Help with simple banner grabber in python

Home Forums Help with simple banner grabber in python

This topic contains 0 replies, has 1 voice, and was last updated by  BrianMiz 4 days, 2 hours ago.

  • Author
    Posts
  • #133384

    BrianMiz
    Member

    Hey guys. I am new to all this and I am trying to write a simple banner grabber in python.

    The only problem I have is the HTTP HEADER request. I always get the 400 error message. I would be glad if someone leave me some useful resources regarding HTTP HEADERS (I basically just copied the request from a tutorial because I couldn’t find any resources which helped me). I also would be very happy if someone could help me out on my code. Very simple code. Thank you in advance.

    #/usr/bin/env python
    import sys
    import socket

    try:
    if len(sys.argv) == 3:
    IP = str(sys.argv[1])
    PORT = int(sys.argv[2])

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(3)
    s.connect((IP,PORT))
    #ERROR POSITION
    s.send(b”GET HTTP/1.1 nn”)
    banner = s.recv(1024)
    s.close()
    print(banner)
    except socket.timeout:
    print(“Connection timed out”)
    except Exception:
    print(“Define a target”)
    finally:
    s.close()

You must be logged in to reply to this topic.