Created
September 15, 2013 15:57
-
-
Save packetforger/6571975 to your computer and use it in GitHub Desktop.
synprobe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
# SYN probes a port on an IP, tells if open/closed | |
from scapy.all import * | |
import sys | |
def synprobe(targetIP, targetPort): | |
""" Send a SYN packet, recieve reply, tell if open/closed """ | |
probe = sr1(IP(dst=targetIP)/TCP(dport= int(targetPort), flags = "S"), verbose = False, timeout = 2) | |
if probe[TCP].flags == 18: | |
print "%s:%s open" %(targetIP, targetPort) | |
else: | |
print "%s:%s closed" %(targetIP, targetPort) | |
def main(args): | |
if len(sys.argv) != 3: | |
sys.exit("usage: %s <targetip> <targetport>" %(sys.argv[0])) | |
synprobe(sys.argv[1], sys.argv[2]) | |
if __name__ == "__main__": | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment