This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jamflog - Copyright (c) 2021 Joel Bruner, Licensed under the MIT License | |
# a way to log to stdout and /var/log/jamf.log (or elsewhere) and have it match Jamf's log style | |
function jamflog(){ | |
[ -n "${-//[^x]/}" ] && { local xTrace=1; set +x; } &>/dev/null | |
local logFile="${2:-/var/log/jamf.log}" | |
#if it exists but we cannot write to the log or it does not exist, unset and tee simply echoes | |
[ -e "${logFile}" -a ! -w "${logFile}" ] && unset logFile | |
#this will tee to jamf.log in the jamf log format: <Day> <Month> DD HH:MM:SS <Computer Name> ProcessName[PID]: <Message> | |
builtin echo "$(/bin/date +'%a %b %d %H:%M:%S') ${jamflog_myComputerName:="$(/usr/sbin/scutil --get ComputerName)"} ${jamflog_myName:="$(/usr/bin/basename "${0%.*}")"}[${myPID:=$$}]: ${1}" | /usr/bin/tee -a "${logFile}" 2>/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#inZoomMeeting (20220214) Copyright (c) 2021 Joel Bruner (https://github.com/brunerd) | |
#Licensed under the MIT License | |
function inZoomMeeting { | |
#if this process exists, there is a meeting, return 0 (sucess), otherwise 1 (fail) | |
pgrep "CptHost" &>/dev/null && return 0 || return 1 | |
} | |
if inZoomMeeting; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Joel Bruner (https://github.com/brunerd) | |
function screenIsLocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" = "true" ] && return 0 || return 1; } | |
function screenIsUnlocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" != "true" ] && return 0 || return 1; } | |
if screenIsLocked; then | |
echo "Screen locked" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#kcpasswordDecode (20220729) Copyright (c) 2021 Joel Bruner (https://github.com/brunerd) | |
#Licensed under the MIT License | |
#specify file as input | |
#kcpasswordDecode.sh /etc/kcpassword | |
#given a filepath XOR to the it back and truncate padding | |
function kcpasswordDecode() ( | |
filepath="${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#kcpasswordEncode (20220610) 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 | |
thisString="${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Joel Bruner - EA Grabber: Surreptitiously grabs Jamf Extension Attributes (EAs) during recon | |
#touch file for debug | |
[ -f /tmp/debug ] && set -x | |
############# | |
# VARIABLES # | |
############# |
NewerOlder