Posted By

brm on 06/16/15


Tagged

sysdamin information-gathering


Versions (?)

simple banner grabbing


 / Published in: Python
 

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

  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  

You need to login to post a comment.