diff --git a/README.md b/README.md index b2a2571..65fbba6 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ IP Navigator is a Flask application designed for the efficient management of IP ## Prerequisites - Python 3 - Node.js and npm +- Scapy + - https://rootinstall.com/tutorial/how-to-install-scapy-on-windows/ + - https://rootinstall.com/tutorial/how-to-install-scapy-on-ubuntu/ ## Setup 1. Clone the repository: diff --git a/ip-atlas/utils/netscan.py b/ip-atlas/utils/netscan.py new file mode 100644 index 0000000..e984e04 --- /dev/null +++ b/ip-atlas/utils/netscan.py @@ -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'])) \ No newline at end of file