Skip to content

Instantly share code, notes, and snippets.

@Tonyliu2ca
Forked from dardo82/mac-passwd2hashcat.sh
Created January 16, 2020 22:06
Show Gist options
  • Save Tonyliu2ca/40744c2c8d81311d2bf540d9f64b33d3 to your computer and use it in GitHub Desktop.
Save Tonyliu2ca/40744c2c8d81311d2bf540d9f64b33d3 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