Skip to content

Commit 6964227

Browse files
committed
Script to find all IPs of devices connected in Network
1 parent 8e18e28 commit 6964227

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Author: OMKAR PATHAK
2+
3+
# This script helps to find the devices (mobiles and computers) connected to my wifi
4+
5+
# This script needs python-nmap as a pre-requisite. To install: sudo pip3 install python-nmap
6+
7+
import nmap
8+
import subprocess
9+
10+
# function to scan network and display IPs of conected devices
11+
def scan_network():
12+
scanner = nmap.PortScanner()
13+
myIP = subprocess.check_output(['hostname -I'], shell=True)
14+
myIP = str(myIP, 'utf-8').split('.')
15+
print(myIP[:3])
16+
scannedData = scanner.scan(hosts = '.'.join(myIP[:3]) + '.1/24', arguments = '-sP')
17+
18+
# printing all the IP addresses of connected devices
19+
for hostnames in scannedData['scan']:
20+
print(hostnames)
21+
22+
scan_network()

0 commit comments

Comments
 (0)