Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / isM1.py
Last active September 28, 2023 16:27
Determine if a Mac can run ARM64 code, whether or not the binary is running in Rosetta 2 via pyobjc
# https://developer.apple.com/documentation/corefoundation/3684868-cfbundleisarchitectureloadable?language=objc
# https://developer.apple.com/documentation/foundation/1495005-mach-o_architecture?language=occ
# https://developer.apple.com/documentation/foundation/1495005-mach-o_architecture/nsbundleexecutablearchitecturearm64?language=occ
from Foundation import NSBundle
import objc
CF = NSBundle.bundleWithPath_('/System/Library/Frameworks/CoreFoundation.framework')
f = [('CFBundleIsArchitectureLoadable', 'BQ')]
objc.loadBundleFunctions(CF, globals(), f)
NSBundleExecutableArchitectureARM64 = 0x0100000c
@pudquick
pudquick / iousb.py
Created October 7, 2020 00:18
IOKit IOUSBDevice enumeration
import objc
from Foundation import NSBundle
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [
("IORegistryEntryCreateCFProperties", b"IIo^@II"),
("IOServiceMatching", b"@*"),
("IOServiceGetMatchingServices", b"II@o^I"),
("IOIteratorNext", b"II"),
]
@pudquick
pudquick / proxy.sh
Last active August 25, 2020 15:47
Minecraft Java <-> Bedrock crossplay server blog post
#!/bin/bash
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
export PATH="$JAVA_HOME/bin:$PATH"
cd "$( dirname "$0" )"
java -Xmx1024M -jar Geyser.jar
@pudquick
pudquick / Info.plist
Created October 29, 2019 03:57 — forked from steventroughtonsmith/Info.plist
[Catalyst] Registering for & responding to AppleScript events in a Mac Catalyst app
<key>NSAppleScriptEnabled</key>
<true/>
<key>OSAScriptingDefinition</key>
<string>ScriptableTasks.sdef</string>
@pudquick
pudquick / 00_notes.md
Last active November 20, 2020 01:53
Discovering variable/constant values in frameworks
@pudquick
pudquick / fdsetup-for-crypt.mobileconfig
Created July 17, 2019 01:31
Enable fdesetup for Crypt
<?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>PayloadContent</key>
<array>
<dict>
<key>PayloadDisplayName</key>
<string>Privacy Preferences Policy Control</string>
<key>PayloadIdentifier</key>
@pudquick
pudquick / keybase.md
Created July 4, 2019 19:24
keybase.md

Keybase proof

I hereby claim:

  • I am pudquick on github.
  • I am frogor (https://keybase.io/frogor) on keybase.
  • I have a public key ASBTy_VUW9m2orm3VyY994_c5qlvSMMatsoKxQk0l6LhyAo

To claim this, I am signing this object:

@pudquick
pudquick / codesign.py
Last active January 14, 2020 16:44
Obtain codesigning information with pyobjc
import objc
from Foundation import NSBundle, NSURL
Security = NSBundle.bundleWithIdentifier_('com.apple.security')
class StaticCodeError(Exception):
pass
class SigningInfoError(Exception):
pass
@pudquick
pudquick / profile_details.py
Created April 19, 2019 21:52
locally checking profile signing information
#!/usr/bin/python
# So the first thing we need to do is get the mdmclient view of the profiles
import subprocess, objc
from Foundation import NSPropertyListSerialization, NSPropertyListMutableContainers, NSBundle
Security = NSBundle.bundleWithIdentifier_('com.apple.security')
S_functions = [
('SecCertificateCreateWithData', '@@@'),
('SecCertificateCopyValues', '@@^@o^@'),
require 'base64'
require 'plist'
module Chef::Provider::User::DsclMojaveUserExtensions
# new for 10.14+
def mac_osx_version_greater_than_10_13?
Gem::Version.new(node['platform_version']) > Gem::Version.new('10.13.99')
end
# updated for 10.14+