Advertisement
Guest User

Untitled

a guest
Nov 4th, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # Created by Pathogen @ www.hakhub.tk
  2.  
  3. import socket,sys,re
  4. def portscan(host):
  5.  portrange = [21,22,23,25,80,110,111,143,445,631,1337,1433,3389,5631,5800,5900,5901,8080,8123,9050]
  6.  # ^ The ports to scan ^
  7.  for portnum in portrange:
  8.   sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  9.   if re.search('www',host):
  10.    host = socket.gethostbyname(host)
  11.    socket.setdefaulttimeout(4)
  12.   try:
  13.    sock.connect((host, portnum))
  14.    sock.close()
  15.    print str(portnum) + " open."
  16.   except:
  17.    pass
  18. try:
  19.  portscan(sys.argv[1])
  20. except:
  21.  print "No ports specified. (EX. python scan.py 127.0.0.1)"
  22.  
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement