Skip to content

Instantly share code, notes, and snippets.

@acidprime
Created December 8, 2011 04:21
Show Gist options
  • Save acidprime/1446095 to your computer and use it in GitHub Desktop.
Save acidprime/1446095 to your computer and use it in GitHub Desktop.
PyObjC bridge code for reading shadow hashes
#!/usr/bin/python
import binascii
from Cocoa import NSDictionary,NSPropertyListSerialization
from Cocoa import NSPropertyListImmutable
user = 'acid'
path = '/var/db/dslocal/nodes/Default/users/%s.plist' % user
# Read the binary plist
plist = NSDictionary.dictionaryWithContentsOfFile_(path)
# Grab the ShadowHashData key
dataShadowHashData = plist['ShadowHashData'][0]
# Convert to dictionary
convertDataToPlist = NSPropertyListSerialization.propertyListWithData_options_format_error_(dataShadowHashData,NSPropertyListImmutable,None,None)
ShadowHashData = convertDataToPlist[0]
for key in ShadowHashData.keys():
value = binascii.hexlify(ShadowHashData[key])
print '%s = %s' % (key,value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment