Skip to content

Instantly share code, notes, and snippets.

@xenithorb
Created January 17, 2019 17:39
Show Gist options
  • Save xenithorb/0114200c02a8bc9952d829b99623f9f7 to your computer and use it in GitHub Desktop.
Save xenithorb/0114200c02a8bc9952d829b99623f9f7 to your computer and use it in GitHub Desktop.
HIBP API curl one-liner for keepassXC CSV output to check for circulated passwords
while read -r line; do hash=$( awk -F'","' '{printf "%s", $4}' <<< "$line" | sha1sum | cut -d' ' -f1 ); hash=${hash^^}; if (curl -s "https://api.pwnedpasswords.com/range/${hash:0:5}" | grep -q "${hash:5}" ); then echo "$line"; fi; sleep 1; done < <( { tr -d '\n' < output.csv | sed -r -e 's|"(xenith_keepass)|\n"\1|g' -e 's|,,|,"",|g'; echo; } | tail -n+2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment