Skip to content

Commit 36196b3

Browse files
Merge pull request #2062 from tayyab-ilyas/network-scanner
Added Network scanner script
2 parents 7433075 + 388b1c6 commit 36196b3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Network Scanner/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Network Scanner
2+
3+
This is a simple Python script that uses the Scapy library to scan the local network and find connected devices.
4+
5+
## Usage
6+
7+
1. Install the Scapy library. You can install it using pip:
8+
9+
```shell
10+
pip install scapy
11+
12+
2. Run the script by executing the following command:
13+
14+
```shell
15+
python network-scanner.py
16+
17+
3. When prompted, enter the target IP address or IP range in the format "ip_address/24". For example, "192.168.1.0/24".
18+
19+
4. The script will send ARP requests to the specified IP range and display the list of available devices along with their IP and MAC addresses.

Network Scanner/network-scanner.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from scapy.all import ARP, Ether, srp
2+
3+
t_ip = input("Enter the Target IP (ip_address/24): ")
4+
arp = ARP(pdst=t_ip)
5+
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
6+
packet = ether/arp
7+
result = srp(packet, timeout=3, verbose=0)[0]
8+
clients = []
9+
for sent, received in result:
10+
clients.append({'ip': received.psrc, 'mac': received.hwsrc})
11+
12+
print("Available Devices: ")
13+
print("IP" + " "*18+"MAC")
14+
15+
for client in clients:
16+
print(("{:16} {}".format(client['ip'], client['mac'])))

0 commit comments

Comments
 (0)