-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnet_scanner7.py
More file actions
26 lines (21 loc) · 915 Bytes
/
Copy pathnet_scanner7.py
File metadata and controls
26 lines (21 loc) · 915 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
#!/usr/bin/env python
from tabnanny import verbose
import scapy.all as scapy
import optparse
def get_ip() :
parser = optparse.OptionParser()
parser.add_option("-i", "--ip_address", dest="ip", help="Enter IP Address Range, to do so, use -i or --ip_address followed by IP Address range to be scanned")
(options, arguments) = parser.parse_args()
if not options.ip :
parser.error("[-] Please enter an IP address range")
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]
print("IP\t\t\tMAC Address\n------------------------------------------------")
for element in answered_list:
print(element[1].psrc + "\t\t" + element[1].hwsrc)
options = get_ip()
scan(options.ip)