Skip to content

Instantly share code, notes, and snippets.

@alan-mushi
Created December 2, 2015 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alan-mushi/188639febbfab479dd06 to your computer and use it in GitHub Desktop.
Save alan-mushi/188639febbfab479dd06 to your computer and use it in GitHub Desktop.
SRI TP scapy TCP connect dumb scanner
from scapy.all import *
ip_dst = "104.16.34.249"
for i in range(1, 65536):
ans,uns = sr(IP(dst=ip_dst) / TCP(dport=i, flags="S"), timeout=1, retry=-2, verbose=False)
try:
if ans[0][1].getlayer(TCP).flags & 0x12 == 0x12:
print str(i) + " is open"
ans.summary()
# On ferme la communication
sr(IP(dst=ip_dst) / TCP(dport=i, flags="AR"), timeout=10, verbose=False)
except AttributeError:
print str(i) + " is closed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment