DEV Community

Pandeyashish17
Pandeyashish17

Posted on

2

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!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more