python

Discover and identify who's in your network using a simple python script

By crypt0z | crypto0z | 2 Feb 2021


 

- Introduction

 

in this post, we will build an Arp scanner script that can detect and identify every host in your LAN.

you might ask what is "Arp"? , Arp is a protocol that maps an IP address to a physical MAC Address on a local area network (LAN), on the LAN, Computers use the "Arp" protocol to find each other MAC Address to communicate with each other, and that's because on the LAN hosts use The Mac Address rather than The Ip Address

arp

 

Requirements

 

you will need to download the python library Scapy, which is our main library in this post, and you will need to download the mac-vendor-lookup library which is basically a "mac vendor lookup", you can use any method you want to lookup the vendor of a mac address once you  got it

you can Download it using pip :

pip install scapy

pip install mac-vendor-lookup

- Code

what we will do in this script is that we are going to send an Arp request to every single host in our network.

we can easily do that with this code :

 

python_code_1

 

in this code, we built a function called "arp_scanner" which sends Arp request to the target, and if it's "alive" it will print out its IP and mac address and vendor. since we can know the vendor of the host using its mac address.

well, that's basically it, hope that was helpful : )

happy coding <3

How do you rate this article?

15

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.