How to get Wi-Fi passwords using Python code

  • Post author:
  • Post comments:0 Comments
  • Reading time:30 mins read

When we connect to a Wi-Fi network we usually need to enter a password. However, we cannot directly view the password that was previously entered for a saved network. In this article, we will explore how Python can be used to retrieve all the saved Wi-Fi names and passwords. To accomplish this we will utilize the module, in Python.
Wi-Fi is a technology that enables networking allowing devices like computers (laptops and desktops) devices (smartphones and wearables) and other equipment (printers and video cameras) to connect with the Internet.

Getting Wi-Fi password using Python code

import subprocess

data = (
    subprocess.check_output(["netsh", "wlan", "show", "profiles"])
profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i]
for i in profiles:
    results = (
        .check_output(["netsh", "wlan", "show", "profile", i, "key=clear"])
    results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
        print("{:<30}|  {:<}".format(i, results[0]))
    except IndexError:
        print("{:<30}|  {:<}".format(i, ""))

After successfully running this code you will be able to see the saved password result on your terminal. There you go now you learn how to get saved wifi password using python with just few lines of code

Latest posts by Publisher (see all)


Publisher @ideasorblogs

Leave a Reply