Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / example.applescript
Last active January 2, 2019 11:16
Example AppleScriptObjC / Cocoa-Applescript function for parsing hdiutil mount plist output via ObjC calls
script AppDelegate
property parent: class "NSObject"
-- Syntax sugar
property myApp: current application
property None: missing value -- Be careful not to bind this as a IBOutlet!
-- Classes
property NSData: myApp's class "NSData"
property NSString: myApp's class "NSString"
@pudquick
pudquick / BootCacheControl.txt
Last active August 26, 2016 20:40
Hidden BootCacheControl documentation
Usage: /usr/sbin/BootCacheControl [-vvv] [-f <playlistfile>] start
Start recording history and play back <playlistfile>.
/usr/sbin/BootCacheControl [-vvv] [-f <playlistfile>] stop
Stop recording history and write the playlist to <playlistfile>.
/usr/sbin/BootCacheControl mount
Notify the boot cache of a new mount.
/usr/sbin/BootCacheControl [-vvv] jettison
Jettison the cache.
/usr/sbin/BootCacheControl statistics
Print statistics for the currently-active cache.
@pudquick
pudquick / word_magic.py
Last active August 29, 2015 14:17
Saturday morning fun.
import sys, os.path, csv
# Run me like: python word_magic.py inputfile.csv output_dir
KEEP_WORD = True
# We're being lazy here - no main for us, it's Saturday
in_filename = sys.argv[1]
out_dir = os.path.abspath(sys.argv[2])

Intercepts HTTPs Traffic with Python & mitmproxy

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

This manual helps you create your own proxy with Python and mitmproxy/libmproxy. Mitmproxy ships with both a standalone command-line tool (mitmproxy) and a Python library (libmproxy).

@pudquick
pudquick / example.sh
Created March 26, 2015 17:21
Example of a bash multi-line value write to a key using defaults
read -r -d '' MULTILINE << EOL
Here's line one.
Wheee this is awesome!
^^ Notice that blank line?!?!
Here's the "last" line.
EOL
defaults write your.whatever.here your.key.name.here -string "$MULTILINE"
#!/bin/sh
# Copyright 2000-2011, Apple Inc.
#
# Disable prebinding-on-the-fly while we're read-only boted
#
export DYLD_NO_FIX_PREBINDING=1
#
# Set autopower on after power failure
@pudquick
pudquick / parse_pbzx.py
Last active September 27, 2021 04:34
Pure python reimplementation of .cpio.xz content extraction from pbzx file payload for OS X packages
# 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
# Example usage:
# parse_pbzx('PayloadJava', 'PayloadJava.cpio.xz')
# Updated for speeeeeeeeeeeeed
@pudquick
pudquick / xz_decompress.py
Last active August 29, 2015 14:18
Python ctypes wrapper around liblzma for the purposes of (naive) xz file decompression, for use with OS X 10.7+
# Example usage of the function:
# decompress('PayloadJava.cpio.xz', 'PayloadJava.cpio')
# Decompresses a xz compressed file from the first input file path to the second output file path
import sys
from ctypes import CDLL, Structure, c_void_p, c_size_t, c_uint, c_uint32, c_uint64, create_string_buffer, addressof, sizeof, byref
class lzma_stream(Structure):
_fields_ = [
@pudquick
pudquick / parse_pbzx2.py
Created April 8, 2015 05:27
A pbzx stream decoder for the format found within Yosemite package payloads.
# 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