-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from scapy.all import ARP, Ether, srp | ||
|
||
# https://thepythoncode.com/article/building-network-scanner-using-scapy | ||
|
||
target_ip = "192.69.69.1/24" | ||
# 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'])) |