Introduction

This example will show you how to find all users connected to wifi network using Python 3. Sometimes just for fun we may want to know who all are connected to the same wifi network. We can also use the command netsh wlan show network in cmd window under Windows Operating System to find out who all users are currently online in the wifi network.

Here we will find all users connected to wifi network using Python programming language.

Prerequisites

Have Python installed in Windows (or Unix)
Pyhton version and Packages
Here I am using Python 3.6.6 version

Example with Source Code

We have used command netsh wlan show network in our Python script to retrieve all online users information. The information will show you as SSID and username of all currently online users. The SSID is the name of the wifi or wireless network. It is a unique 32 alphanumeric characters for each user.

Netsh is a command-line scripting utility that allows you to display or modify the network configuration of a computer that is currently running.

WLAN commands that allow you to access the Wi-Fi profiles.

Network the unique name of wireless network.

Then we basically split, extract and format to print the wifi network name (SSID) and user name of the wifi network for currently online users.

import subprocess

results = subprocess.check_output(["netsh", "wlan", "show", "network"])
results = results.decode("ascii")
results = results.replace("\r","")
ls = results.split("\n")
ls = ls[4:]
ssids = []
x = 0
while x < len(ls):
    if x % 5 == 0:
        ssids.append(ls[x])
    x += 1
print(ssids)

Testing the Program

When you run the above Python script then you will be able to see the below output in the console:

find all users connected to wifi network using python

That’s all. Hope you got idea how to find all users connected to wifi network using Python 3.

Source Code

You can download source code.

Thanks for reading.

Tags: •

Leave a Reply

Your email address will not be published. Required fields are marked *