programming/python/bhp/junk/banner_grab.py

25 lines
528 B
Python
Raw Normal View History

#!/usr/bin/python3
import socket
targetHost = "127.0.0.1"
2021-05-17 10:58:35 -06:00
targetPort = 9999
print(targetHost)
#create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#connect the client
client.connect((targetHost, targetPort))
#send some data
message = "GET / HTTP/1.1\r\nHost: google.com\r\n\r\n"
#we have to encode our string using UTF-8
#client.send(message.encode("utf-8"))
#receive some data
response = client.recv(4096) #This is the amount of bytes you want to read!!
#print the response
2021-05-17 10:58:35 -06:00
print(response)