Skip to content

Instantly share code, notes, and snippets.

View brunerd's full-sized avatar

Joel Bruner brunerd

View GitHub Profile
@brunerd
brunerd / nothing
Last active February 10, 2020 03:56
Uses of : (no effect)
#to officially do nothing
:
#there you go, this could be used when writing or troubleshooting a script and you have only a single item in an if clause
if [ "${this}" = "that" ]; then
#actually not sure what to do here, let's do nothing
:
else
echo "This else, I'll do"
#!/bin/bash
#macOS - returns 0 or 1 depending on if we are a running in a VM or not
grep -c VMM <<< $(sysctl -n machdep.cpu.features)
@brunerd
brunerd / removeSpawnOfZoomOpenerAllUsers.sh
Last active August 8, 2019 23:07
Removes all the ZoomOpener variants for all users
#!/bin/bash
#Joel Bruner - removes all ZoomOpener variants for all users
#############
# VARIABLES #
#############
#folder names where lurking webservers live
folderNames=".ringcentralopener
.zoomus
@brunerd
brunerd / shell_vers.sh
Last active October 25, 2019 15:15
Quickly get versions of items in /etc/shells
#!/bin/sh
#brunerd - shell_vers
#a simple version checker of available shells
#not guaranteed to always work (I'm looking at YOU dash!)
#specify another volume to test
target="$1"
#loop through /etc/shells either locally or on specified target volume
for shell in $(grep -v ^\# "${1}"/etc/shells); do
@brunerd
brunerd / certChecker.command
Last active November 24, 2020 13:24
Check the signing certificates on pkg packages and apps
#!/bin/bash
#certChecker - gets the certificate expiration(s) from a pkg or an app and outputs as CSV
: <<-EOL
MIT License
Copyright (c) 2020 Joel Bruner (brunerd.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@brunerd
brunerd / repackPKGs.command
Created October 28, 2019 17:28
Repack expired packages and strip off certs
#!/bin/bash
#Joel "brunerd" Bruner - repack and expired pkg, stripping off all certs
#we can specify a target as an argument
target="$1"
#if target not specified we ask
while [ ! -d "${target}" -a ! -f "${target}" ]; do
read -p "Please provide a target file or folder: " target
done
@brunerd
brunerd / maclTrack.command
Last active June 16, 2022 18:59
Examine all the com.apple.macl entries on files and folders
#!/bin/bash
: <<-EOL
MIT License
Copyright (c) 2020 Joel Bruner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@brunerd
brunerd / maclTackle.command
Last active February 23, 2024 11:28
A hacky example to clean the com.apple.macl attribute from a file using zip to sidestep SIP on Catalina
#!/bin/bash
#clean the com.apple.macl attribute from a file or folders using zip to sidestep SIP on Catalina
#WARNING: This will overwrite the original file/folders with the zipped version - DO NOT use on production data
#hold down command key at launch or touch /tmp/debug to enable xtrace command expansion
commandKeyDown=$(/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSCommandKeyMask > 1')
[ "$commandKeyDown" = "True" -o -f /tmp/debug ] && set -x && xtraceFlag=1
#hacky example to clean the com.apple.macl attribute from a file using zip to sidestep SIP
: <<-EOL
@brunerd
brunerd / macHardwareIdentifiers.sh
Last active December 9, 2022 20:29
Shell one liners for getting Mac hardware Serial, UUID, and Board ID
#Serial Number - x86/ARM
mySerial=$(/usr/libexec/PlistBuddy -c "print :0:IOPlatformSerialNumber" /dev/stdin <<< "$(ioreg -ard1 -c IOPlatformExpertDevice)")
#UUID - x86/ARM
myUUID=$(/usr/libexec/PlistBuddy -c "print :0:IOPlatformUUID" /dev/stdin <<< "$(ioreg -ard1 -c IOPlatformExpertDevice)")
#Provisioning UDID - ARM only, Monterey+ only
myProvisioningUDID=$(system_profiler -xml SPHardwareDataType | sed -e $'s/^[ \t]*//g;s/[ \t]*$//g' -e "s/date>/string>/g; s/data>/string>/g;s/real>/string>/g" | sed -e :a -e N -e '$!ba' -e 's/\n//g' | plutil -extract "0._items.0.provisioning_UDID" raw -o - -)
#Model ID - Universal
@brunerd
brunerd / keyDown.sh
Last active September 10, 2023 19:28
Getting macOS Modifier Key Down Events in JXA and Python
#!/bin/bash
#https://gist.github.com/brunerd/d775ab7b362b72d9feb0c4035f922ede
function printState
{
echo commandKeyDown: $commandKeyDown
echo controlKeyDown: $controlKeyDown
echo optionKeyDown: $optionKeyDown
echo shiftKeyDown: $shiftKeyDown
echo functionKeyDown: $functionKeyDown