1
0
mirror of https://github.com/danog/scapy-tools.git synced 2024-11-26 20:04:41 +01:00
scapy-tools/ping_range.py

13 lines
546 B
Python
Raw Permalink Normal View History

2017-04-20 13:40:48 +02:00
from scapy.all import *
import os
for x in range(0, 255):
ping = sr(IP(dst="192.168.1."+str(x))/ICMP(), timeout=1, verbose=False)
if ping and len(ping[0].res):
if ping[0].res[0][1].payload.code == 0:
print("echo reply from "+ping[0].res[0][1].src+": icmp_seq "+str(ping[0].res[0][1].payload.seq)+", ttl "+str(ping[0].res[0][1].ttl))
else:
print("Got another ICMP code ("+str(ping[0].res[0][1].payload.code)+") from "+ping[0].res[0][1].src)
else:
print("FAILURE for 192.168.1."+str(x))