-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharpscan.py
More file actions
38 lines (26 loc) · 911 Bytes
/
arpscan.py
File metadata and controls
38 lines (26 loc) · 911 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
32
33
34
35
36
37
38
#!/usr/bin/env python3
"""ARP Scan
Scans a given address range to find devices
Usage: $ python3 arpscan.py
"""
### Import Statements ###
from scapy.all import *
broadcast_MAC = "ff:ff:ff:ff:ff:ff"
### Functions ###
def arp_scan(ip_range: str, interface: str) -> None:
"""Uses ARP and scapy to scan a range of addresses
Args:
range (str): IP range using CIDR notation
interface (str): The interface scanning from
"""
packet = Ether(dst=broadcast_MAC) / ARP(pdst=ip_range)
ans, unans = srp(packet, timeout=2, iface=interface, inter=0.1)
for send, receive in ans:
print(receive.sprintf(r"%Ether.src% - %ARP.psrc%"))
if __name__ == "__main__":
if os.geteuid() != 0:
print('Must be <root> to run, please try using "sudo python3"...')
sys.exit(1)
interface = "eth0"
ip_range = "192.168.64.1/24"
arp_scan(ip_range, interface)