Skip to content

Instantly share code, notes, and snippets.

@sente
Created February 3, 2011 11:16
Show Gist options
  • Save sente/809363 to your computer and use it in GitHub Desktop.
Save sente/809363 to your computer and use it in GitHub Desktop.
scan for open ports
#!/usr/bin/python
import sys
import socket
try:
server = sys.argv[1]
except:
server = "localhost"
for x in range(10000):
try:
s = socket.create_connection((server,x),.1)
print x
except:
pass
# $ python portscan.py localhost
#21
#22
#25
#80
#81
#111
#139
#143
#445
#587
#974
#993
#3000
#3306
#8080
#9418
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment