From 3f90a01a5e7c15525330fe973eefcfa917dcef3e Mon Sep 17 00:00:00 2001 From: sagar627 <55939746+sagar627@users.noreply.github.com> Date: Wed, 14 Oct 2020 16:50:21 +0530 Subject: [PATCH] Python script to view wifi password. (#163) * Added wifi.py * Delete main.py * Create wifi_password.py * Create requirements.txt * Create README.md * Rename wifi_password.py to main.py * Update README.md * Update README.md Co-authored-by: Ayush Bhardwaj --- README.md | 1 + Wifi-Password/README.md | 3 +++ Wifi-Password/main.py | 30 ++++++++++++++++++++++++++++++ Wifi-Password/requirements.txt | 1 + 4 files changed, 35 insertions(+) create mode 100644 Wifi-Password/README.md create mode 100644 Wifi-Password/main.py create mode 100644 Wifi-Password/requirements.txt diff --git a/README.md b/README.md index ee2105b..3015b8d 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ So far, the following projects have been integrated to this repo: |[YTS Torrents](yts_torrents)|[Mayank Nader](https://github.com/makkoncept)| |[COVID visualiser (real-time) ](covdi_visualiser)|[Tushar Gupta](https://github.com/tushar5526)| |[Random_Email_Generator](Random_Email_Generator)|[Shubham Garg](https://github.com/shub-garg)| +|[WiFi Password Viewer](Wifi-Password)|[Sagar Patel](https://github.com/sagar627)| |[Tambola_Ticket_Generator](Tambola_Ticket_Generator)|[Amandeep_Singh](https://github.com/Synster)| | [Py_Cleaner](Py_Cleaner) | [Abhishek Dobliyal](https://github.com/Abhishek-Dobliyal) |[Send messages to sqs in parallel](send_sqs_messages_in_parallel)|[Jinam Shah](https://github.com/jinamshah)| diff --git a/Wifi-Password/README.md b/Wifi-Password/README.md new file mode 100644 index 0000000..b45dd32 --- /dev/null +++ b/Wifi-Password/README.md @@ -0,0 +1,3 @@ +**A Simple python Script to view saved password on your system.** + +This script works on both Windows and Linux. diff --git a/Wifi-Password/main.py b/Wifi-Password/main.py new file mode 100644 index 0000000..f93d4a0 --- /dev/null +++ b/Wifi-Password/main.py @@ -0,0 +1,30 @@ +import subprocess +systemInfo='' +try: + systemInfo = subprocess.check_output(['uname']).decode('utf-8', errors="backslashreplace").split('\n') + systemInfo = systemInfo[0] +except : + pass +if systemInfo == "Linux": + wifiData = subprocess.check_output(['ls', '/etc/NetworkManager/system-connections']).decode('utf-8', errors="backslashreplace").split('\n') + print ("Wifiname Password") + print ("----------------------------------------") + + for wifiname in wifiData: + if wifiname != '': + wifiPass = subprocess.check_output(['sudo','cat', f"/etc/NetworkManager/system-connections/{wifiname}"]).decode('utf-8', errors="backslashreplace").split('\n') + password=wifiPass[15].strip("psk="); + print ("{:<30} {:<}".format(wifiname, password)) +else: + wifi = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="backslashreplace").split('\n') + profiles = [i.split(":")[1][1:-1] for i in wifi if "All User Profile" in i] + for i in profiles: + try: + results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8', errors="backslashreplace").split('\n') + results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b] + try: + print ("{:<30}| {:<}".format(i, results[0])) + except : + print ("{:<30}| {:<}".format(i, "")) + except : + print ("{:<30}| {:<}".format(i, "ENCODING ERROR")) diff --git a/Wifi-Password/requirements.txt b/Wifi-Password/requirements.txt new file mode 100644 index 0000000..30cd8df --- /dev/null +++ b/Wifi-Password/requirements.txt @@ -0,0 +1 @@ +subprocess