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 | |
packagekit_bundle = objc.loadBundle('PackageKit', module_globals=globals(), bundle_path='/System/Library/PrivateFrameworks/PackageKit.framework', scan_classes=False) | |
PKReceipt = objc.lookUpClass('PKReceipt') | |
receipts = PKReceipt.receiptsOnVolumeAtPath_('/') | |
first_receipt = receipts[0] | |
# Things you can look up: | |
# installPrefixPath |
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 | |
# Predefine some opaque types | |
DASessionRef = objc.createOpaquePointerType('DASessionRef', b'^{__DASession=}', None) | |
DADiskRef = objc.createOpaquePointerType('DADiskRef', b'^{__DADisk=}', None) | |
# Load DiskManagement framework classes | |
DiskManagment = objc.loadBundle('DiskManagment', globals(), bundle_path='/System/Library/PrivateFrameworks/DiskManagement.framework') |
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 | |
login_bundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/login.framework') | |
functions = [('SACLockScreenImmediate', '@'),] | |
objc.loadBundleFunctions(login_bundle, globals(), functions) | |
# Lock the screen regardless of security settings or who is logged in | |
result = SACLockScreenImmediate() |
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 | |
CG_bundle = NSBundle.bundleWithIdentifier_('com.apple.CoreGraphics') | |
functions = [("CGSSessionCopyAllSessionProperties", b"@"),] | |
objc.loadBundleFunctions(CG_bundle, globals(), functions) | |
# example usage: graphical_security_sessions = CGSSessionCopyAllSessionProperties() |
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
# This code must run as root | |
# We're mixing ObjC and C-style dylibs, so this is really fun | |
# The only reason we're doing this is that the OS is _really really_ picky about trying to do | |
# ANYTHING with the CoreStorage Family Properties CFDictionary that's in-memory EXCEPT for | |
# making a mutable copy of it. | |
# Once we've done that, we can bring it into pyObjC to play nicely with the data. | |
import objc |
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 | |
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit') | |
functions = [("IOServiceGetMatchingService", b"II@"), | |
("IOServiceMatching", b"@*"), | |
("IORegistryEntryCreateCFProperty", b"@I@@I"), | |
] |
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
from ctypes import CDLL | |
loginPF = CDLL('/System/Library/PrivateFrameworks/login.framework/Versions/Current/login') | |
result = loginPF.SACLockScreenImmediate() |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Description</key> | |
<string>Downloads the current release version of Eclipse.</string> | |
<key>Identifier</key> | |
<string>com.github.sheagcraig.download.EclipseIDE</string> | |
<key>Input</key> | |
<dict> |
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 sys, os, os.path, tempfile, plistlib, shutil | |
class TempApp(object): | |
def __init__(self, infoPlist_dict, app_path=None, bundle_name='TempApp', cleanup=True, app_icon=None): | |
# infoPlist_dict: A dict containing key values that should be set/overridden | |
# vs. the normal Python.app keys. | |
# app_path: The path to where your app should go. Example: '/usr/local/myOrgStuff' | |
# This directory needs to pre-exist. If app_path is left at None, | |
# a temporary directory will be created and used and the value of | |
# cleanup will be forced to True |