WiFi Password Finder Using Python and Tkinter
**Title: WiFi Password Finder Using Python and Tkinter** **Introduction** WiFi networks have become an integral part of our lives, and it's easy to accumulate a long list of saved passwords on our devices. But what if you forget a password or need to retrieve it for another device? In this article, we'll explore how to create a WiFi password finder using Python and Tkinter. This application will allow users to view and save their saved WiFi passwords with just a few clicks. **Prerequisites** To follow along with this tutorial, you'll need the following: - Python installed on your computer - Basic knowledge of the Python programming language - The Tkinter library (usually comes bundled with Python) **Building the WiFi Password Finder Application** Let's dive into the step-by-step process of creating a WiFi password finder using Python and Tkinter. **Step 1: Importing the Required Modules** To begin, we need to import the necessary modules. Add the following code at the top of your Python file: ```python import subprocess from tkinter import * import tkinter.messagebox as messagebox ``` The `subprocess` module allows us to run shell commands from within Python, and `tkinter` provides the GUI components for our application. **Step 2: Retrieving and Displaying WiFi Passwords** Next, we'll define a function called `show_pass()` that retrieves the saved WiFi profiles and their corresponding passwords. Add the following code: ```python def show_pass(): data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8').split('\n') profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i] passwords = "" for i in profiles: results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8').split('\n') results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b] try: passwords +=("{:<30}| {:<}\n".format(i, results[0])) except IndexError: passwords +=("{:<30}| {:<}\n".format(i, "")) return passwords ``` This function uses the `netsh` command-line utility to retrieve the WiFi profiles and their passwords. It stores the profiles in the `profiles` list and concatenates the profile names and passwords into the `passwords` string. **Step 3: Updating the Text Field** Now, let's define a function called `update_text()` that updates the text field with the retrieved passwords. Add the following code: ```python def update_text(): passw = show_pass() text.delete("1.0", END) text.insert(END, passw) ``` This function calls the `show_pass()` function to retrieve the passwords, clears the text field using the `delete()` method, and inserts the passwords using the `insert()` method. **Step 4: Copying the Password to the Clipboard** To enhance the usability of our application, we can add a right-click context menu to copy the passwords. Implement the following function: ```python def copy_password(): password = text.get("1.0", END) root.clipboard_clear() root.clipboard_append(password) messagebox.showinfo("Password Copied", "Password has been copied to clipboard.") ``` This function retrieves the password from the text field using the `get()` method, clears the clipboard using `clipboard_clear()`, appends the password to the clipboard using `clipboard_append()`, and displays a message
Download full code from github Download
No comments:
Post a Comment