Created
August 17, 2019 18:42
-
-
Save Sharpiro/5df4ba2069acc048a4777c723eb01445 to your computer and use it in GitHub Desktop.
http request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
# https://93.184.216.34/ # example.com | |
# http://52.239.152.74/tor-blobs/tor.txt # http://torpy.blob.core.windows.net/tor-blobs/tor.txt | |
# # example.com | |
# ip_address = "93.184.216.34" | |
# port = 80 | |
# host = "example.com" | |
# path = "/" | |
# http://torpy.blob.core.windows.net/tor-blobs/tor.txt | |
ip_address = "52.239.152.74" | |
port = 80 | |
host = "torpy.blob.core.windows.net" | |
path = "/tor-blobs/tor.txt" | |
request = bytearray(f"GET {path} HTTP/1.1\r\nHost: {host}\r\nAccept: */*\r\n\r\n", "utf8") | |
plain_socket = socket.create_connection((host, port)) | |
plain_socket.send(request) | |
data = plain_socket.recv(5000) | |
str_data = str(data, "utf8") | |
# index = data.index(bytes([13, 10, 13, 10])) + 4 | |
index = str_data.index("\r\n\r\n") + 4 | |
print(str_data[:index]) | |
print(len(data[index:])) | |
print(data[index:]) | |
# print(str_data[index:]) | |
# print(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment