
はい、ダウンロードしましたHave I Been Pwned のすべての SHA-1 ハッシュパスワード マネージャーからすべてをエクスポートし、それを 1 行に 1 つのパスワードを含むファイルに処理しました。これらのファイルを効果的に一致させるにはどうすればよいですか?
答え1
前提条件
7z
、これは「p7zip」パッケージ。sha1sum
そしてshred
、これらは「coreutils」パッケージに含まれているはずです。grep
「grep」パッケージから。
プロセス
一意の大文字のパスワード ハッシュを含むファイルと、パスワードとそれに対応するハッシュを含むファイルを作成します。
sort -u passwords.txt | while read -r password do hash="$(printf '%s' "$password" | \ sha1sum | \ cut -d' ' -f1 | \ tr 'a-f' 'A-F')" printf '%s\n' "$hash" >> hashes.txt printf '%s\t%s\n' "$hash" "$password" >> passwords-with-hashes.txt done
ダウンロードしたファイル内のすべてのエントリとハッシュを一致させます。
7z e -so pwned-passwords-sha1-ordered-by-hash-v*.7z | \ cut -c 1-40 | \ grep -Fxf hashes.txt | \ tee matches.txt
しばらくお待ちください。SSD を搭載したデスクトップ マシンでは、この処理に 20 分近くかかりました。
一致に関連するパスワードを表示します:
grep -Ff matches.txt passwords-with-hashes.txt | cut -f2
作成したファイルを安全に削除します。
shred --remove hashes.txt matches.txt passwords.txt passwords-with-hashes.txt