Skip to content

Instantly share code, notes, and snippets.

@n8felton
Forked from bruienne/create_osx_pbkdf2_plist.py
Created October 15, 2024 16:09
Show Gist options
  • Save n8felton/fd5bc1cacabab06cc7284f69caf11b2a to your computer and use it in GitHub Desktop.
Save n8felton/fd5bc1cacabab06cc7284f69caf11b2a to your computer and use it in GitHub Desktop.
Create an MDM-compatible PBKDF2 hash and plist for use with AccountConfiguration
#!/usr/bin/python
# Requires passlib: pip install passlib
from passlib.hash import pbkdf2_sha512
from passlib.util import ab64_decode
from biplist import *
# Checksum size must be 128 bytes for use as OS X password hash!
pbkdf2_sha512.checksum_size = 128
hash = pbkdf2_sha512.encrypt("password", rounds=38000, salt_size=32)
# Decode the "special" base64 encoding passlib applies and use inside the data key binary instead
outerdict = {'SALTED-SHA512-PBKDF2': {'entropy': Data(ab64_decode(hash.split('$')[4])), 'salt': Data(ab64_decode(hash.split('$')[3])), 'iterations': int(hash.split('$')[2])}}
biplist.writePlist(outerdict,'admin.plist')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment