Skip to content

Instantly share code, notes, and snippets.

Michael Lynn pudquick

Block or report user

Report or block pudquick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pudquick
pudquick / parse_pbzx2.py
Created Apr 8, 2015
A pbzx stream decoder for the format found within Yosemite package payloads.
View parse_pbzx2.py
# v2 pbzx stream handler
# My personal writeup on the differences here: https://gist.github.com/pudquick/29fcfe09c326a9b96cf5
#
# Pure python reimplementation of .cpio.xz content extraction from pbzx file payload originally here:
# http://www.tonymacx86.com/general-help/135458-pbzx-stream-parser.html
#
# Cleaned up C version (as the basis for my code) here, thanks to Pepijn Bruienne / @bruienne
# https://gist.github.com/bruienne/029494bbcfb358098b41
import struct, sys
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>
@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^@'),
@pudquick
pudquick / shellista.py
Last active Aug 27, 2019
Advanced shell for Pythonista
View shellista.py
import os, cmd, sys, re, glob, os.path, shutil, zipfile, tarfile, gzip
# Credits
#
# The python code here was written by pudquick@github
#
# License
#
# This code is released under a standard MIT license.
#
@pudquick
pudquick / od_verify.py
Last active Aug 8, 2019
Verifying username and password with python and OpenDirectory framework
View od_verify.py
import objc
# Set up opaque types for undefined signatures so we don't have
# to deal with "PyObjCPointer created:" errors
ODNode = objc.createOpaquePointerType("ODNode", b"^{_ODNode=}", None)
ODRecord = objc.createOpaquePointerType("ODRecord", b"^{_ODRecord=}", None)
from OpenDirectory import ODNodeCreateWithNodeType, ODNodeCopyRecord, ODRecordVerifyPassword, kODNodeTypeAuthentication, kODRecordTypeUsers
directory_service, err = ODNodeCreateWithNodeType(None, None, kODNodeTypeAuthentication, None)
@pudquick
pudquick / xcode_get.py
Last active Aug 8, 2019
Stupid tricks: using stock macOS python subprocess with curl to download products from Apple's Developer Center
View xcode_get.py
from subprocess import Popen, PIPE, STDOUT, check_output
from mimetools import Message
from StringIO import StringIO
from urlparse import urlparse, parse_qs
from urllib import quote, basejoin, urlencode
DEV_SITE = 'https://developer.apple.com'
AUTH_SITE = 'https://idmsa.apple.com'
AUTH_PATH = '/IDMSWebAuth/authenticate'
APPIDKEY_PATH = "/services-account/download?path=%s"
@pudquick
pudquick / pyobjc_keychain.py
Last active Aug 8, 2019
Manipulating the Keychain in macOS via python and pyobjc
View pyobjc_keychain.py
from Foundation import NSBundle
import objc, array
# from CoreFoundation import CFGetTypeID
Security = NSBundle.bundleWithPath_('/System/Library/Frameworks/Security.framework')
# First we need the CF TypeIDs to build some signatures
functions = [
('SecKeychainGetTypeID', 'I'),
]
View reorder_wifi_alt.py
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root
@pudquick
pudquick / reorder_wifi.py
Last active Aug 2, 2019
This python code uses Objective-C calls to reorder pre-existing SSIDs in your WiFi interfaces to place a preferred SSID at the top (without removing / re-adding)
View reorder_wifi.py
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root
@pudquick
pudquick / 00_notes.md
Last active Jul 31, 2019
Discovering variable/constant values in frameworks
View 00_notes.md
You can’t perform that action at this time.