Skip to content

Instantly share code, notes, and snippets.

@khajer
Created July 5, 2011 10:43
Show Gist options
  • Select an option

  • Save khajer/1064642 to your computer and use it in GitHub Desktop.

Select an option

Save khajer/1064642 to your computer and use it in GitHub Desktop.
scan port
from socket import *
if __name__ == '__main__':
target = raw_input('Enter host to scan: ')
targetIP = gethostbyname(target)
print 'Starting scan on host ', targetIP
#scan reserved ports
for i in range(20, 1025):
s = socket(AF_INET, SOCK_STREAM)
result = s.connect_ex((targetIP, i))
if(result == 0) :
print 'Port %d: OPEN' % (i,)
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment