DEV Community


Posted on

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 =['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:

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!

Latest comments (0)