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
mitm6 is a pentesting tool that exploits the default configuration of Windows to take over the default DNS server.

mitm6 is a pentesting tool that exploits the default configuration of Windows to take over the default DNS server.

Fox-IT 1.3k Jan 05, 2023
Multi-vendor library to simplify CLI connections to network devices

Netmiko Multi-vendor library to simplify CLI connections to network devices Why Netmiko? Network automation to screen-scraping devices is primarily co

Kirk Byers 3k Jan 01, 2023
Herramienta para transferir eventos de Shadowserver REST API hacia Azure Blob Storage.

Herramienta para transferir eventos de Shadowserver REST API hacia Azure Blob Storage.

CSIRT-RD 1 Feb 04, 2022
AdaFruit Funhouse publishing Temperature, Humidity and Pressure to MQTT / Apache Pulsar

pulsar-adafruit-funhouse AdaFruit Funhouse publishing Temperature, Humidity and Pressure to MQTT / Apache Pulsar Device Get your own from adafruit Ada

Timothy Spann 1 Dec 30, 2021
Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.

🚀 IPpy Parallel testing of IP addresses and domains in python. Reads IP addresses and domains from a CSV file and gives two lists of accessible and i

Shivam Mathur 54 May 21, 2022
ARTEMIS: Real-Time Detection and Automatic Mitigation for BGP Prefix Hijacking.

ARTEMIS: Real-Time Detection and Automatic Mitigation for BGP Prefix Hijacking. This is the main ARTEMIS repository that composes artemis-frontend, artemis-backend, artemis-monitor and other needed c

INSPIRE Group @FORTH-ICS 273 Jan 01, 2023
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)

gRPC - An RPC library and framework gRPC is a modern, open source, high-performance remote procedure call (RPC) framework that can run anywhere. gRPC

grpc 36.6k Dec 30, 2022
Easy to use gRPC-web client in python

pyease-grpc Easy to use gRPC-web client in python Tutorial This package provides a requests like interface to make calls to gRPC-Web servers.

Sudipto Chandra 4 Dec 03, 2022
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.

asyncio-socks-server A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio. Features Supports both TCP a

Amaindex 164 Dec 30, 2022
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 database-based CDN node supporting PostgreSQL and MongoDB backends.

A simple to use database-based deployable CDN node for hobbyist developers who wish to have their own CDN!

Vish M 10 Nov 19, 2022
Way find out if DNS is down or your instance

DNS-PING Way to find out if DNS is down or your instance Problem: At times it happens that DNS provider services of a website URL is down and so to re

Giten Mitra 4 Nov 18, 2022
Ov3 - Easy common OpenVPN3 operations

ov3 Easy common OpenVPN3 operations Install ov3 requires Python3 and OpenVPN3 to

Yunus Bora Erciyas 6 Apr 25, 2022
Network Engineer's Unified Realtime Automation Library

NEURAL is the premiere CLI jockey replacement full stack web/app/database network automation application, providing a "no-code" web app for network engineers developed by a network engineer!

Brett M Spunt 3 Aug 15, 2022
track IP Address

ipX Table of Contents ipX Welcome Features Uses Author 📝 License Welcome find the location of an IP address. Specifically, you can get the following

Ali Shahid 15 Sep 26, 2022
A live streaming chatroom involving multiple modalities, such as voice, gesture, and facial expression

HiLive A live streaming chatroom involving multiple modalities, such as voice, gesture, and facial expression. Introduction We focus on demonstrating

Ryan Yen 2 Dec 02, 2021
DataShare - Simple library for data sharing between scripts and public functions calling

DataShare - Simple library for data sharing between scripts and public functions calling. Installation. Install code, Delete LICENSE, README, readme.t

Ivan Perzhinsky. 1 Dec 17, 2021
Python 3.3+'s ipaddress for older Python versions

ipaddress Python 3.3+'s ipaddress for Python 2.6, 2.7, 3.2. This repository tracks the latest version from cpython, e.g. ipaddress from cpython 3.8 as

Philipp Hagemeister 103 Nov 11, 2022
IoT owl is light face detection and recognition system made for small IoT devices like raspberry pi.

IoT Owl IoT owl is light face detection and recognition system made for small IoT devices like raspberry pi. Versions Heavy with mask detection withou

Ret2Me 6 Jun 06, 2022
This tools just for education only - Layer-7 or HTTP FLOODER

Layer-7-Flooder This tools just for education only - Layer-7 or HTTP FLOODER Require Col1 Before You Run this tools How To Use Download This Source Ex

NumeX 7 Oct 30, 2022