Skip to content

Instantly share code, notes, and snippets.

@cobaohieu
Last active December 12, 2024 11:58
Show Gist options
  • Save cobaohieu/96d7f8b04774c01367dd80b68a01a651 to your computer and use it in GitHub Desktop.
Save cobaohieu/96d7f8b04774c01367dd80b68a01a651 to your computer and use it in GitHub Desktop.
Turn off MDM on Macbook OS 11.X Big Sur to now

mdm-screen

Prerequisites ⚠️

  • It is advised to erase the hard-drive prior to starting.
  • It is advised to re-install MacOS using an external flash drive.
  • Device language needs to be set to English, it can be changed afterwards.

Follow steps below to bypass MDM setup during a fresh installation of MacOS

Upon arriving to the setup stage of forced MDM enrollement:

Method 1: By pass MDM on Recovery Mac

  1. Long press Power button to forcefully shut down your Mac.

  2. Hold the power button to start your Mac & boot into recovery mode.

a. Apple-based Mac: Hold Power button.
b. Intel-based Mac: Hold CMD + R during boot.

  1. Connect to WiFi to activate your Mac.

  2. Enter Recovery Mode & Open Safari.

  3. Navigate to https://bit.ly/bypass-mdm

  4. Copy the script below:

sudo /bin/bash -c "$(curl -fsSL https://bit.ly/bypass-mdm)"
# or 
curl https://bit.ly/bypass-mdm -o bypass-mdm.sh && chmod +x ./bypass-mdm.sh && ./bypass-mdm.sh
  1. Launch Terminal (Utilities > Terminal).

  2. Paste (CMD + V) and Run the script (ENTER).

  3. Input 1 for Autobypass.

  4. Press Enter to leave the default username 'macbook'.

  5. Press Enter to leave the default password '1234'.

  6. Wait for the script to finish & Reboot your Mac.

  7. Sign in with user (Apple) & password (1234)

  8. Skip all setup (Apple ID, Siri, Touch ID, Location Services)

  9. Once on the desktop navigate to System Settings > Users and Groups, and create your real Admin account.

  10. Log out of the Apple profile, and sign in into your real profile.

  11. Feel free set up properly now (Apple ID, Siri, Touch ID, Location Services).

  12. Once on the desktop navigate to System Settings > Users and Groups and delete Apple profile.

  13. Congratulations, you're MDM free! 💫

Method 2: By pass MDM using Terminal At macOS Setup Assistant | Tested on OpenCore Legacy Patcher install macOS

  1. Install macOS newest

a. Install onunspupported Mac: Please follow the link on Youtube here b. Install on spupported Mac: Please go the normal install mac OS like the link on Youtube here

  1. Please wait for macOS setup show the final config account or select Wi-Fi to connect the internet.

  2. Press (CTL + OPTION + CMD + T) to open Terminal

(view-terminal)[https://chris-collins.io/2018/03/15/Using-Terminal-At-macOS-Setup-Assistant/betasoftwareupdate.jpg]

a. Using the online script: Connect Wi-Fi then type and run the script below:

/bin/bash -c "$(curl -fsSL https://bit.ly/bypass-mdm)"
# or 
curl https://bit.ly/bypass-mdm -o bypass-mdm.sh && chmod +x ./bypass-mdm.sh && ./bypass-mdm.sh

b. Using the offline script: Open Safari and access the link https://bit.ly/bypass-mdm then save the script on the Setup USB/Partition. Press (CTL + OPTION + CMD + T) to open Terminal and run the script below:

chmod +x ./bypass-mdm.sh && ./bypass-mdm.sh
  1. Wait for the script to finish. Exit Terminal then continue with the setup (Apple ID, Siri, Touch ID, Location Services)

  2. Congratulations, you're MDM free! 💫

Although it's virtually impossible to catch that you've removed the MDM (because it wasn't even configured), be aware that the serial number of the laptop will still be shown in the inventory system of your company. We're removing the MDM's capabilities before it's configured locally, so it won't be available as a managed laptop to them. Use with caution. Probably a good idea to have a valid excuse as well.
Thanks to

Assaf Dori

#!/bin/bash
# Run command
# sudo /bin/bash -c "$(curl -fsSL https://bit.ly/fix-mdm)"
# or
# curl https://bit.ly/bypass-mdm -o bypass-mdm.sh && chmod +x ./bypass-mdm.sh && ./bypass-mdm.sh
#
echo ""
echo -e "Bypass MDM"
echo ""
echo -e "Bypass on Recovery"
if [ -d "/Volumes/Macintosh HD - Data" ]; then
diskutil rename "Macintosh HD - Data" "Data"
fi
if [ -d "/Volumes/Macintosh HD - Dữ liệu" ]; then
diskutil rename "Macintosh HD - Data" "Data"
fi
echo -e "Username default: macbook, password: 1234"
realName="${realName:=Macbook}"
username="${username:=macbook}"
passw="${passw:=1234}"
dscl_path='/Volumes/Data/private/var/db/dslocal/nodes/Default'
echo -e "Creating user ..."
# Create user
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username"
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" UserShell "/bin/zsh"
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" RealName "$realName"
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" RealName "$realName"
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" UniqueID "501"
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" PrimaryGroupID "20"
mkdir "/Volumes/Data/Users/$username"
dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" NFSHomeDirectory "/Users/$username"
dscl -f "$dscl_path" localhost -passwd "/Local/Default/Users/$username" "$passw"
dscl -f "$dscl_path" localhost -append "/Local/Default/Groups/admin" GroupMembership $username
echo "By pass hosts"
echo "0.0.0.0 deviceenrollment.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
echo "0.0.0.0 mdmenrollment.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
echo "0.0.0.0 iprofiles.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
echo "0.0.0.0 gdmf.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
echo -e "Successfully blocked MDM & Profile Domains on host"
echo "Remove config profile"
touch /Volumes/Data/private/var/db/.AppleSetupDone
csrutil disable
rm -rf /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigHasActivationRecord
rm -rf /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordFound
touch /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigProfileInstalled
touch /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordNotFound
sudo profiles remove -all
echo "Disable Notification (SIP) SIP"
rm /var/db/ConfigurationProfiles/Settings/.cloudConfigHasActivationRecord
rm /var/db/ConfigurationProfiles/Settings/.cloudConfigRecordFound
touch /var/db/ConfigurationProfiles/Settings/.cloudConfigProfileInstalled
touch /var/db/ConfigurationProfiles/Settings/.cloudConfigRecordNotFound
launchctl disable system/com.apple.ManagedClient.enroll
echo "Disable Notification (Recovery)"
rm -rf /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigHasActivationRecord
rm -rf /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordFound
touch /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigProfileInstalled
touch /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordNotFound
echo "Verify the DEP status. Error is success"
profiles show -type enrollment
profiles status -type enrollment
echo -e "MDM enrollment has been bypassed!"
echo -e "Exit terminal and reboot your Mac."
reboot
echo "----------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment