GithubHelp home page GithubHelp logo

sdushantha / wifi-password Goto Github PK

View Code? Open in Web Editor NEW
2.8K 49.0 331.0 15.41 MB

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

License: MIT License

Python 100.00%
wifi commandline qrcode network windows linux python wifi-network macos python3

wifi-password's Introduction

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

  • With pamac
$ sudo pamac build wifi-password
  • With yay
$ yay -S wifi-password


Usage

$ wifi-password --help
usage: wifi_password [options]

optional arguments:
  -h, --help            show this help message and exit
  --show-qr, -show      Show a ASCII QR code onto the terminal/console
  --save-qr [PATH], -save [PATH]
                        Create the QR code and save it as an image
  --ssid SSID, -s SSID  Specify a SSID that you have previously connected to
  --list, -l            Lists all stored network SSID
  --version             Show version number


Problems? Check this list

  • Password not found:

    • Linux:
      • Make sure your network passwords are stored correctly in NetworkManager's storage directory. This is in /etc/NetworkManager/system-connections/. NetworkManager can work by checking if the passwords are stored with another program, but you need to store them in this directory for this program to work.
    • MacOS/Windows:
      • You probably have something broken with your WiFi storage. If not, submit an issue to this repository with information.

  • NetworkManager isn't installed:

    • This program does not work without NetworkManager on Linux. If you want to use this program, install it using your distributions package manager or software center. Not using NetworkManager is a strange decision, but that's an issue for another time.

  • Have another issue?

    • Open a useful issue on this GitHub, and/or suggest a new item in this list if you find a solution.


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.

wifi-password's People

Contributors

0xflotus avatar adrianordp avatar ayhon avatar barak avatar celianvdb avatar gothicvi avatar hallur avatar littlediobolic avatar movatica avatar pelonchasva avatar rinkimekari avatar sdushantha avatar stuartf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wifi-password's Issues

Application throws Index out of range error when SSID is not found in Windows

I was trying to use the program without any arguments and it throws an index out of range exception because the variable ssid is an empty string:

image

After some debugging the issue is found in the method get_ssid when the platform is win32, in my case, I don't have wifi enable so that's why the SSID interface is not being fetched, but apparently the netsh command returns an empty value and when trying to grab the index of 0, it breaks because there is nothing defined.

  • OS: Windows 10
  • Python version: 3.8.1

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

Termux

Excuse me, does this not work with termux on mobile phones?

中文版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]

Could not find password on Ubuntu

Hi awesome work,
however I noticed on Linux (Ubuntu 18 LTS) throws the error : ERROR: Cound not find password. This happens because it looks in /etc/NetworkManager/.../ for files with name {ssid}.nmconnection, whereas in my case those files are just named as {ssid}. Changing {ssid}.nmconnection to just {ssid} solved my issue.

--version should just print the version

The --version option should just print the version number, it shouldn't ask to be run as root or, if run as root, print the WiFi password.

$ wifi-password --version
1.0.3
ERROR: You need to run '/usr/local/bin/wifi-password' as root
$ sudo wifi-password --version
1.0.3
Password-Printed-Here

Installing via pip throws errors

python3 -m pip install --user wifi-password
Requirement already satisfied: wifi-password in /home/ryan/Projects/wifi-password (1.0.6)
Requirement already satisfied: qrcode in /usr/local/lib/python3.8/dist-packages/qrcode-6.1-py3.8.egg (from wifi-password) (6.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from qrcode->wifi-password) (1.14.0)

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

comments

I like it! But can you please comment the code. That way it is easier to read and understand.

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.

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

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

Any way to prevent this MacOS prompt?

I understand that Mac will prompt for admin access every time I run wifi-password for security purposes. Is there any way to give wifi-password admin access always so as to easily access the wifi password?

image

I am somewhat satisfied that it does prompt for username and password before fetching the keychain credential. However, it would be more convenient to simply run it and get the wifi password directly haha

Do I have to enter my wifi password somewhere?

This might be a stupid question but do I have to enter my wifi password I'm scanning the qr code given but it my phone doesn't log in. If I do have to enter a password where? Thank you

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

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'

-i and --image don't work?

Neither -i nor --image returns an image. Instead I see the password in plain text.

I'm on commit 1cc6ba2. I'm using macOS 10.15.7 and the built in terminal.

Uninstall instructions

Can the steps to uninstall be documented on the README, or better yet, automated? Adding an uninstall flag to the setup.py would be optimal.

Looking at the install logs, is this essentially it?

rm /usr/local/bin/wifi-password
rm /usr/local/lib/python3.9/site-packages/wifi_password-*.egg

pip install exits successfully on Git Bash, but wifi-password: not recognized

$ wifi-password
bash: wifi-password: command not found

Not sure why wifi-password command not recognized, I tried reloading Git Bash, but same error.

But installing through Git worked, so I'm currently using that.

output.txt

Attached is a snippet log of my terminal.

I suppose the next issue would be the command returning ERROR: SSID was not found regardless of what flags I pass through.

wifi-password is not recognized

it showed
wifi-password is not recognized as an internal or external command, operable program or batch file.
even after i installed wifi-password using pip on windows10 system.

it doesn't work

have a error
-bash:/usr/local/bin/wifi-password :NO such file or directory

Indicate Pillow as dependency in Install instructions

This tripped me up for a minute, but the quick install instructions don't mention that you need Pillow for generating images. Would be nice if the README indicated that.

I'll open a PR for that. If not desired feel free to close.

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

please update DEMO gif

it shows the commands differently that what they really are

Thanks and awesome project

'netsh' command does not work for `WPA2-Enterprise`

Hi It's a great project!:two_hearts:

i found the Key Content(password ) is not displayed when the types of networks is WPA2-Enterprise


  • e.g
Security settings
-----------------
    Authentication         : WPA2-Enterprise
    Cipher                 : CCMP
    Authentication         : WPA2-Enterprise
    Cipher                 : GCMP
    Security key           : Absent
    802.1X                 : Enabled
    EAP type               : Microsoft: Protected EAP (PEAP)
    802.1X auth credential : User credential
    Credentials configured : No
    Cache user information : Yes

Is there a way to solve this situation?
Thx~~~~

Didn't fetch my password with `sudo nmcli ...`, only with `nmcli ...`

Here's an example:

Your command from here:

m ~ % sudo nmcli -s -g 802-11-wireless-security.psk connection show $SSID | grep -q . && echo 'Password found'
m ~ %

Since I'm not running wifi-password as root, it puts sudo on.

Removing the sudo:

m ~ % nmcli -s -g 802-11-wireless-security.psk connection show $SSID | grep -q . && echo 'Password found' 
Password found

One thing though, is that nmcli has this functionality:

m ~ % nmcli device wifi show-password 
SSID: [CLIPPED]
Security: WPA
Password: [CLIPPED FOR GITHUB]

  █████████████████████████████████████
  ██ ▄▄▄▄▄ █▄▀ ▀ ▄▀▄ ██▄▀▀▄ ▄█ ▄▄▄▄▄ ██
  ██ █   █ █   █▀ █▄ ▀▀▄▄█ ███ █   █ ██
[TRUNCATED FOR GITHUB ...]
  ██▄▄▄▄▄▄▄█▄▄▄▄█▄███▄███▄█▄█████▄▄████
  ████████████████████████████████████
m ~ % printf '%s\n\n' "$(wifi-password --version)" "$(NetworkManager --version)" "$(nmcli --version)" "$(cat /etc/os-release | head -4)"
1.1.1

1.32.12-1

nmcli tool, version 1.32.12-1

NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.