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!

Build gen AI apps that run anywhere with MongoDB Atlas

Build gen AI apps that run anywhere with MongoDB Atlas

MongoDB Atlas bundles vector search and a flexible document model so developers can build, scale, and run gen AI apps without juggling multiple databases. From LLM to semantic search, Atlas streamlines AI architecture. Start free today.

Start Free

Top comments (0)

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

👋 Kindness is contagious

Take a moment to explore this thoughtful article, beloved by the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A heartfelt "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay