File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change
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 ()
You can’t perform that action at this time.
0 commit comments