Skip to content

Instantly share code, notes, and snippets.

@dardo82
Created June 2, 2019 18:26
Show Gist options
  • Save dardo82/a529db7a191f375ef401adfea7156b6d to your computer and use it in GitHub Desktop.
Save dardo82/a529db7a191f375ef401adfea7156b6d to your computer and use it in GitHub Desktop.
OSX user PW to HC format
#!/bin/sh
sudo dscl . read /Users/$USER ShadowHashData | tail -1 | xxd -p -r | plutil -convert xml1 - -o - | sed s/data/string/ | plutil -convert json - -o $USER.json
ITERATIONS=$(jq '."SALTED-SHA512-PBKDF2".iterations' $USER.json)
SALT=$(jq '."SALTED-SHA512-PBKDF2".salt' $USER.json | sed -E 's/"?\\n\\t\\t"?//g' | base64 -D | xxd -c 256 -p)
ENTROPY=$(jq '."SALTED-SHA512-PBKDF2".entropy' $USER.json | sed -E 's/"?\\n\\t\\t"?//g' | base64 -D | xxd -c 256 -p | cut -c -128)
echo "\$ml\$$ITERATIONS\$$SALT\$$ENTROPY" > $USER.hash
hashcat -m 7100 --example-hashes | awk '/HASH/{print $2}' > example.hash
hashcat -a 3 -m 7100 example.hash "?l?l?l?l?l?l?l"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment