Skip to content

Instantly share code, notes, and snippets.

View n8felton's full-sized avatar
🍎

Nate Felton n8felton

🍎
View GitHub Profile
@n8felton
n8felton / create_osx_pbkdf2_plist.py
Created October 15, 2024 16:09 — forked from bruienne/create_osx_pbkdf2_plist.py
Create an MDM-compatible PBKDF2 hash and plist for use with AccountConfiguration
#!/usr/bin/python
# Requires passlib: pip install passlib
from passlib.hash import pbkdf2_sha512
from passlib.util import ab64_decode
from biplist import *
# Checksum size must be 128 bytes for use as OS X password hash!
pbkdf2_sha512.checksum_size = 128
hash = pbkdf2_sha512.encrypt("password", rounds=38000, salt_size=32)
@n8felton
n8felton / Makefile.version
Created August 9, 2023 15:32 — forked from grihabor/Makefile.version
Makefile to use for incremental semantic versioning
MAKE := make --no-print-directory
DESCRIBE := $(shell git describe --match "v*" --always --tags)
DESCRIBE_PARTS := $(subst -, ,$(DESCRIBE))
VERSION_TAG := $(word 1,$(DESCRIBE_PARTS))
COMMITS_SINCE_TAG := $(word 2,$(DESCRIBE_PARTS))
VERSION := $(subst v,,$(VERSION_TAG))
VERSION_PARTS := $(subst ., ,$(VERSION))
@n8felton
n8felton / darwin_env_var.sh
Created March 30, 2023 17:07 — forked from carlashley/darwin_env_var.sh
Darwin Environment Variables
#!/bin/sh
# User path
/usr/bin/getconf DARWIN_USER_DIR
# Temp directory
# Note - $TMPDIR is the same as this
/usr/bin/getconf DARWIN_USER_TEMP_DIR
# Cache directory
@n8felton
n8felton / kcpasswordEncode.sh
Created January 19, 2022 03:39 — forked from brunerd/kcpasswordEncode.sh
Encode a string for use in macOS /etc/kcpassword using shell, printf, sed, awk and xxd
#!/bin/bash
#kcpasswordEncode (20210911) Copyright (c) 2021 Joel Bruner (https://github.com/brunerd)
#Licensed under the MIT License
#given a string creates data for /etc/kcpassword
function kcpasswordEncode {
#ascii string
local thisString="${1}"
local i
@n8felton
n8felton / nvram.py
Last active December 7, 2021 00:27 — forked from pudquick/nvram.py
Get nvram values via python and pyobjc on macOS
import objc
from Foundation import NSBundle
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [
("IORegistryEntryFromPath", b"II*"),
("IORegistryEntryCreateCFProperty", b"@I@@I"),
]
@n8felton
n8felton / letsencrypt_esxi.sh
Created February 10, 2021 21:09 — forked from shr00mie/letsencrypt_esxi.sh
Let's Encrypt SSL for ESXi
#!/bin/bash
#
## -----------------------------=[ WARNING ]=-------------------------------- ##
#
# This script is now woefully out of date due to which accounts ESXi allows to
# ssh into the box as well as sticky folders/file flags.
# I've since ported the whole thing to python with a lot of bells and whistles
# and if i get around to making it public, i'll put a link here.
#
## -------------------------------=[ Info ]=--------------------------------- ##
#!/usr/local/munki/munki-python
import plistlib, os.path, os, logging, pprint
# Based off of https://forums.developer.apple.com/message/6741
# and http://apple.stackexchange.com/a/136976
# Downloaded from https://gist.github.com/pudquick/349f063c242239952a2e
log_fmt = "[%(asctime)s] [%(levelname)-8s] %(message)s"
logging.basicConfig(format=log_fmt, level=logging.DEBUG)
@n8felton
n8felton / README.md
Created November 25, 2019 15:08 — forked from heywoodlh/README.md
Auth logging on MacOS using the log command
mkdir -p /opt/scripts
mkdir -p /var/log/custom
mkdir -p /var/root/Library/LaunchAgents


curl 'https://gist.githubusercontent.com/heywoodlh/0295135b9e24ec0729571497c9ab5a77/raw/b3032d9a563c956f574176c39cb2a5382f8c579c/auth-log.sh' -o /opt/scripts/auth-log.sh
chmod +x /opt/scripts/auth-log.sh

#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (tested on 10.12.6 and 10.14.3)
# - 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)
# Run with root
import objc, ctypes.util, os.path, collections