Repository: jgamblin/Blackhat-MacOS-Config Branch: master Commit: 122992651baf Files: 4 Total size: 4.6 KB Directory structure: gitextract_flgkxal6/ ├── .gitattributes ├── LICENSE ├── README.md └── blackhat-macos-config.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 Jerry Gamblin 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 copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Black Hat macOS Config A simple shell script to configure your Mac to some of the most commonly recommended settings for the world's most dangerous hacking conferences (Black Hat/Defcon) or every day life. **Warning:** Tool does not ask before making changes. ## What It Does: - Deletes Saved Wireless Networks. - ~~Disable Wireless Network Auto Join.~~ < This cant be done programmatically. `¯\_(ツ)_/¯` - Require Password Immediately After Sleep - Turns On Firewall. - Enables Stealth Mode - Installs Needed System Updates. - Validates System Integrity Protection is enabled. - Enables Full Disk Encryption. Note: Script Will Prompt For Password If Not Root. ## Usage: - Review for your preferences and comment out options **You** don't want. - Set `homessid` and `workssid` variable to stop from deleting those! To Run: ``` chmod +x blackhat-macos-config.sh ./blackhat-macos-config.sh ``` ## Important Notice I likely don't know what I am doing and this could be done faster, better and simpler some other way. These scripts could also break your MacBook and make you cry. ================================================ FILE: blackhat-macos-config.sh ================================================ #!/bin/bash homessid="AddMe" workssid="AddMe" SECONDS=0 RED='\033[0;31m' NC='\033[0m' #Check if running as root and if not elevate sudo -nv 2>>/dev/null if [ $? -ne 0 ]; then printf "Black Hat macOS Config requires root access.\n" printf "Please enter your password, or run 'sudo -v' first.\n" sudo -v #Validate we can sudo now if [ $? -ne 0 ]; then printf "\n" printf "Still not root. Exiting.\n" exit fi printf "\n" fi #Delete Saved SSIDs For Security #Be Sure To Set Home And Work SSID for ease of use. printf "Deleting saved Wi-Fi networks.\n" IFS=$'\n' for ssid in $(networksetup -listpreferredwirelessnetworks en0 | grep -v "Preferred networks on en0:" | grep -v $homessid | grep -v $workssid | sed "s/[\ ]//g") do networksetup -removepreferredwirelessnetwork en0 "$ssid" > /dev/null 2>&1 done #Enable Password Login: printf "Require Password Immediately After Sleep or Screen Saver Begins.\n" defaults write com.apple.screensaver askForPassword 1 > /dev/null 2>&1 defaults write com.apple.screensaver askForPasswordDelay 0 > /dev/null 2>&1 #Enable Firewall: printf "Enabling Firewall.\n" #This is a more "open" firewall config #https://discussions.apple.com/thread/3148672 defaults write /Library/Preferences/com.apple.alf globalstate 1 > /dev/null 2>&1 #This is a more "strict" firewall config #defaults write /Library/Preferences/com.apple.alf globalstate 2 > /dev/null 2>&1 printf "Enabling Stealth Firewall Mode.\n" defaults write /Library/Preferences/com.apple.alf stealthenabled 1 > /dev/null 2>&1 #Install Updates. printf "Installing needed updates.\n" softwareupdate -i -a > /dev/null 2>&1 #Check if System Integrity Protection is enabled printf "Verifying System Integrity Protection (SIP) is enabled.\n" csrutil=$(csrutil status) if [[ $csrutil = *"disabled"* ]]; then printf "${RED}WARNING: System Integrity Protection is disabled!${NC}\n" printf "To enable, you must boot into recovery mode and enable:\n" printf " - restart\n" printf " - during bootup, hold Cmd+R\n" printf " - click Utilities->Terminal\n" printf " - run: csrutil enable\n" printf " - run: reboot # to get back into standard macOS\n" fi #Enabling Firevault: printf "Enabling FDE.\n" fdesetup enable > /dev/null 2>&1 #Finishing Up. timed="$((SECONDS / 3600)) Hours $(((SECONDS / 60) % 60)) Minutes $((SECONDS % 60)) seconds" printf "It took %s to help get your Mac ready for Black Hat.\n" "$timed"