-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynScanner.py
More file actions
32 lines (28 loc) · 934 Bytes
/
synScanner.py
File metadata and controls
32 lines (28 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
from scapy.all import *
import sys, getopt
def help():
print "Usage: sudo ./synScanner.py <host> <port>"
def main(argv):
try:
opts, args = getopt.getopt(argv, "h")
except getopt.GetoptError:
help()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h"):
help()
sys.exit()
if len(args) < 2:
usage()
sys.exit(2)
response = sr1(IP(dst=args[0])/TCP(dport=int(args[1]), flags="S"), timeout=5, verbose=0)
if response:
if response.sprintf("%TCP.flags%") == "SA":
print "Port " + args[1] + " open"
else:
print "Port " + args[1] + " closed"
else:
print "No response"
if __name__ == "__main__":
main(sys.argv[1:])