Skip to content

Instantly share code, notes, and snippets.

View bmike's full-sized avatar

Mike Bradshaw bmike

View GitHub Profile
@haircut
haircut / tcc-reset.py
Last active December 17, 2024 16:38
Completely reset TCC services database in macOS
#!/usr/bin/python
"""
Completely reset TCC services database in macOS
Note: Both the system and individual users have TCC databases; run the script as both
a user and as root to completely reset TCC decisions at all levels.
2018-08-15: Resetting the 'Location' service fails; unknown cause
2018-08-16: Confirmed the 'All' service does not really reset _all_
services, so individual calls to each service is necessary.
@bwmorales
bwmorales / rmSMB_Illegals.sh
Last active June 29, 2018 18:10
Swap out those pesty SMB illegals with benign characters!
#!/bin/bash
# USAGE: ./rmSMB_Illegals.sh path
# Find searches through each file on a filesystem and passes the filenames to a
# function that tests for the presence of illegal characters and remediates.
# Bad characters are either removed or replaced with a ``-''.
# This has been tested on APFS on macOS 10.13.5. It'd be pretty safe to run this
# on a mounted volume, but it'd be nicer to test on Synology Linux and have it
@timsutton
timsutton / mv1Password.sh
Created May 27, 2018 19:52
1P 'mv1Password' script
#!/bin/sh
# this script removes the binary before we install it to ensure that we don't end up with a hybrid of what was there and what we're installing
echo "Removing legacy helper startup items"
loggedInUser=$(stat -f%Su /dev/console)
bundleIds=( "2BUA8C4S2C.com.agilebits.onepassword4-helper"
"2BUA8C4S2C.com.agilebits.onepassword-osx-helper"
"com.agilebits.onepassword-osx-helper"
"ws.agile.1PasswordAgent"
@bruienne
bruienne / find32bit.py
Created January 25, 2018 17:08
Find 32-bit executables in a given path. Uses the macholib module that ships with macOS.
#!/usr/bin/python
from macholib import MachO
import macholib
import os
import sys
path = sys.argv[1]
for root, dirs, files in os.walk(path):
@talkingmoose
talkingmoose / Download and Install Microsoft product.zsh
Last active March 10, 2025 23:07
**Download the latest version of this script from: https://gist.github.com/b6637160b65b751824943ede022daa17 .** Downloads and installs the latest available Microsoft product specified directly on the client. This avoids having to manually download and store an up-to-date installer on a distribution server every month.
#!/bin/zsh
:<<'ABOUT_THIS_SCRIPT'
-----------------------------------------------------------------------
Written by:William Smith
Partner Program Manager
Jamf
[email protected]
https://gist.github.com/b6637160b65b751824943ede022daa17
@pudquick
pudquick / last.py
Last active July 26, 2024 08:19
Parsing utmp/utmpx record entries for login, logout, shutdown and reboot on macOS with python and ctypes
from ctypes import CDLL, Structure, POINTER, c_int64, c_int32, c_int16, c_char, c_uint32
from ctypes.util import find_library
import time
c = CDLL(find_library("System"))
# https://opensource.apple.com/source/Libc/Libc-1158.50.2/include/NetBSD/utmpx.h.auto.html
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/endutxent.3.html#//apple_ref/doc/man/3/endutxent
BOOT_TIME = 2
@pudquick
pudquick / sip_config.py
Created December 22, 2016 22:31
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,
@chockenberry
chockenberry / finder_icons.sh
Last active February 10, 2024 19:05
A simple shell script to turn the Finders desktop icons on and off
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write com.apple.finder CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
@opragel
opragel / help.apple.com_urls
Last active July 4, 2020 05:05
help.apple.com_urls
help.apple.com pages:
https://help.apple.com/accessibility/mac/control/10.12/
https://help.apple.com/deployment/macos/
https://help.apple.com/deployment/ios/
https://help.apple.com/deployment/business/
https://help.apple.com/education/
https://help.apple.com/deployment/education/
https://help.apple.com/machelp/mac/10.12/
https://help.apple.com/serverapp/mac/