-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscapy-scan-arp.py
More file actions
31 lines (24 loc) · 881 Bytes
/
scapy-scan-arp.py
File metadata and controls
31 lines (24 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import scapy.all as scapy
import sys
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
# --------------------------------------------------
# FUNCTIONS
# --------------------------------------------------
def scan(target):
packet = scapy.Ether(dst='ff:ff:ff:ff:ff:ff')/scapy.ARP(pdst=target)
answer, noanswer = scapy.srp(packet, timeout=1, verbose=False)
for item in answer:
# item = (sent packet, received packet)
print( f'ARP reply from {item[1].psrc} ({item[1].hwsrc})' )
# --------------------------------------------------
# MAIN
# --------------------------------------------------
if __name__ == '__main__':
if len(sys.argv)==2:
target = sys.argv[1]
print(f'scan {target} with ARP')
scan(target)
else:
print(f'Usage: {sys.argv[0]} <target|range>')