-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnetScanner.py
More file actions
41 lines (32 loc) · 1.15 KB
/
netScanner.py
File metadata and controls
41 lines (32 loc) · 1.15 KB
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
39
40
41
from scapy.all import *
import optparse
#Function to get the user input
def ip():
get_ip()
def get_ip():
parser = optparse.OptionParser()
parser.add_option("-i", "--ip", dest="ip", help="Your IP address")
(options, arguments) = parser.parse_args()
#check of the user input
if not options.ip:
print("[-] Enter your IP address, see --help for more info")
raise SystemExit
else:
return options.ip
def scan(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast_request = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_broadcast_request = broadcast_request / arp_request
answered, unanswered = scapy.srp(
arp_broadcast_request, timeout=1, verbose=False)
client_list = []
print("+-----------------------+--------------------+\n| IP \t\t\t| MAC Address\t" +
" "+"|\n+-----------------------+--------------------+")
for element in answered:
client_dic = {"IP": element[1].psrc, "MAC": element[1].hwsrc}
print("| "+element[1].psrc + "\t\t" + "| "+element[1].hwsrc+" |")
client_list.append(client_dic)
print("+-----------------------+--------------------+")
#execute
ip_address = get_ip()
scan(ip_address)