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
#!/usr/bin/python | |
# (Note that we must use system Python on a Mac.) | |
#### | |
# Quick script to get the computer's serial number. | |
# | |
# Written for @john.e.lamb on the MacAdmins Slack team. | |
import objc | |
import CoreFoundation |
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
{ | |
"/Contents": ["d", ""], | |
"/Contents/Frameworks": ["d", ""], | |
"/Contents/Frameworks/OSInstallerSetup.framework": ["d", ""], | |
"/Contents/Frameworks/OSInstallerSetup.framework/OSInstallerSetup": ["s", "Versions/Current/OSInstallerSetup"], | |
"/Contents/Frameworks/OSInstallerSetup.framework/Resources": ["s", "Versions/Current/Resources"], | |
"/Contents/Frameworks/OSInstallerSetup.framework/Versions": ["d", ""], | |
"/Contents/Frameworks/OSInstallerSetup.framework/Versions/A": ["d", ""], | |
"/Contents/Frameworks/OSInstallerSetup.framework/Versions/A/Frameworks": ["d", ""], | |
"/Contents/Frameworks/OSInstallerSetup.framework/Versions/A/Frameworks/IABridgeOSInstall.framework": ["d", ""], |
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
EFI found at IODeviceTree:/efi | |
Current EFI boot device string is: '<array><dict><key>IOMatch</key><dict><key>IOProviderClass | |
</key><string>IOMedia</string><key>IOPropertyMatch</key><dict><key>UUID</key><string>08A2DDE7 | |
-7A58-44F0-ABF6-B721AD7C31AF</string></dict></dict><key>BLLastBSDName</key><string>disk1s2</s | |
tring></dict><dict><key>IOEFIDevicePathType</key><string>MediaFilePath</string><key>Path</key | |
><string>\FD77CA06-84E9-42D0-B5FE-6295D28CBB2F\System\Library\CoreServices\boot.efi</string>< | |
/dict></array>' | |
Boot option is 8BE4DF61-93CA-11D2-AA0D-00E098032B8C:Boot0080 | |
Processing boot option 'Mac OS X' | |
Boot option matches XML representation |
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 Crypto.Cipher import AES | |
from Crypto.Util import Counter | |
import struct | |
""" | |
typedef struct boot_dat_hdr | |
{ | |
unsigned char ident[0x10]; | |
unsigned char sha2_s2[0x20]; | |
unsigned int s2_dst; |
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 ctypes import create_string_buffer, c_void_p, cast | |
from Foundation import NSBundle | |
Security = NSBundle.bundleWithIdentifier_('com.apple.security') | |
# CMSDecoder.h | |
kCMSSignerUnsigned = 0 | |
kCMSSignerValid = 1 | |
kCMSSignerNeedsDetachedContent = 2 |
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
# Warning - because of how this works, it loads classes into memory namespace. | |
# Attempting to load a second Xcode to inspect within the same python run will result in errors | |
# If you need to inspect multiple, for now, just spin the inspection up under a second process | |
from Foundation import NSBundle | |
def xcode_info(app_path): | |
# app_path = '/Applications/Xcode.app' | |
DVTFoundation = NSBundle.bundleWithPath_('%s/Contents/SharedFrameworks/DVTFoundation.framework' % app_path) | |
IDEKit = NSBundle.bundleWithPath_('%s/Contents/Frameworks/IDEKit.framework' % app_path) |
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 glob, os.path, pwd, os | |
from ctypes import CDLL, byref, create_string_buffer, c_uint32 | |
from ctypes.util import find_library | |
libsys = CDLL(find_library('C')) | |
def user_temp_dir(uid): | |
path_buffer = create_string_buffer(1024) | |
result = libsys.__user_local_dirname(c_uint32(uid), 0, byref(path_buffer), 1024) | |
return path_buffer.value.rsplit('/0/',1)[0] |
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
property destination_for_dmgs : "/Users/mike/Desktop" | |
on open the_items | |
repeat with an_item in the_items | |
set the_info to info for an_item | |
if kind of the_info is "Folder" then | |
set dmg_path to quoted form of (destination_for_dmgs & "/" & (name of the_info) & ".dmg") | |
set src_path to quoted form of POSIX path of an_item | |
set vol_name to quoted form of (name of the_info) | |
set command_str to "hdiutil create " & dmg_path & " -volname " & vol_name & " -srcfolder " & src_path |
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 nibbler import * | |
from Foundation import NSTimer, NSObject | |
from AppKit import NSApplication | |
n = Nibbler('/Users/frogor/Desktop/sweet.nib') | |
def test2(): | |
print "hi (politely quit)" | |
n.quit() |
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
#!/usr/bin/python | |
from Foundation import NSZeroRect, NSMakeRect, NSMakeSize | |
from AppKit import NSPNGFileType, NSCompositeCopy, NSGraphicsContext, NSCalibratedRGBColorSpace, NSBitmapImageRep, NSImage, NSImageNameComputer | |
dimension = 512 | |
size = NSMakeSize(dimension, dimension) | |
rect = NSMakeRect(0, 0, dimension, dimension) | |
image = NSImage.imageNamed_(NSImageNameComputer) | |
image.setSize_(size) |