-
-
Save erikng/753988edec18fbb43604e37a3ff3ec56 to your computer and use it in GitHub Desktop.
Getting an unsigned plist / mobileconfig from a signed one in python on OS X with pyObjC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import objc | |
from Foundation import NSBundle | |
Security_bundle = NSBundle.bundleWithIdentifier_('com.apple.security') | |
CMSDecoderRef = objc.createOpaquePointerType("CMSDecoderRef", b"^{CMSDecoder}", None) | |
functions = [('CMSDecoderCreate', b'io^^{CMSDecoder}'), | |
('CMSDecoderUpdateMessage', b'i^{CMSDecoder}*I'), | |
('CMSDecoderFinalizeMessage', b'i^{CMSDecoder}',), | |
('CMSDecoderCopyContent', b'i^{CMSDecoder}o^^{__CFData}')] | |
objc.loadBundleFunctions(Security_bundle, globals(), functions) | |
f = open('Example.mobileconfig.signed', 'rb') | |
signed_plist = f.read() | |
f.close() | |
err, decoder = CMSDecoderCreate(None) | |
err = CMSDecoderUpdateMessage(decoder, signed_plist, len(signed_plist)) | |
err = CMSDecoderFinalizeMessage(decoder) | |
err, unsigned_data = CMSDecoderCopyContent(decoder, None) | |
plist_bytes = unsigned_data.bytes().tobytes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment