Getting Saved Wifi Passwords using Python Last Updated : 10 Jun, 2022 Comments Improve Suggest changes Like Article Like Report Usually while connecting with the wifi we have to enter some password to access the network, but we are not directly able to see the password we have entered earlier i.e password of saved network. In this article, we will see how we can get all the saved WiFi name and passwords using Python, in order to do this we will use subprocess module of python.Wi-Fi is a wireless networking technology that allows devices such as computers (laptops and desktops), mobile devices (smartphones and wearables), and other equipment (printers and video cameras) to interface with the Internet.The subprocess module present in Python(both 2.x and 3.x) is used to run new applications or programs through Python code by creating new processes. It also helps to obtain the input/output/error pipes as well as the exit codes of various commands. Steps for Implementation :1. Import the subprocess module 2. Get the metadata of the wlan(wifi) with the help of check_output method 3. Decode the metadata and split the meta data according to the line 4. From the decoded metadata get the names of the saved wlan networks 5. Now for each name again get the metadata of wlan according to the name 6. Start try and catch block and inside the try block, decode and split this metadata and get the password of the given wifi name 7. Print the password and the wifi name and print blank if there is no password 8. In except block if process error occurred print encoding error occurred Below is the implementation Python3 # importing subprocess import subprocess # getting meta data meta_data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']) # decoding meta data data = meta_data.decode('utf-8', errors ="backslashreplace") # splitting data by line by line data = data.split('\n') # creating a list of profiles profiles = [] # traverse the data for i in data: # find "All User Profile" in each item if "All User Profile" in i : # if found # split the item i = i.split(":") # item at index 1 will be the wifi name i = i[1] # formatting the name # first and last character is use less i = i[1:-1] # appending the wifi name in the list profiles.append(i) # printing heading print("{:<30}| {:<}".format("Wi-Fi Name", "Password")) print("----------------------------------------------") # traversing the profiles for i in profiles: # try catch block begins # try block try: # getting meta data with password using wifi name results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key = clear']) # decoding and splitting data line by line results = results.decode('utf-8', errors ="backslashreplace") results = results.split('\n') # finding password from the result list results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b] # if there is password it will print the pass word try: print("{:<30}| {:<}".format(i, results[0])) # else it will print blank in front of pass word except IndexError: print("{:<30}| {:<}".format(i, "")) # called when this process get failed except subprocess.CalledProcessError: print("Encoding Error Occurred") Output : Wi-Fi Name | Password ----------------------------------------------- Engineer | ayush123 honor | 1234567890 Engineer_5GHz | ayush123 Redmi | 12345677 Ayush | 123123123 BiGX-cmtqaGFtYjc | rakshit123 UERJTTBV8e0GUmVkbWkg 2 | 987654321 DESKTOP-F32H70N 5009 | SUSHANT@123 UERJTTBV8e0GUmVkbWkg | Bunns | heyhotspot Hogwarts | sushant@123 Cgc wireless | database1234 Moto G (5) Plus 8691 | rakshit123 AndroidAP | udrw7859 AndroidAPab7e | 123000123 roshan | 12345678 Svj? | salonivij Hey | heythere AndroidAP202 | bhuvanbroo JARVIS | abhishek09 B6NO-wq5hamF0IGt1bWHCrg | 12345678 CDAC | Comment More infoAdvertise with us Next Article Getting Saved Wifi Passwords using Python R rakshitarora Follow Improve Article Tags : Python Python Programs python-utility Practice Tags : python Similar Reads Generate Random Strings for Passwords in Python A strong password should have a mix of uppercase letters, lowercase letters, numbers, and special characters. The efficient way to generate a random password is by using the random.choices() method. This method allows us to pick random characters from a list of choices, and it can repeat characters 2 min read Password validation in Python Let's take a password as a combination of alphanumeric characters along with special characters, and check whether the password is valid or not with the help of few conditions. Conditions for a valid password are: Should have at least one number.Should have at least one uppercase and one lowercase c 4 min read Get Your System Information - Using Python Script Getting system information for your system can easily be done by the operating system in use, Ubuntu let's say. But won't it be fun to get this System information using Python script? In this article, we will look into various ways to derive your system information using Python. There are two ways t 2 min read Finding IP Address using Python An IP(Internet Protocol) address is an identifier assigned to each computer and other device(e.g., router, mobile, etc.) connected to a TCP/IP network that is used to locate and identify the node in communication with other nodes on the network. IP addresses are usually written and displayed in huma 2 min read Python Program to generate one-time password (OTP) One-time Passwords (OTP) is a password that is valid for only one login session or transaction in a computer or a digital device. Now a days OTPâs are used in almost every service like Internet Banking, online transactions, etc. They are generally combination of 4 or 6 numeric digits or a 6-digit al 2 min read Python - Getting all the Wifi Devices the system has connected In this article we will see how we can all those wifi network on which the system is ever connected to. Wi-Fi is a wireless networking technology that allows devices such as computers (laptops and desktops), mobile devices (smart phones and wearables), and other equipment (printers and video cameras 2 min read How to Create Fake Access Points using Scapy in Python? In this article, we are going to discuss how to create fake access points using scapy module in python This task can be done with the help of the python package scapy-fakeap. The intention behind using this library is not only making Fake Access Point but also Testing of 802.11 protocols and its imp 4 min read Python program to check the validity of a Password In this program, we will be taking a password as a combination of alphanumeric characters along with special characters, and checking whether the password is valid or not with the help of a few conditions.Primary conditions for password validation:Minimum 8 characters.The alphabet must be between [a 3 min read Input Validation in Python String In Python, string input validation helps ensure that the data provided by the user or an external source is clean, secure and matches the required format. In this article, we'll explore how to perform input validation in Python and best practices for ensuring that strings are correctly validated.Pyt 2 min read How to Build a Password Manager in Python We have a task to create a Password Manager in Python. In this article, we will see how to create a Password Manager in Python. What is a Password Manager?A Password Manager in Python is a tool in which we can add the username and password. Additionally, it allows us to retrieve the username and pas 7 min read Like