Created
September 24, 2017 09:24
-
-
Save v2-dev/88e77bff5659dd9be481bea05693d6b0 to your computer and use it in GitHub Desktop.
find every device connected to the subnet with the pair MAC Address <---> Subnet IP using scapylibrary
This file contains hidden or 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
#! /usr/bin/env python | |
# scan-layer2 : arpings a subnet to find every device connected to the subnet | |
import sys | |
if len(sys.argv) != 2: | |
print ("Usage: scan-layer2 \n eg: scan-layer2.py 192.168.1.0/24") | |
sys.exit(1) | |
from scapy.all import srp,Ether,ARP,conf | |
ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=sys.argv[1]),timeout=10) | |
for snd,rcv in ans: | |
print(rcv.sprintf(r"%Ether.src% & %ARP.psrc%")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment