DEV Community

Pandeyashish17
Pandeyashish17

Posted on

3

Let's see wifi password using python

Hey guys, welcome to the world of Python and wifi hacking... just kidding! In this article, we will be taking a look at a Python script that can be used to view the Wi-Fi password for a network you are currently connected to.

The script uses the subprocess module to run the command netsh wlan show profile [network name] key=clear. This command retrieves information about the specified network and the stdout=subprocess.PIPE redirects the output to a variable.

The output is then decoded and stored in the output variable. After that, the script splits the output into a list of lines, and iterates through each line. If a line contains the string "Key Content", the script extracts the wifi password from the line and prints it.

Here's the full script for your reference:

import subprocess

network_name = "Get your own wifi" #your_wifi_network_name

result = subprocess.run(['netsh', 'wlan', 'show', 'profile', network_name, 'key=clear'], stdout=subprocess.PIPE)
output = result.stdout.decode()

for line in output.split('\n'):
    if "Key Content" in line:
        print(line.split(":")[1].strip())

Enter fullscreen mode Exit fullscreen mode

As you can see, this script is quite simple and straightforward. You just need to replace "Get your own wifi" with the name of the network you want to retrieve the password for.

And that's it, folks! With this script, you'll be able to hack into your own wifi network and retrieve the password in case you forget it!

AWS reinvent image

Exclusive savings when you register before November 7!

Act now to save $150 using the following discount code: DEVEXJVu6vUt. This special discount is only available for the first 100 tickets booked on or before November 7th.

BONUS!!! Lock in your tickets! Receive $250 Delta Air Lines flight vouchers when you book using this discount code.

*Voucher will be sent to the email you use to register for re:Invent.
Register now

Top comments (0)

Hosting.com image

Your VPS. Your rules.

No bloat, no shortcuts. Just raw VPS power with full root, NVMe storage, and AMD EPYC performance. Ready when you are.

Learn more