Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / findpboard.py
Created Jan 30, 2021
Get / Set shared Find Pasteboard state on macOS via pyobjc
View findpboard.py
from AppKit import NSPasteboard, NSFindPboard, NSStringPboardType, NSString
def get_fboard():
fboard = NSPasteboard.pasteboardWithName_(NSFindPboard)
if NSStringPboardType in fboard.types():
return fboard.stringForType_(NSStringPboardType)
def set_fboard(findstr):
fboard = NSPasteboard.pasteboardWithName_(NSFindPboard)
fboard.declareTypes_owner([NSStringPboardType], None)
@pudquick
pudquick / isM1.py
Last active Feb 24, 2021
Determine if a Mac can run ARM64 code, whether or not the binary is running in Rosetta 2 via pyobjc
View isM1.py
# 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 Oct 7, 2020
IOKit IOUSBDevice enumeration
View iousb.py
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 Aug 25, 2020
Minecraft Java <-> Bedrock crossplay server blog post
View proxy.sh
#!/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 Oct 29, 2019 — forked from steventroughtonsmith/Info.plist
[Catalyst] Registering for & responding to AppleScript events in a Mac Catalyst app
View Info.plist
<key>NSAppleScriptEnabled</key>
<true/>
<key>OSAScriptingDefinition</key>
<string>ScriptableTasks.sdef</string>
@pudquick
pudquick / 00_notes.md
Last active Nov 20, 2020
Discovering variable/constant values in frameworks
View 00_notes.md
View fdsetup-for-crypt.mobileconfig
<?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>
View 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 Jan 14, 2020
Obtain codesigning information with pyobjc
View codesign.py
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 Apr 19, 2019
locally checking profile signing information
View profile_details.py
#!/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^@'),