1

def main(port):
    try:
        ip = '192.168.0.51'
        s = socket.socket()
        socket.setdefaulttimeout(1)
        s.connect((ip, port))
        rec = s.recv(1024).decode('utf-8')
        print(rec)
    except Exception:
        pass

for port in range(1,100):
    main(port)

I have watched tutorials on this and it still has not worked for me, I also tried it with my public IP but obviously I didn't put that in the code shown. I didn't receive any data from the connection, so I tried to decode it but still didn't work. I am trying to get the banner so the service running on the port. How would I do this? What did I do wrong? I don't mind if it's in py2 or py3

0 Answers0