-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAC-reader.py
33 lines (24 loc) · 914 Bytes
/
MAC-reader.py
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
#!/usr/bin/env python3
import scapy.all as scapy
def scan(ip):
arp_req = scapy.ARP(pdst=ip)
#arp_req.show()
#print(arp_req.summary())
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
#broadcast.show()
#print(broadcast.summary())
arp_req_broadcast = broadcast/arp_req
#arp_req_broadcast.show()
#print(arp_req_broadcast.summary())
answered, unanswered = scapy.srp(arp_req_broadcast,timeout=1,verbose=False)
# print(answered.summary())
client_list = []
for ans in answered:
client_dict = { "ip" : ans[1].psrc, "mac" : ans[1].hwsrc }
client_list.append(client_dict)
return client_list
def print_result(result_list):
print("IP\t\t\tMAC Address\n----------------------------------------------------------------")
for client in result_list:
print(client["ip"] + "\t\t" + client["mac"])
print_result(scan("10.0.2.1/24"))