simple banner grabbing


/ Published in: Python
Save to your folder(s)

Simple script to banner grabbing the service based port(HTTP, SMTP, POP3, etc) - really simple method.


Copy this code and paste it in your HTML
  1. #!/usr/bin/python
  2. #service banner grabbing - bannergrab.py
  3. """
  4. simple banner grabbing - not really useful when port protected, pretty much can read HTTP Header/SMTP/POP
  5. """
  6.  
  7. import sys, socket, urllib
  8.  
  9. if len(sys.argv) != 2:
  10. print "usage: python bannergrab.py <url/host> "
  11. raise SystemExit(1)
  12.  
  13. target = sys.argv[1]
  14.  
  15. if target[0:4] == "http":
  16. page = urllib.urlopen(target)
  17. print page.info()
  18. else:
  19. port = raw_input("enter port number: ")
  20. sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  21. sock.connect((target, int(port)))
  22. print sock.recv(1024)
  23. sock.close()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.