Skip to content

Instantly share code, notes, and snippets.

@samduy
Created December 31, 2017 12:06
Show Gist options
  • Save samduy/d5e92897c0d432da48a196f930bcb99b to your computer and use it in GitHub Desktop.
Save samduy/d5e92897c0d432da48a196f930bcb99b to your computer and use it in GitHub Desktop.
Python port scanner
import socket as sk
for port in range(1,1024):
try:
s=sk.socket(sk.AF_NET,sk.SOCK_STREAM)
s.settimeout(1000)
s.connect(('127.0.0.1',port))
print '%d: OPEN' % (port)
s.close
except: continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment