mirror of
https://github.com/sunknudsen/privacy-guides.git
synced 2025-02-22 16:53:56 +00:00
Standardized script syntax
This commit is contained in:
parent
8b4def74ec
commit
78ee1e0e3b
@ -265,8 +265,8 @@ cat << EOF > /usr/local/bin/check.sh
|
||||
|
||||
set -e
|
||||
|
||||
red=$'\e[1;31m'
|
||||
nc=$'\e[0m'
|
||||
red=\$(tput setaf 1)
|
||||
normal=\$(tput sgr0)
|
||||
|
||||
printf "Backup hash: "
|
||||
|
||||
@ -275,7 +275,7 @@ read -r previous
|
||||
current=\$(openssl dgst -sha512 "$BACKUP_VOLUME_PATH")
|
||||
|
||||
if [ "\$current" != "\$previous" ]; then
|
||||
printf "\${red}%s\${nc}\n" "Integrity check failed"
|
||||
printf "\$red%s\$normal\n" "Integrity check failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -18,7 +18,7 @@ Listed: true
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /usr/local/bin
|
||||
sudo chown ${USER}:admin /usr/local/bin
|
||||
sudo chown ${USER}:staff /usr/local/bin
|
||||
```
|
||||
|
||||
### Step 2: download [app-cleaner.sh](./app-cleaner.sh) ([PGP signature](./app-cleaner.sh.sig), [PGP public key](https://sunknudsen.com/sunknudsen.asc))
|
||||
@ -36,13 +36,13 @@ chmod +x /usr/local/bin/app-cleaner.sh
|
||||
|
||||
```console
|
||||
$ app-cleaner.sh /Applications/AppCleaner.app
|
||||
Checking for running processes...
|
||||
Finding application data...
|
||||
Checking for running processes…
|
||||
Finding application data…
|
||||
/Applications/AppCleaner.app
|
||||
/Users/sunknudsen/Library/Preferences/net.freemacsoft.AppCleaner.plist
|
||||
/Users/sunknudsen/Library/Saved Application State/net.freemacsoft.AppCleaner.savedState
|
||||
Move application data to trash (y or n)? y
|
||||
Moving application data to trash...
|
||||
Moving application data to trash…
|
||||
Done
|
||||
```
|
||||
|
||||
|
@ -7,8 +7,8 @@ fi
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
red=$'\e[1;31m'
|
||||
nc=$'\e[0m'
|
||||
red=$(tput setaf 1)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
if [ ! -e "$1/Contents/Info.plist" ]; then
|
||||
printf "%s\n" "Cannot find app plist"
|
||||
@ -31,7 +31,7 @@ processes=($(pgrep -afil "$app_name" | grep -v "app-cleaner.sh"))
|
||||
|
||||
if [ ${#processes[@]} -gt 0 ]; then
|
||||
printf "%s\n" "${processes[@]}"
|
||||
printf "${red}%s${nc}" "Kill running processes (y or n)? "
|
||||
printf "$red%s$normal" "Kill running processes (y or n)? "
|
||||
read -r answer
|
||||
if [ "$answer" = "y" ]; then
|
||||
printf "%s\n" "Killing running processes…"
|
||||
@ -113,7 +113,7 @@ paths=($(printf "%s\n" "${paths[@]}" | sort -u));
|
||||
|
||||
printf "%s\n" "${paths[@]}"
|
||||
|
||||
printf "${red}%s${nc}" "Move app data to trash (y or n)? "
|
||||
printf "$red%s$normal" "Move app data to trash (y or n)? "
|
||||
read -r answer
|
||||
if [ "$answer" = "y" ]; then
|
||||
printf "%s\n" "Moving app data to trash…"
|
||||
|
@ -256,7 +256,7 @@ sudo pfctl -F all -f /etc/pf.conf
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /usr/local/sbin
|
||||
sudo chown $USER:admin /usr/local/sbin
|
||||
sudo chown ${USER}:admin /usr/local/sbin
|
||||
```
|
||||
|
||||
### Step 11: source `/usr/local/sbin` folder
|
||||
@ -294,8 +294,8 @@ if [ "$(id -u)" != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
green=$'\e[1;32m'
|
||||
nc=$'\e[0m'
|
||||
green=$(tput setaf 2)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
# /usr/libexec/ApplicationFirewall/socketfilterfw --blockapp /Applications/1Password\ 7.app
|
||||
# /usr/libexec/ApplicationFirewall/socketfilterfw --blockapp /usr/local/Cellar/squid/4.8/sbin/squid
|
||||
@ -309,7 +309,7 @@ printf "\n"
|
||||
|
||||
pfctl -F all -f /etc/pf.conf
|
||||
|
||||
printf "\n${green}%s${nc}\n" "Strict mode enabled"
|
||||
printf "\n$green%s$normal\n" "Strict mode enabled"
|
||||
EOF
|
||||
chmod +x /usr/local/sbin/strict.sh
|
||||
```
|
||||
@ -335,8 +335,8 @@ function disable()
|
||||
|
||||
trap disable INT
|
||||
|
||||
red=$'\e[1;31m'
|
||||
nc=$'\e[0m'
|
||||
red=$(tput setaf 1)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
# /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /Applications/1Password\ 7.app
|
||||
# /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /usr/local/Cellar/squid/4.8/sbin/squid
|
||||
@ -350,7 +350,7 @@ printf "\n"
|
||||
|
||||
pfctl -F all -f /etc/pf.conf
|
||||
|
||||
printf "\n${red}%s${nc}\n\n" "Trusted mode enabled (press ctrl+c to disable)"
|
||||
printf "\n$red%s$normal\n\n" "Trusted mode enabled (press ctrl+c to disable)"
|
||||
|
||||
while :
|
||||
do
|
||||
@ -379,12 +379,12 @@ function disable()
|
||||
|
||||
trap disable INT
|
||||
|
||||
red=$'\e[1;31m'
|
||||
nc=$'\e[0m'
|
||||
red=$(tput setaf 1)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
pfctl -d
|
||||
|
||||
printf "\n${red}%s${nc}\n\n" "Firewall disabled (press ctrl+c to enable)"
|
||||
printf "\n$red%s$normal\n\n" "Firewall disabled (press ctrl+c to enable)"
|
||||
|
||||
while :
|
||||
do
|
||||
|
@ -246,7 +246,7 @@ Insert micro SD card into macOS computer, run following and eject card.
|
||||
|
||||
```shell
|
||||
volume_path="/Volumes/boot"
|
||||
volume_uuid=`diskutil info "$volume_path" | awk '/Volume UUID:/ { print $3 }'`
|
||||
volume_uuid=$(diskutil info "$volume_path" | awk '/Volume UUID:/ { print $3 }')
|
||||
echo "UUID=$volume_uuid none msdos rw,noauto" | sudo tee -a /etc/fstab
|
||||
```
|
||||
|
||||
|
@ -83,13 +83,13 @@ cat << "EOF" >> ~/.zshrc
|
||||
# Kill apps that match string
|
||||
function kill-apps() {
|
||||
IFS=$'\n'
|
||||
red=$'\e[1;31m'
|
||||
nc=$'\e[0m'
|
||||
red=$(tput setaf 1)
|
||||
normal=$(tput sgr0)
|
||||
if [ -z "$1" ]; then
|
||||
printf "%s\n" "Usage: kill-apps string"
|
||||
return 1
|
||||
fi
|
||||
printf "%s\n" "Finding apps that match \"$1\"..."
|
||||
printf "%s\n" "Finding apps that match \"$1\"…"
|
||||
sleep 1
|
||||
processes=($(pgrep -afil "$1"))
|
||||
if [ ${#processes[@]} -eq 0 ]; then
|
||||
@ -97,10 +97,10 @@ function kill-apps() {
|
||||
return 0
|
||||
else
|
||||
printf "%s\n" "${processes[@]}"
|
||||
printf "${red}%s${nc}" "Kill found apps (y or n)? "
|
||||
printf "$red%s$normal" "Kill found apps (y or n)? "
|
||||
read -r answer
|
||||
if [ "$answer" = "y" ]; then
|
||||
printf "%s\n" "Killing found apps..."
|
||||
printf "%s\n" "Killing found apps…"
|
||||
sleep 1
|
||||
for process in "${processes[@]}"; do
|
||||
echo $process | awk '{print $1}' | xargs sudo kill 2>&1 | grep -v "No such process"
|
||||
@ -122,7 +122,7 @@ source ~/.zshrc
|
||||
|
||||
```console
|
||||
$ kill-apps adobe
|
||||
Finding apps that match "adobe"...
|
||||
Finding apps that match "adobe"…
|
||||
46639 /Library/Application Support/Adobe/Adobe Desktop Common/IPCBox/AdobeIPCBroker.app/Contents/MacOS/AdobeIPCBroker -launchedbyvulcan /Applications/Adobe Premiere Pro 2020/Adobe Premiere Pro 2020.app/Contents/MacOS/Adobe Premiere Pro 2020
|
||||
46645 /Library/Application Support/Adobe/Creative Cloud Libraries/CCLibrary.app/Contents/MacOS/../libs/node /Library/Application Support/Adobe/Creative Cloud Libraries/CCLibrary.app/Contents/MacOS/../js/server.js
|
||||
46653 /Applications/Utilities/Adobe Creative Cloud Experience/CCXProcess/CCXProcess.app/Contents/MacOS/../libs/Adobe_CCXProcess.node /Applications/Utilities/Adobe Creative Cloud Experience/CCXProcess/CCXProcess.app/Contents/MacOS/../js/main.js
|
||||
|
@ -65,19 +65,19 @@ export LC_CTYPE=C
|
||||
basedir=$(dirname "$0")
|
||||
|
||||
# Spoof computer name
|
||||
first_name=`sed "$(jot -r 1 1 2048)q;d" $basedir/first-names.txt | sed -e 's/[^a-zA-Z]//g'`
|
||||
model_name=`system_profiler SPHardwareDataType | awk '/Model Name/ {$1=$2=""; print $0}' | sed -e 's/^[ ]*//'`
|
||||
first_name=$(sed "$(jot -r 1 1 2048)q;d" $basedir/first-names.txt | sed -e 's/[^a-zA-Z]//g')
|
||||
model_name=$(system_profiler SPHardwareDataType | awk '/Model Name/ {$1=$2=""; print $0}' | sed -e 's/^[ ]*//')
|
||||
computer_name="$first_name’s $model_name"
|
||||
host_name=`echo $computer_name | sed -e 's/’//g' | sed -e 's/ /-/g'`
|
||||
host_name=$(echo $computer_name | sed -e 's/’//g' | sed -e 's/ /-/g')
|
||||
sudo scutil --set ComputerName "$computer_name"
|
||||
sudo scutil --set LocalHostName "$host_name"
|
||||
sudo scutil --set HostName "$host_name"
|
||||
printf "%s\n" "Spoofed hostname to $host_name"
|
||||
|
||||
# Spoof MAC address of en0 interface
|
||||
mac_address_prefix=`sed "$(jot -r 1 1 768)q;d" $basedir/mac-address-prefixes.txt | sed -e 's/[^A-F0-9:]//g'`
|
||||
mac_address_suffix=`openssl rand -hex 3 | sed 's/\(..\)/\1:/g; s/.$//'`
|
||||
mac_address=`echo "$mac_address_prefix:$mac_address_suffix" | awk '{print toupper($0)}'`
|
||||
mac_address_prefix=$(sed "$(jot -r 1 1 768)q;d" $basedir/mac-address-prefixes.txt | sed -e 's/[^A-F0-9:]//g')
|
||||
mac_address_suffix=$(openssl rand -hex 3 | sed 's/\(..\)/\1:/g; s/.$//')
|
||||
mac_address=$(echo "$mac_address_prefix:$mac_address_suffix" | awk '{print toupper($0)}')
|
||||
sudo ifconfig en0 ether "$mac_address"
|
||||
printf "%s\n" "Spoofed MAC address of en0 interface to $mac_address"
|
||||
EOF
|
||||
|
Loading…
x
Reference in New Issue
Block a user