-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkScanner.py
More file actions
38 lines (28 loc) · 1021 Bytes
/
NetworkScanner.py
File metadata and controls
38 lines (28 loc) · 1021 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 python
import scapy.all as scapy
import argparse
def arguments():
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--target", dest="target", help="Target IP / IP range")
options = parser.parse_args()
if not options.target:
print("Please specify the target, use --help for more info")
exit()
return options
def scan(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast / arp_request
answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
client_list = []
for element in answered_list:
client_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc}
client_list.append(client_dict)
return client_list
def result(client_list):
print("IP\t\t\tMAC Address")
for element in client_list:
print(element["ip"] + "\t\t" + element["mac"])
ips = arguments()
scan_result = scan(ips.target)
result(scan_result)