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
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.

61 Dec 17, 2022
Simple threaded Python Rickroll server. Listens on port 23 by default.

Terminal Rickroll Simple threaded Python Rickroll server. Listens on port 23 by default. Rickroll video made using Video-To-Ascii and the standard ric

AG 10 Sep 13, 2022
A simple DHCP server and client simulation with python

About The Project This is a simple DHCP server and client simulation. I implemented it for computer network course spring 2021 The client can request

shakiba 3 Feb 08, 2022
Compare the contents of your hosted and proxy repositories for coordinate collisions

Nexus Repository Manager dependency/namespace confusion checker This repository contains a script to check if you have artifacts containing the same n

Sonatype Community 59 Mar 31, 2022
GhostVPN - Simple and lightweight TUI application for CyberGhostVPN

GhostVPN Simple and lightweight TUI application for CyberGhostVPN. Screenshot Us

Mehmet Ali KERİMOĞLU 5 Jul 27, 2022
This repository contain sample code of gRPC Communication between Python and GoLang

This repository contain sample code of gRPC Communication between Python and GoLang, the Server is running on GoLang while Python is running the client

Abdullahi Muhammad 2 Nov 29, 2021
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
Dnspython is a DNS toolkit for Python.

dnspython is a DNS toolkit for Python. It supports almost all record types. It can be used for queries, zone transfers, and dynamic updates. It supports TSIG authenticated messages and EDNS0.

Bob Halley 2.1k Jan 06, 2023
ServerStatus with node management and monitor

ServerStatus with node management and monitor

lidalao 162 Jan 01, 2023
MQTT Explorer - MQTT Subscriber client to explore topic hierarchies

mqtt-explorer MQTT Explorer - MQTT Subscriber client to explore topic hierarchies Overview The MQTT Explorer subscriber client is designed to explore

Gambit Communications, Inc. 4 Jun 19, 2022
It's a little project for change MAC address, for ethical hacking purposes

MACChangerPy It's a small project for MAC address change, for ethical hacking purposes, don't use it for bad purposes, any infringement will be your r

Erick Adriano Nunes da Silva 1 Mar 11, 2022
A simple multi-threaded time server and client in python.

time-server-client A simple multi-threaded time server and client in Python. This uses the latest match/case command found in Python 3.10 so requires

Zeeshan Mulk 1 Jan 29, 2022
FramIp - it a framework for work at IP and domain

FramIp FramIp - it a framework for work with IP and domain Installation (termux) $ pkg install git && pkg install python && git clone https://github.c

1 Jan 28, 2022
High capacity, high availability, well connected, fast lightning node.

LND ⚡ Routing High capacity, high availability, well connected, fast lightning node. We aim to become a top liquidity provider for the lightning netwo

18 Dec 16, 2022
Medusa is a cross-platform agent compatible with both Python 3.8 and Python 2.7.

Medusa Medusa is a cross-platform agent compatible with both Python 3.8 and Python 2.7. Installation To install Medusa, you'll need Mythic installed o

Mythic Agents 123 Nov 09, 2022
Tool to get the top 100 of the fastest nodes in the Tor network. Based on Kirzahk tool.

Tor Network Top 100 IPs Tool to get the top 100 of the fastest nodes in the Tor network. Based on Kirzahk tool. Just execute top100ipstor.py to get th

Juan Manuel 0 Jan 23, 2022
Converts Cisco formatted MAC Addresses to PC formatted MAC Addresses

Cisco-MAC-to-PC-MAC Converts a file with a list of Cisco formatted MAC Addresses to PC formatted MAC Addresses... Ex: abcd.efgh.ijkl to AB:CD:EF:GH:I

Stew Alexander 0 Jan 04, 2022
Very simple and tiny file sharing service written in python

Simple File sharing tool Sharing client usage (You will need to use python3 for linux) main.py --send -f file/path Optionnal flags : pwd : set a passw

2 Jul 26, 2022
Control your Puffco Peak Pro from your computer!

PuffcoPC Control your Puffco Peak Pro from your computer! Contributions Pull requests are welcome. For major changes, please open an issue first to di

Bryan Muschter 5 Nov 02, 2022
Whoisss is a website information gatharing Tool.

Whoisss Whoisss is a website information gatharing Tool. You can cse it to collect information about website. Usage apt-get update apt-get upgrade pkg

Md. Nur habib 2 Jan 23, 2022