1
0
mirror of https://github.com/danog/scapy-tools.git synced 2024-11-26 11:54:40 +01:00
scapy-tools/nmap_auto.py
Daniil Gentili c78718cbf7 first commit
2017-04-20 13:40:48 +02:00

49 lines
1.7 KiB
Python

from scapy.all import *
import os
if len(sys.argv) < 3:
print("Usage: nmap_auto.py address porta-portb-portc")
sys.exit()
ports = os.sys.argv[2].split("-")
ports = [int(port) for port in ports]
print("EXECUTING UDP SCAN ON "+os.sys.argv[1]+" ports "+str(ports))
ans,unans=sr(IP(dst=os.sys.argv[1])/UDP(dport=ports), timeout=2, verbose=False)
ans.summary( lambda(s,r) : r.sprintf("%IP.sport%: open") )
unans.summary( lambda(s) : s.sprintf("%IP.dport%: open|filtered") )
print("EXECUTING SYN SCAN ON "+os.sys.argv[1]+" ports "+str(ports))
ans,unans = sr(IP(dst=os.sys.argv[1])/TCP(dport=ports,flags="S"), timeout=2, verbose=False)
for s,r in ans:
if s[TCP].dport == r[TCP].sport:
print str(s[TCP].dport) + ": open"
for s in unans:
print str(s[TCP].dport) + ": closed"
print("EXECUTING ACK SCAN ON "+os.sys.argv[1]+" ports "+str(ports))
ans,unans = sr(IP(dst=os.sys.argv[1])/TCP(dport=ports,flags="A"), timeout=1, verbose=False)
for s,r in ans:
if s[TCP].dport == r[TCP].sport:
print str(s[TCP].dport) + ": open"
for s in unans:
print str(s[TCP].dport) + ": open|filtered"
print("EXECUTING NULL SCAN ON "+os.sys.argv[1]+" ports "+str(ports))
ans,unans = sr(IP(dst=os.sys.argv[1])/TCP(dport=ports,flags=""), timeout=1, verbose=False)
for s,r in ans:
if s[TCP].dport == r[TCP].sport:
print str(s[TCP].dport) + ": open"
for s in unans:
print str(s[TCP].dport) + ": open|filtered"
print("EXECUTING XMAS SCAN ON "+os.sys.argv[1]+" ports "+str(ports))
ans,unans = sr(IP(dst=os.sys.argv[1])/TCP(dport=ports,flags="FPU"), timeout=1, verbose=False)
for s,r in ans:
if s[TCP].dport == r[TCP].sport:
print str(s[TCP].dport) + ": open"
for s in unans:
print str(s[TCP].dport) + ": open|filtered"