HIBP Pwned Passwords Awk splitter
This Awk script splits pwned-passwords-1.0.txt.7z
(and
updates) into 256 files xz compressed files, by hash prefix (2 digits).
The script assumes the format of the input file is one hash per line.
It can be ran for more than one pwned-passwords-*.txt.7z
file, such as
pwned-passwords-update-1.txt.7z
as long as Troy keeps the format consistent.
Requires 7z
(p7zip), and GNU Awk (tested with
GNU Awk 4.1.4).
$ 7z e -so pwned-passwords-1.0.txt.7z | awk -f split.awk
Because searching a multi-GiB compressed file is a pain in the ass, and loading the contents into a database for a few local searches is not worth the hassle. (says the one who wrote an awk script and ran it...)
Being able to use xzgrep
is also nice.
Here's a quick and dirty bash function to perform a search on these files:
amipwned() {
local pw pwsha
read -rsp "Password: " pw
echo
pwsha=$(echo -n "$pw" | shasum | cut -f1 -d ' ')
xzgrep -qm1 "$pwsha" "pwned-${pwsha:0:2}.xz" \
&& echo 'PWNED!' \
|| echo 'That one is safe, for now.'
}
Using it is simple:
$ amipwned
Password:
PWNED!
π°π°π°
I'm not responsible for full disks, omg-my-password-is-pwned panic attacks, sweated shirts or soiled trousers, or whatever happens to you or your system derived from running any of this code, or reading this text.
This code is licensed under a CC0 1.0 Universal license: https://creativecommons.org/publicdomain/zero/1.0/legalcode.
Have fun. π