-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscanner.py
57 lines (34 loc) · 2.92 KB
/
scanner.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from scapy.all import ARP, Ether, srp
logo = """
██▓███ ▄▄▄ ██████ ██████ █ █░ ▒█████ ██▀███ ▓█████▄
▓██░ ██▒▒████▄ ▒██ ▒ ▒██ ▒ ▓█░ █ ░█░▒██▒ ██▒▓██ ▒ ██▒▒██▀ ██▌
▓██░ ██▓▒▒██ ▀█▄ ░ ▓██▄ ░ ▓██▄ ▒█░ █ ░█ ▒██░ ██▒▓██ ░▄█ ▒░██ █▌
▒██▄█▓▒ ▒░██▄▄▄▄██ ▒ ██▒ ▒ ██▒░█░ █ ░█ ▒██ ██░▒██▀▀█▄ ░▓█▄ ▌
▒██▒ ░ ░ ▓█ ▓██▒▒██████▒▒▒██████▒▒░░██▒██▓ ░ ████▓▒░░██▓ ▒██▒░▒████▓
▒▓▒░ ░ ░ ▒▒ ▓▒█░▒ ▒▓▒ ▒ ░▒ ▒▓▒ ▒ ░░ ▓░▒ ▒ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒▓ ▒
░▒ ░ ▒ ▒▒ ░░ ░▒ ░ ░░ ░▒ ░ ░ ▒ ░ ░ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ▒ ▒
░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░
░
"""
print(logo)
target_ip = input('target_ip: ')
# IP Address for the destination
# create ARP packet
arp = ARP(pdst=target_ip)
# create the Ether broadcast packet
# ff:ff:ff:ff:ff:ff MAC address indicates broadcasting
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
# stack them
packet = ether/arp
result = srp(packet, timeout=3, verbose=0)[0]
# a list of clients, we will fill this in the upcoming loop
clients = []
for sent, received in result:
# for each response, append ip and mac address to `clients` list
clients.append({'ip': received.psrc, 'mac': received.hwsrc})
# print clients
print("Available devices in the network:")
print("IP" + " "*18+"MAC")
for client in clients:
print("{:16} {}".format(client['ip'], client['mac']))