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
Build surface water network for MODFLOW's SFR Package

Surface water network Creates surface water network, which can be used to create MODFLOW's SFR. Python packages Python 3.6+ is required. Required geop

Mike Taves 20 Nov 22, 2022
A Python tool used to automate the execution of the following tools : Nmap , Nikto and Dirsearch but also to automate the report generation during a Web Penetration Testing

📡 WebMap A Python tool used to automate the execution of the following tools : Nmap , Nikto and Dirsearch but also to automate the report generation

Iliass Alami Qammouri 274 Jan 01, 2023
euserv auto-renew script - A Python script which can help you renew your free EUserv IPv6 VPS.

eu_ex eu_ex means EUserv_extend. A Python script which can help you renew your free EUserv IPv6 VPS. This Script can check the VPS amount in your acco

A beam of light 92 Jan 25, 2022
Simple python script for automated network scans with random name generator(useful for CTF boxes).

📄 Automated NMAP script Description Simple python script for automated network scans with random name generator(useful for CTF boxes). Requirements 1

Dhmos Funk 2 Oct 29, 2021
Tool written on Python that locate all up host on your subnet

HOSTSCAN Easy to use command line network host scanner. From noob to noobs. Dependencies Nmap 7.92 or superior Python 3.9 or superior All requirements

NexCreep 4 Feb 27, 2022
Web service load balancing simulation experiment.

Web service load balancing simulation experiment.

NicestZK 1 Nov 12, 2021
🥑 A Python ARP and DNS Spoofer CLI and INTERFACE 🥓

NEXTGEN SPOOFER 🥑 A Python ARP and DNS Spoofer CLI and INTERFACE 🥓 CLI - advanced pentesters INTERFACE - beginners SetUp Make sure you installed P

9 Dec 25, 2022
A simple, 2-person chat program that runs on a single computer. No Internet, just you

localChat A simple, 2-person chat program that runs on a single computer. No Internet, just you. Simple and Local This was created with ease of use in

Owls 2 Aug 19, 2022
Python port of proxy-www (https://github.com/justjavac/proxy-www)

proxy-www.py Python port of proxy-www (https://github.com/justjavac/proxy-www). Implemented additional functionalities! How to install pip install pro

Minjun Kim (Lapis0875) 20 Dec 08, 2021
Automatically block traffic on Cloudflare's side based on Nginx Log parsing.

AutoRL This is a PoC of automatically block traffic on Cloudflare's side based on Nginx Log parsing. It will evaluate Nginx access.log and find potent

Nova Kwok 62 Dec 28, 2022
A simple port scanner for Web/ip scanning Port 0/500 editable inside the .py file

Simple-Port-Scanner a simple port scanner for Web/ip scanning Port 0/500 editable inside the .py file Open Cmd/Terminal Cmd Downloads Run Command: pip

YABOI 1 Nov 22, 2021
A repo with study material, exercises, examples, etc for Devnet SPAUTO

MPLS in the SDN Era -- DevNet SPAUTO All of the study notes have now been moved to use auto-generated documentation to build a static site with Githu

Hugo Tinoco 67 Nov 16, 2022
A python tool auto change proxy or ip after dealy time set by user

Auto proxy Ghost This tool auto change proxy or ip after dealy time set by user how to run 1. Install required file ./requirements.sh 2.Enter command

Harsh Tagra 0 Feb 23, 2022
TunnelProxy 是一个本地隧道代理,可以从fofa爬取免费的socks代理,然后构建代理池,如果一个代理失效,会自动切换

TunnelProxy 是一个本地隧道代理,可以从fofa爬取免费的socks代理,然后构建代理池,如果一个代理失效,会自动切换。 应用场景 渗透测试需要访问某些国内网站(比如edu的),想要隐藏自己,但是国外代理不能访问,也没有稳定的可用代理的时候。 之后,可能我会增加国外代理,实现白嫖科学上网。

urdr-gungnir 45 Nov 17, 2022
Send files to your friends over network! (100mb max)

PyServed v2.0.1 Made by Shaurya Pratap Singh Installation Using pip(for stable releases.) - $ pip install pyserved Using Git (for latest updates) -

Sblip.dev 4 Mar 22, 2022
A Python Tor template on Gitpod

A Python Tor template on Gitpod This is template configured for ephemeral development environments on Gitpod. prebuild Get Started With Your Own Proje

Ivan Yastrebov 1 Dec 17, 2021
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 03, 2022
IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

invasion 3 Feb 18, 2022
With Py-Autocrack you can crack WPA2 networks in no time.

With Py-Autocrack you can crack WPA2 networks in no time. All based on Aircrack-ng and Crunch.

Paul - FloatDesign 1 Dec 10, 2021
A protocol or procedure that connects an ever-changing IP address to a fixed physical machine address

p0znMITM ARP Poisoning Tool What is ARP? Address Resolution Protocol (ARP) is a protocol or procedure that connects an ever-changing IP address to a f

Furkan OZKAN 9 Sep 18, 2022