Skip to content

Commit

Permalink
super scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari Wahl committed Dec 29, 2014
1 parent ba1c777 commit 5e0ef6f
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions Network_and_802.11/scapy/super_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,55 @@
import random

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:
srcPort = random.randint(1025,65534)
resp = sr1(IP(dst=host)/TCP(sport=srcPort,dport=dstPort,flags="S"),timeout=1,verbose=0)

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)):

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."

elif (resp.getlayer(TCP).flags == 0x14):
print host + ":" + str(dstPort) + " is closed."

elif(resp.haslayer(ICMP)):
if(int(resp.getlayer(ICMP).type)==3 and int(resp.getlayer(ICMP).code) in [1,2,3,9,10,13]):
print host + ":" + str(dstPort) + " is filtered (silently dropped)."
if(int(resp.getlayer(ICMP).type) == 3 and int(resp.getlayer(ICMP).code) in \
CODES):
print host + ":" + str(dstPort) + " is filtered dropped)."


def super_scanner():
liveCounter = 0
for addr in addresses:
if (addr == addresses.network or addr == addresses.broadcast):
for addr in RANGE_IP:
if (addr == RANGE_IP.network or addr == RANGE_IP.broadcast):
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'>"):
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."

else:
portScan(str(addr),PORTS)
port_scanner(str(addr),PORTS)
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__':
super_scanner()

0 comments on commit 5e0ef6f

Please sign in to comment.