mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-04-28 11:36:08 -04:00
super scanner
This commit is contained in:
parent
ba1c777dd9
commit
5e0ef6f5c7
@ -7,44 +7,55 @@ import netaddr
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
RANGE = "192.168.1.0/24"
|
RANGE = "192.168.1.0/24"
|
||||||
PORTS = [22,23,80,443,449]
|
PORTS = [22, 23, 80, 443, 449]
|
||||||
|
CODES = [1, 2, 3, 9, 10, 13]
|
||||||
|
RANGE_IP = netaddr.IPNetwork(RANGE)
|
||||||
|
|
||||||
addresses = netaddr.IPNetwork(RANGE)
|
|
||||||
|
|
||||||
def portScan(host, ports):
|
def port_scanner(host, ports):
|
||||||
for dstPort in ports:
|
for dstPort in ports:
|
||||||
srcPort = random.randint(1025,65534)
|
srcPort = random.randint(1025,65534)
|
||||||
resp = sr1(IP(dst=host)/TCP(sport=srcPort,dport=dstPort,flags="S"),timeout=1,verbose=0)
|
resp = sr1(IP(dst=host)/TCP(sport=srcPort,dport=dstPort,flags="S"),timeout=1,verbose=0)
|
||||||
|
|
||||||
if (str(type(resp)) == "<type 'NoneType'>"):
|
if (str(type(resp)) == "<type 'NoneType'>"):
|
||||||
print host + ":" + str(dstPort) + " is filtered (silently dropped)."
|
print host + ":" + str(dstPort) + " is filtered (dropped)."
|
||||||
|
|
||||||
elif(resp.haslayer(TCP)):
|
elif(resp.haslayer(TCP)):
|
||||||
|
|
||||||
if(resp.getlayer(TCP).flags == 0x12):
|
if(resp.getlayer(TCP).flags == 0x12):
|
||||||
send_rst = sr(IP(dst=host)/TCP(sport=srcPort,dport=dstPort,flags="R"),timeout=1,verbose=0)
|
send_rst = sr(IP(dst=host)/TCP(sport=srcPort, dport=dstPort, flags="R"),\
|
||||||
|
timeout=1, verbose=0)
|
||||||
print host + ":" + str(dstPort) + " is open."
|
print host + ":" + str(dstPort) + " is open."
|
||||||
|
|
||||||
elif (resp.getlayer(TCP).flags == 0x14):
|
elif (resp.getlayer(TCP).flags == 0x14):
|
||||||
print host + ":" + str(dstPort) + " is closed."
|
print host + ":" + str(dstPort) + " is closed."
|
||||||
|
|
||||||
elif(resp.haslayer(ICMP)):
|
elif(resp.haslayer(ICMP)):
|
||||||
if(int(resp.getlayer(ICMP).type)==3 and int(resp.getlayer(ICMP).code) in [1,2,3,9,10,13]):
|
if(int(resp.getlayer(ICMP).type) == 3 and int(resp.getlayer(ICMP).code) in \
|
||||||
print host + ":" + str(dstPort) + " is filtered (silently dropped)."
|
CODES):
|
||||||
|
print host + ":" + str(dstPort) + " is filtered dropped)."
|
||||||
|
|
||||||
|
|
||||||
def super_scanner():
|
def super_scanner():
|
||||||
liveCounter = 0
|
liveCounter = 0
|
||||||
for addr in addresses:
|
for addr in RANGE_IP:
|
||||||
if (addr == addresses.network or addr == addresses.broadcast):
|
if (addr == RANGE_IP.network or addr == RANGE_IP.broadcast):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
resp = sr1(IP(dst=str(addr))/ICMP(),timeout=2,verbose=0)
|
resp = sr1(IP(dst=str(addr))/ICMP(), timeout=2, verbose=0)
|
||||||
if (str(type(resp)) == "<type 'NoneType'>"):
|
if (str(type(resp)) == "<type 'NoneType'>"):
|
||||||
print str(addr) + " is down or not responding."
|
print str(addr) + " is down or not responding."
|
||||||
elif (int(resp.getlayer(ICMP).type)==3 and int(resp.getlayer(ICMP).code) in [1,2,3,9,10,13]):
|
|
||||||
|
elif (int(resp.getlayer(ICMP).type) == 3 and int(resp.getlayer(ICMP).code) in CODES):
|
||||||
print str(addr) + " is blocking ICMP."
|
print str(addr) + " is blocking ICMP."
|
||||||
|
|
||||||
else:
|
else:
|
||||||
portScan(str(addr),PORTS)
|
port_scanner(str(addr),PORTS)
|
||||||
liveCounter += 1
|
liveCounter += 1
|
||||||
|
|
||||||
print "Out of " + str(addresses.size) + " hosts, " + str(liveCounter) + " are online."
|
print "Scanned hosts: " + str(RANGE_IP.size)
|
||||||
|
print "Online hosts: " + str(liveCounter)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
super_scanner()
|
super_scanner()
|
Loading…
x
Reference in New Issue
Block a user