Skip to content

Instantly share code, notes, and snippets.

View Python 3.8.5 framework build
$ ./make_relocatable_python_framework.py --python-version 3.8.5
Downloading https://www.python.org/ftp/python/3.8.5/python-3.8.5-macosx10.9.pkg...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 28.8M 100 28.8M 0 0 6860k 0 0:00:04 0:00:04 --:--:-- 6860k
Expanding /var/folders/tc/sd4_mtvj14jdy7cg21m2gmcw000495/T/tmpdhiqv6m3...
Extracting /var/folders/tc/sd4_mtvj14jdy7cg21m2gmcw000495/T/tmpdhiqv6m3__expanded__/Python_Framework.pkg/Payload to ./Python.framework...
Ensuring correct modes for files in /Users/Shared/relocatable-python/Python.framework...
Analyzing /Users/Shared/relocatable-python/Python.framework...
...............................
@gregneagle
gregneagle / adminopen.sh
Created Mar 9, 2020
Guess what this can be used for? (Hint: read the comments)
View adminopen.sh
#!/bin/bash
# This script is designed to be run as root, perhaps by a management tool
# It takes one argument, a path to an app to be launched (or a name of an app,
# if you don't mind LaunchServices deciding which if any app to launch)
#
# If the current console user is not a member of the admin group, the user will
# be added to to the group. The app will then be launched in the console user's
# context.
# When the app exits (or this script is killed via SIGINT), if we had promoted
@gregneagle
gregneagle / Makefile
Created Mar 5, 2020
Make your own PPPC/TCC avoidance wrapper!
View Makefile
CC=gcc
CFLAGS=
SIGNINGIDENTITY="insert signing identity here"
IDENTIFIER=com.someorg.fudo.changeme
fudo: main.c
$(CC) -o fudo main.c
codesign -s $(SIGNINGIDENTITY) -i $(IDENTIFIER) fudo
@gregneagle
gregneagle / startosinstall_10.12.6_normalboot.txt
Last active Apr 11, 2020
Comparison of startosinstall's available options depending on boot OS environment
View startosinstall_10.12.6_normalboot.txt
bash-3.2$ /Applications/Install\ macOS\ Sierra.app/Contents/Resources/startosinstall --usage
Usage: startosinstall --applicationpath <install macOS.app path>
Arguments
--applicationpath, a path to copy of the OS installer application to start the install with.
--license, prints the user license agreement only.
--agreetolicense, agree to license the license you printed with --license.
--rebootdelay, how long to delay the reboot at the end of preparing. This delay is in seconds and has a maximum of 300 (5 minutes).
--pidtosignal, Specify a PID to which to send SIGUSR1 upon completion of the prepare phase. To bypass "rebootdelay" send SIGUSR1 back to startosinstall.
--usage, prints this message.
@gregneagle
gregneagle / prefs_observer.py
Created Aug 1, 2017
Getting notified when a preference changes (using PyObjC)
View prefs_observer.py
from Foundation import NSObject, NSUserDefaults, NSKeyValueObservingOptionNew
from Foundation import NSRunLoop, NSDate
class PrefsObserver(NSObject):
def observe(self, domain, key):
self.domain = domain
self.key = key
if self:
self.defaults = NSUserDefaults.alloc().initWithSuiteName_(
@gregneagle
gregneagle / fancy_defaults_read.py
Last active Mar 19, 2021
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
View fancy_defaults_read.py
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
View locationd_fun.py
#!/usr/bin/python
import os
import pwd
from Foundation import CFPreferencesAppSynchronize
from Foundation import CFPreferencesSetValue
from Foundation import kCFPreferencesCurrentUser
from Foundation import kCFPreferencesCurrentHost
@gregneagle
gregneagle / sysctl_demo.py
Last active Apr 16, 2021
Based on sysctl function by Michael Lynn aka frogor aka pudquick aka ????
View sysctl_demo.py
# Based on sysctl function by Michael Lynn
# https://gist.github.com/pudquick/581a71425439f2cf8f09
from ctypes import CDLL, c_uint, byref, create_string_buffer
from ctypes import cast, POINTER, c_int32, c_int64
from ctypes.util import find_library
import struct
libc = CDLL(find_library('c'))
View DNDtest.py
#!/usr/bin/python
import time
from Quartz import CGGetActiveDisplayList, CGGetOnlineDisplayList
from CoreFoundation import CFPreferencesCopyAppValue
def displayMirroringActive():
'''Returns True if any two displays are mirroring, False otherwise'''
View docklib.py
'''Routines for manipulating the Dock'''
import os
import subprocess
from Foundation import NSURL
from Foundation import CFPreferencesAppSynchronize
from Foundation import CFPreferencesCopyAppValue
from Foundation import CFPreferencesSetAppValue