Created
July 4, 2017 01:58
-
-
Save mjuenema/d8921e091f6ac1694f31aa52f455f97f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Ping all hosts in 10.1.10/24 and print IP addresses of | |
hosts that replied. | |
Requires scapy (https://pypi.python.org/pypi/scapy) and | |
must be run with root permissions. | |
(c) 2017 Markus Juenemann | |
""" | |
import threading | |
from scapy.all import sr1, IP, ICMP | |
HOSTS = ['10.1.1.%s' % (n) for n in range(1,255)] | |
def sender(host): | |
reply = sr1(IP(dst=host)/ICMP(), retry=3, timeout=1.0, verbose=0) | |
if reply: | |
print reply.src | |
def main(): | |
threads = [threading.Thread(target=sender, args=(host,)).start() | |
for host in HOSTS] | |
for thread in threads: | |
if thread: | |
thread.join() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment