Skip to content

Instantly share code, notes, and snippets.

@seamustuohy
Created October 22, 2017 19:23
Show Gist options
  • Save seamustuohy/61f01ff199a465f2a5036c2ac6d24685 to your computer and use it in GitHub Desktop.
Save seamustuohy/61f01ff199a465f2a5036c2ac6d24685 to your computer and use it in GitHub Desktop.
WPA-PSK Bash Golf
# Bash Golf example that gets the WPA-PSK key from the WiFi network you are currently connected to.
# Beyond the basics (cut & grep) it uses network manager's CLI and python3
c='cut -d: -f2';g=grep;a=$(nmcli -t -f ACTIVE,SSID d w l|$g -E "^yes:"|$c);p=$(nmcli -s -t c show $a|$g psk:|$c);python3 -c "from hashlib import pbkdf2_hmac as p; from binascii import hexlify as h;print('PSK',h(p('sha1', b'$p', b'$a', 4096, dklen=32)).decode('ascii'))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment