Skip to content

Instantly share code, notes, and snippets.

@erikng
erikng / 8021x_inspect.py
Created July 19, 2016 22:27 — forked from pudquick/8021x_inspect.py
802.1x configuration / data collection on OS X using python and the PrivateFramework "EAP8021X.framework"
# This was all run from user space
# I haven't tested it with root
# ... but it didn't prompt for any permissions under userspace ^_^
# Tested on 10.11.5
import objc
from Foundation import NSBundle
EAP8021X_bundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/EAP8021X.framework')
Security_bundle = NSBundle.bundleWithIdentifier_('com.apple.security')
@erikng
erikng / marketing.py
Created August 25, 2016 03:52 — forked from pudquick/marketing.py
Using PrivateFrameworks to get marketing model information for Apple Macs without hitting their internet API (where possible) via python and pyobjc
# Tested on 10.11
# Note:
# The marketing information embedded in the ServerInformation.framework is not the same as what
# About This Mac displays - there are differences.
#
# For example:
# ServerInformation: 15" MacBook Pro with Retina display (Mid 2015)
# About This Mac: MacBook Pro (Retina, 15-inch, Mid 2015)
#
@erikng
erikng / dump_efi_images.py
Created September 24, 2016 17:59 — forked from pudquick/dump_efi_images.py
Decompressing and re-assembling LVZN compressed animations and logos from boot.efi
# This file parses this file:
# https://github.com/Piker-Alpha/macosxbootloader/blob/El-Capitan/src/boot/NetBootImages.h
# and this one:
# https://github.com/Piker-Alpha/macosxbootloader/blob/El-Capitan/src/boot/AppleLogoData.h
from ctypes import CDLL, create_string_buffer, c_size_t, c_void_p
import re
CPK = CDLL('/System/Library/PrivateFrameworks/PackageKit.framework/Versions/Current/PackageKit')
lzvn_decode = CPK.lzvn_decode
@erikng
erikng / unsign_plist.py
Created October 1, 2016 19:43 — forked from pudquick/unsign_plist.py
Getting an unsigned plist / mobileconfig from a signed one in python on OS X with pyObjC
import objc
from Foundation import NSBundle
Security_bundle = NSBundle.bundleWithIdentifier_('com.apple.security')
CMSDecoderRef = objc.createOpaquePointerType("CMSDecoderRef", b"^{CMSDecoder}", None)
functions = [('CMSDecoderCreate', b'io^^{CMSDecoder}'),
('CMSDecoderUpdateMessage', b'i^{CMSDecoder}*I'),
('CMSDecoderFinalizeMessage', b'i^{CMSDecoder}',),
@erikng
erikng / sip_config.py
Created December 23, 2016 01:43 — forked from pudquick/sip_config.py
Querying active SIP status directly from the kernel, bypassing nvram and csrutil, via python on macOS
# An overly complicated SIP config checker
# This is a technically interesting implementation because it does not rely on csrutil
# Instead it queries the kernel directly for the current configuration status
# This means, for example, in environments where SIP has been disabled and csrutil has
# been removed or modified (say, with DYLD_LIBRARY_PATH), as long as python can run you
# can still check status
# Additionally, checking the nvram csr-active-config setting isn't accurate now with
# 10.12.2+, since running "sudo csrutil clear" deletes the variable until reboot,
@erikng
erikng / convert.go
Created January 5, 2017 21:22 — forked from groob/convert.go
package main
import (
"fmt"
"image"
"image/draw"
"image/jpeg"
"image/png"
"io"
"log"
@erikng
erikng / xcode_get.py
Created February 1, 2017 22:23 — forked from pudquick/xcode_get.py
Stupid tricks: using stock macOS python subprocess with curl to download products from Apple's Developer Center
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"
@erikng
erikng / make_firmwareupdater_pkg.sh
Created September 12, 2017 15:59
Make standalone "universal" FirmwareUpdater package for High Sierra
#!/bin/sh
# Based on investigations and work by Pepijn Bruienne
# Expects a single /Applications/Install macOS Sierra*.app on disk
# Adapted from https://gist.github.com/gregneagle/7c802aef636ac4295536f2e360921bb1
IDENTIFIER="com.foo.FirmwareUpdateStandalone"
VERSION=1.0
# find the Install macOS Sierra.app and mount the embedded InstallESD disk image
echo "Mounting Sierra ESD disk image..."
@erikng
erikng / xcodemarkdown.sh
Created September 25, 2017 20:34 — forked from MagerValp/xcodemarkdown.sh
Convert markdown to html in a shell script using Xcode's CommonMark framework
#!/bin/bash
cat <<__MARKDOWN__ |
# Title ÅÄÖ
* list
__MARKDOWN__
/usr/bin/python <( cat <<__EOF__
#!/usr/bin/python
@erikng
erikng / seedutil.md
Created November 30, 2017 17:07 — forked from pookjw/seedutil.md
Enroll macOS Beta Seed without profile installation

seedutil

Enroll macOS Beta Seed without profile installation

Usage

$ sudo /System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil 
usage: seedutil enroll SEED_PROGRAM
    seedutil unenroll

seedutil current