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.

    [[email protected] wifi-password]$ wifi-password -i
    ERROR: You need to run '/usr/bin/wifi-password' as root
    
    [[email protected] wifi-password]$ wifi-password --image
    ERROR: You need to run '/usr/bin/wifi-password' as root
    
    [[email protected] wifi-password]$ sudo wifi-password -i
    <shows password, erased for privacy reasons>
    
    [[email protected] 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
nettrace is a powerful tool to trace network packet and diagnose network problem inside kernel.

nettrace nettrace is is a powerful tool to trace network packet and diagnose network problem inside kernel on TencentOS. It make use of eBPF and BCC.

84 Jan 01, 2023
Tiny Interactive File Transfer Application

TIFTA: Tiny Interactive File Transfer Application This repository holds all the source code, tests and documentation of the TIFTA software. The main g

Jorge Martínez 2 Dec 08, 2021
Python script to stop qBittorrent from torrenting without VPN for users with static IP.

Python script to stop qBittorrent from torrenting without VPN for users with static IP.

voidoak_ 1 Oct 25, 2021
snappi-trex is a snappi plugin that allows executing scripts written using snappi with Cisco's TRex Traffic Generator

snappi-trex snappi-trex is a snappi plugin that allows executing scripts written using snappi with Cisco's TRex Traffic Generator Design snappi-trex c

Open Traffic Generator 14 Sep 07, 2022
sshuttle: where transparent proxy meets VPN meets ssh

Transparent proxy server that works as a poor man's VPN. Forwards over ssh. Doesn't require admin. Works with Linux and MacOS. Supports DNS tunneling.

9.4k Jan 09, 2023
Connects to databases or sftp server based on configured environmental variables.

Myconnections Connects to Oracle databases or sftp servers depending on configured environmental variables. VERY IMPORTANT: VPN must exist. Installati

0 Jan 02, 2022
A simple tcpdump sidecar injector to demonstrate Kubernetes's Mutating Webhook

k8s-tcpdump-webhook A simple tcpdump sidecar injector to demonstrate Kubernetes's Mutating Webhook Build and Deploy Build docker image; docker build -

Bilal Ünal 2 Sep 01, 2022
A Python package for handling free proxies from sslproxies.org

SSLProxies Get free working proxy from https://www.sslproxies.org/ and use it in your script This is a port/rewrite of free-proxy with additional feat

Nate Harris 2 Mar 17, 2022
Linkedin Connection Automation

Why spend an hour+ a week, connecting with the correct people on LinkedIn when you can go for lunch and let your computer do the hard work?

1 Nov 29, 2021
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
Automated network configuration backups using Github actions and git-scraping

Network Config Scraper This repository demonstrates the use of Github Actions and git-scraping to build an automated backup solution for network confi

WWT 19 Dec 14, 2022
A simple, configurable application and set of services to monitor multiple raspberry pi's on a network.

rpi-info-monitor A simple, configurable application and set of services to monitor multiple raspberry pi's on a network. It can be used in a terminal

Kevin Kirchhoff 11 May 22, 2022
Vent domain information retrieval tool, which is capable of retrieving customer information

Vent domain information retrieval tool, which is capable of retrieving customer information. This tool has been created for the purpose of complete education, Iam not responsible for any illegal acti

Md. Ridwanul Islam Muntakim 25 Dec 09, 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
TicTacToe using Socket Server

TicTacToe using Socket Server This is a project for the class : 18CSC302J - Computer Networks by Dr. S.Babu Contributors Suvodeep Sinha RA191100301010

Suvodeep Sinha 12 Nov 30, 2022
Ipscanner - A simple threaded IP-Scanner written in python3 that can monitor local IP's in your network

IPScanner 🔬 A simple threaded IP-Scanner written in python3 that can monitor lo

4 Dec 12, 2022
HTTP proxy pool server primarily meant for evading IP whitelists

proxy-forwarder HTTP proxy pool server primarily meant for evading IP whitelists. Setup Create a file named proxies.txt and fill it with your HTTP pro

h0nda 2 Feb 19, 2022
Network monitoring tool

netmeter If you are looking for a tool to monitor your network interfaces, here you are. See netmeter-exporter to export Prometheus metrics. Installat

Saeid Bostandoust 97 Dec 03, 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
Minimal, self-hosted, 0-config alternative to ngrok. Caddy+OpenSSH+50 lines of Python.

If you have a webserver running on one computer (say your development laptop), and you want to expose it securely (ie HTTPS) via a public URL, SirTunnel allows you to easily do that.

Anders Pitman 423 Jan 02, 2023