Skip to content

Instantly share code, notes, and snippets.

@evilchili
Created August 27, 2013 21:58
Show Gist options
  • Save evilchili/6359717 to your computer and use it in GitHub Desktop.
Save evilchili/6359717 to your computer and use it in GitHub Desktop.
Trying to extract a PBKDF2-HMAC-SHA1 from user plist on mountain lion; failing. What am I missing?
#!/bin/sh
USER=$1
# get the shadow hash from the user entry
dscl . read /Users/$USER dsAttrTypeNative:ShadowHashData | tail -1 \
# remove everything but hex data and spaces
| tr -dc '0-9a-f ' \
# convert the hex dump into binary
| xxd -p -r \
# decode the binary blob into an xml-formatted plist entry
| plutil -convert xml1 - -o - \
# extract the <data> element's text
| xmllint --xpath "string(//data/text())" - \
# clean-up
|tr -d '\t\n'
@epu
Copy link

epu commented Aug 28, 2013

The output of dscl doesn't look like it's modified from 'tail -1' on mac. What does it do?

@epu
Copy link

epu commented Aug 28, 2013

that xpath should get at least 2 data nodes, if I'm reading my own output correctly. Is there a particular one you're after?

@epu
Copy link

epu commented Aug 28, 2013

Nerp. Interesting. It stops iterating on the first node. So you do only get the first one.

@epu
Copy link

epu commented Aug 28, 2013

Eh. It looks like it gets the entropy data block as a string ok, as long as I sudo. Is this not working for you?

@epu
Copy link

epu commented Aug 28, 2013

On the console, I am using single quotes around the xpath. Trying as a .sh as nature intended.

@epu
Copy link

epu commented Aug 28, 2013

This works fine as long as I delete comments from the shell script and run as sudo. What are you stuck on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment