Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect

Overview

wifi-password

Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect.
Works on macOS and Linux and Windows

Installation

Install using pip

$ python3 -m pip install --user wifi-password

Install using git

$ git clone https://github.com/sdushantha/wifi-password
$ cd wifi-password
$ python3 setup.py install

Install using the AUR

$ sudo pamac build wifi-password

Usage

$ wifi-password
usage: wifi_password [options]

optional arguments:
  -h, --help            show this help message and exit
  --qrcode, -q          Generate a QR code
  --image, -i           Create the QR code as image instead of showing it on the terminal (must be useed along with --qrcode)
  --ssid SSID, -s SSID  Specify a SSID that you have previously connected to
  --version             Show version number

Reference

  • This project is an improvement of wifi-password created by @rauchg, where I have added support for multiple platforms and have added the feature for generating QR codes.
  • wifiPassword created by @ankitjain28may was frequently used as reference throughout the development of this project.
Comments
  • fix line 71 IndexError at Windows

    fix line 71 IndexError at Windows

    I used this app but I get this bug

    Traceback (most recent call last):
      File "C:\Users\user\AppData\Roaming\Python\Python39\Scripts\wifi-password-script.py", line 33, in <module>
        sys.exit(load_entry_point('wifi-password==1.0.7', 'console_scripts', 'wifi-password')())
      File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\wifi_password\wifi_password.py", line 116, in main
        password = get_password(args.ssid)
      File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\wifi_password\wifi_password.py", line 76, in get_password
        password = re.findall(r"Key Content\s+:\s(.*)", password)[0]
    IndexError: list index out of range
    

    That's why I added this.

    def get_password(ssid):
        if ssid == "":
            print_error("SSID is not defined")
    
        if sys.platform == "darwin":
            password = run_command(f"security find-generic-password -l \"{ssid}\" -D 'AirPort network password' -w")
            password = password.replace("\n", "")
    
        elif sys.platform == "linux":
            # Check if the user is running with super user privilages
            if os.geteuid() != 0:
                password = run_command(f"sudo nmcli -s -g 802-11-wireless-security.psk connection show '{ssid}'")
            else:
                password = run_command(f"nmcli -s -g 802-11-wireless-security.psk connection show '{ssid}'")
    
            password = password.replace("\n", "")
    
        elif sys.platform == "win32":
            password = run_command(f"netsh wlan show profile name=\"{ssid}\" key=clear | findstr Key").replace("\r", "")
            try:
                password = re.findall(r"Key Content\s+:\s(.*)", password)[0]
            except IndexError:
                password = ""
        if password == "":
            print_error("Could not find password")
    
        return password
    
    opened by sunrabbit123 18
  • zsh: command not found: wifi_password

    zsh: command not found: wifi_password

    It isn't work at wifi_password

    #  rikasai @ huacainoMBP in ~ [22:27:59]
    $ wifi_password
    zsh: command not found: wifi_password
    

    But work at python -m wifi_password

    # rikasai @ huacainoMBP in ~ [22:27:30]
    $ python -m wifi_password
    *********
    

    image

    opened by lihuacai168 11
  • Fix potential bug with os not in english

    Fix potential bug with os not in english

    Hi, After some tests with your tool, I discovered a little problem for some setups.

    To detect SSID, it's using nmcli -t -f active,ssid dev wifi | egrep '^yes' | cut -d\: -f2. The problem is that nmcli -t -f active,ssid dev wifi output depends of language. In english it will return SSID yes/no but for example in french it return SSID oui/non.

    To fix that I'm forcing the language using LANG env variable.

    opened by celianvdb 11
  • IndexError: list index out of range

    IndexError: list index out of range

    Hi,

    I do not know why no matter what SSID I put in as input, it keeps saying IndexError for some reason. image

    my OS is Windows 10 my python version is 3.9.0 my wifi-password version is 1.0.9

    opened by RuoyuDeng 10
  • added --path parameter to allow users to specify a directory to save the image to

    added --path parameter to allow users to specify a directory to save the image to

    when I ran wifi-password --qrcode --image the image was saved to my home directory so I added a CLI parameter so the user can control which directory the image will be saved to

    enhancement 
    opened by hallur 10
  • List networks

    List networks

    This PR includes a set of changes to list saved networks (see item #28 ) on Windows, it also moves most functions into a utils.py file so they can be reused more efficiently.

    Added comments to each function to understand what they do.

    Please note that this changes are only made for Windows platform, it is pending to implement the changes for Linux and MacOS.

    opened by pelonchasva 7
  • Why can't I output qrcode?

    Why can't I output qrcode?

    image

    Why not I get qrcode image?

    I get only Unknown String

    What is ploblem?

    my OS is Windows 10 my python version is 3.9.0 my wifi-password version is 1.0.7

    bug help wanted 
    opened by sunrabbit123 6
  • Cannot read SSID password if there's a space between the SSID's name

    Cannot read SSID password if there's a space between the SSID's name

    If I run sudo wifi-password I get

    ERROR: Could not find password

    This is because my AP's name has a space inside (e.g: John DoeWifi)

    If I create a new AP and name it JohnDoeWifi, I successfully get the result

    password123

    The program doesn't take into consideration that there may be an SSID with space inside the name. Only SSIDs with no space are read.

    bug 
    opened by engineer22 5
  • ModuleNotFoundError

    ModuleNotFoundError

    I just installed the package with python -m pip install --user wifi-password. When I run wifi-password -q -i the following exception is thrown:

    Traceback (most recent call last):
      File "C:\Users\Bob\AppData\Roaming\Python\Python38\site-packages\qrcode\image\pil.py", line 6, in <module>
        from PIL import Image, ImageDraw
    ModuleNotFoundError: No module named 'PIL'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\Bob\AppData\Roaming\Python\Python38\Scripts\wifi-password-script.py", line 11, in <module>
        load_entry_point('wifi-password==1.0.3', 'console_scripts', 'wifi-password')()
      File "C:\Users\Bob\AppData\Roaming\Python\Python38\site-packages\wifi_password\wifi_password.py", line 108, in main
        generate_qr_code(args.ssid, password, image=args.image)
      File "C:\Users\Bob\AppData\Roaming\Python\Python38\site-packages\wifi_password\wifi_password.py", line 85, in generate_qr_code
        img = qr.make_image()
      File "C:\Users\Bob\AppData\Roaming\Python\Python38\site-packages\qrcode\main.py", line 289, in make_image
        from qrcode.image.pil import PilImage
      File "C:\Users\Bob\AppData\Roaming\Python\Python38\site-packages\qrcode\image\pil.py", line 8, in <module>
        import Image
    ModuleNotFoundError: No module named 'Image'
    
    bug 
    opened by hallur 4
  • Linux fixes

    Linux fixes

    This PR should bring it back to being able to work with any linux install using NetworkManager, with the added bonus of not relying on wireless-tools. This should resolve #17 and #11

    However this program will still be unable to function on a linux install that does not use NetworkManager, such as wicd or connman, or on the Raspberry Pi. The most likely scenario for supporting those is writing special cases for each, though I did not go through the effort in this commit.

    Maybe its also worth merging into its own branch to get some more testing instead of merging directly to master?

    opened by littlediobolic 3
  • parameter --image doesn't work

    parameter --image doesn't work

    version: 1.0.2

    IS: calling wifi-password with -i or --image shows the password in the terminal.

    SHOULD: show the qr code as an image

    SUGGESTION: let the user specify a name and/or a path including the file extension(.jpeg, .png, etc.). If no extension is give or the extension is invalid, fall back to a default extension.

    [janst@jan-pc wifi-password]$ wifi-password -i
    ERROR: You need to run '/usr/bin/wifi-password' as root
    
    [janst@jan-pc wifi-password]$ wifi-password --image
    ERROR: You need to run '/usr/bin/wifi-password' as root
    
    [janst@jan-pc wifi-password]$ sudo wifi-password -i
    <shows password, erased for privacy reasons>
    
    [janst@jan-pc wifi-password]$ sudo wifi-password --image
    <shows password, erased for privacy reasons>```
    question 
    opened by janhsteiner 3
  • Unable to find the password

    Unable to find the password

    Hi!

    I appreciate the work you put in this, but sadly it doesn't work for me.

    I'm using Kubuntu 22.04 and the WiFi is a hidden network. If I run the command nmcli -s -g 802-11-wireless-security.psk connection show '{ssid}' manually, it outputs the password though. Do I have to set up something first?

    Thanks in advance! Greetings, Noah Streller

    image

    opened by noahstreller 1
  • Win10系统中文版执行命令返回的是中文字符串,不能用正则匹配key

    Win10系统中文版执行命令返回的是中文字符串,不能用正则匹配key

    image 由于得到的字符串是中文的,所以需要换一种方式去解析

        elif sys.platform == "win32":
            password = run_command(f"netsh wlan show profile name=\"{ssid}\" key=clear")
            password_line = password.split("\r\n")[32]
            password = password_line[(password_line.find(":") if password_line.find(":") != -1 else password_line.find(":"))+ 1:].rstrip().lstrip()
    

    另外由于PowerShell输出流编码为GBK,所以不同平台的解码也需要考虑 image

    opened by Fcscanf 0
  • Error when saving QR Code

    Error when saving QR Code

    Windows 10

    Traceback (most recent call last):
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\Scripts\wifi-password-script.py", line 33, in <module>
        sys.exit(load_entry_point('wifi-password==1.1.1', 'console_scripts', 'wifi-password')())
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\wifi_password-1.1.1-py3.9.egg\wifi_password\wifi_password.py", line 165, in main
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\wifi_password-1.1.1-py3.9.egg\wifi_password\wifi_password.py", line 126, in generate_qr_code
      File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\qrcode\image\pil.py", line 50, in save
        self._img.save(stream, format=format, **kwargs)
      File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\PIL\Image.py", line 2161, in save
        fp = builtins.open(filename, "w+b")
    OSError: [Errno 22] Invalid argument: 'Name\r.png'h
    
    
    opened by donenoyes 1
  • 中文版win10遇到的问题修改

    中文版win10遇到的问题修改

    run_command方法中的返回语句字符集需要修改为“gbk” return output.decode("gbk").rstrip("\r\n")

    get_password方法中,判断为"win32“的分支需要修改 elif sys.platform == "win32": password = run_command(f"netsh wlan show profile name="{ssid}" key=clear") password = re.findall(r"关键内容\s+:\s(.*)", password)[0]

    opened by weibasai 4
  • This is awesome! I wonder if we can make it a brew formula!

    This is awesome! I wonder if we can make it a brew formula!

    Found some details here: https://docs.brew.sh/Homebrew-and-Python

    Let me know if you like the idea! I can have a look to see what it takes and raise a PR.

    enhancement 
    opened by mickeypash 6
Releases(1.1.1)
  • 1.1.1(Feb 14, 2021)

    • 72b299def17fd0cf3a466d071c2c6193ff6caf26 Fixed a potential bug where the OS is not set to English
    • 8603a53acd8216b8f5a36564967b73d1ca89bc0f Made the CLI usage more intuitive
    Source code(tar.gz)
    Source code(zip)
  • 1.0.9(Feb 8, 2021)

    • a8185979bd749aad3e8ccc5db58097124be73449 Removed get_ssid() from being the default for --ssid. By setting get_ssid() as the default value later in the code prevents the dependency checking for Network Manager on Linux whenever a user runs wifi-password --help to view the usage.
    • 9e693ca8d1ce3f183da08f5a2eaf69f7985a75a6 Cleaned up the formatting of the argparse arguments for better legibility
    Source code(tar.gz)
    Source code(zip)
  • 1.0.8(Feb 6, 2021)

    Changelog

    • Error messages are now sent to sys.stderr instead of sys.stdout. [165b7122b7736184d9e1e3f3161935e3f86d8cd4]
    • Previously after running a command, all newlines were removed but the intent was to remove the trailing newline character. Therefore .rstrip() is now being used instead to remove the trailing newlines (\n)and carriage returns (\r). [1cc6ba2deac3855de32108fca0aa4db99371dc56]
    • Added image and Pillow as dependencies in order to create the image of the QR code. [54d0b02cbf0aac70076164a07e713d65c6299241, 8fb55fc91b015a7b50140cc58a18a3c245ee7b12]
    Source code(tar.gz)
    Source code(zip)
Owner
Siddharth Dushantha
Creator of Sherlock from the @sherlock-project
Siddharth Dushantha
A socket script to obtain chinese phones-sequence for any english word

Foreign Pronunciation Generator (English-Chinese) We provide a simple socket script for acquiring Chinese pronunciation of English words (phones in ai

Ephemeroptera 5 Jul 25, 2022
This application aims to read all wifi passwords and visualizes the complexity in graph formation by taking into account several criteria and help you generate new random passwords.

This application aims to read all wifi passwords and visualizes the complexity in graph formation by taking into account several criteria and help you generate new random passwords.

Njomza Rexhepi 0 May 29, 2022
A lightweight python script that can monitor the T-Mobile Home Internet Nokia 5G Gateway for band and connectivity and reboot as needed.

tmo-monitor A lightweight Python 3 script that can monitor the T-Mobile Home Internet Nokia 5G Gateway for band and connectivity and reboot as needed.

null 61 Dec 17, 2022
A simple python application for generating a WiFi QR code for ease of connection

A simple python application for generating a WiFi QR code Initialize the class by providing QR code values WiFi_QR_Code(self, error_correction: int =

Ivan 2 Aug 1, 2022
A TCP Chatroom built with python and TCP/IP sockets, consisting of a server and multiple clients which can connect with the server and chat with each other.

A TCP Chatroom built with python and TCP/IP sockets, consisting of a server and multiple clients which can connect with the server and chat with each other. It also provides an Admin role with features including kicking and baning of users.

null 3 May 22, 2022
A simple and lightweight server that allows clients to connect and launch a shell remotely through a browser.

carrotsh A simple and lightweight server that allows clients to connect and launch a shell remotely through a browser. Uses xterm.js for the frontend

V9 31 Dec 27, 2022
Geowifi 📡 💘 🌎 Search WiFi geolocation data by BSSID and SSID on different public databases.

Geowifi ?? ?? ?? Search WiFi geolocation data by BSSID and SSID on different public databases.

GOΠZO 441 Dec 23, 2022
Linux SBC featuring two wifi radios, masquerading as a USB charger.

The WiFiWart is an open source WiFi penetration device masquerading as a regular wall charger. It features a 1.2Ghz Cortex A7 MPU with two WiFi chips onboard.

Walker 151 Dec 26, 2022
Wifi-Jamming is a simple, yet highly effective method of causing a DoS on a wireless implemented using python pyqt5.

pyqt5-linux-wifi-jamming-tool Linux-Wifi-Jamming is a simple GUI tool, yet highly effective method of causing a DoS on a wireless implemented using py

lafesa 8 Dec 5, 2022
Python module to interface with Tuya WiFi smart devices

TinyTuya Python module to interface with Tuya WiFi smart devices Description This python module controls and monitors Tuya compatible WiFi Smart Devic

Jason Cox 365 Dec 26, 2022
The module that allows the collection of data sampling, which is transmitted with WebSocket via WIFI or serial port for CSV file.

The module that allows the collection of data sampling, which is transmitted with WebSocket via WIFI or serial port for CSV file.

Nelson Wenner 2 Apr 1, 2022
Wifi-jammer - Continuously perform deauthentication attacks on all detectable stations

wifi-jammer Continuously perform deauthentication attacks on all detectable stat

Leonardo de Araujo 14 Nov 3, 2022
Python Program to connect to different VPN servers autoatically using Windscribe VPN.

AutomateVPN What is VPN ? VPN stands for Virtual Private Network , it is a technology that creates a safe and encrypted connectionover a less secure n

Vivek 1 Oct 27, 2021
A fire and forget command-line tool to allow for easy transitions of VPN connections between a pool of AWS machines.

VPN Swapper A fire and forget command-line tool to allow for easy transitions of VPN connections between a pool of AWS machines. Dependencies poetry -

Workday 5 Jul 7, 2022
These scripts send notifications to a Webex space when a new IP is banned by Expressway, and allow to request more info or change the ban status

Spam Call and Toll Fraud Mitigation Cisco Expressway release X14 is able to mitigate spam calls and toll fraud attempts by jailing the spam IP address

Luca Pellegrini 6 Aug 5, 2022
Tool for quickly gathering information from Shodan.io about the number of IPs which satisfy large number of different queries

TriOp Tool for quickly gathering information from Shodan.io about the number of IPs which satisfy large number of different queries For furt

Jan Kopriva 27 Nov 3, 2022
📨 Share files easily over your local network from the terminal! 📨

Fileshare ?? Share files easily over your local network from the terminal! ?? Installation #

Dopevog 11 Sep 10, 2021
Use Fast Redirect to easily redirect your domains.

Fast Redirect Use Fast Redirect to easily redirect your domains. Fast Redirects expects a JSON 'database'. This JSON 'database' contains the domains t

Cyberfusion 1 Dec 20, 2021
This is simple script that changes the config register of a cisco router over serial so that you can reset the password

Cisco-router-config-bypass-tool- This is simple script that changes the config register of a cisco router over serial so that you can bypass the confi

James 1 Jan 2, 2022