feat: structured logging, CLI aliases, comprehensive README
- Rewrite colors.sh with proper log levels ([INF], [ OK], [WRN], etc.) - Add timestamps, --verbose debug mode, --log-file support - Add begin()/end_ok()/end_fail() progress bar helpers - Add command aliases (by, sv, st, fw, wl, mn, etc.) - Rewrite help with categorized command listing - Write comprehensive README covering every command, layer, scenario - All syntax verified with bash -n
This commit is contained in:
@@ -1,100 +1,483 @@
|
|||||||
# unleash
|
# unleash
|
||||||
|
|
||||||
Single-script MDM bypass for macOS. Works from Recovery mode. Apple Silicon and Intel.
|
Single-script MDM bypass for macOS. Works from Recovery mode on Apple Silicon and Intel.
|
||||||
|
|
||||||
|
I started this because the original bypass-mdm project had five different scripts (v2, v3, express, dualboot.sh, verify.sh), each with slightly different options and none of them handling the full problem after Migration Assistant. This replaces all of them in one file.
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
1. Copy the unleash folder to an external SSD (FAT32/APFS/exFAT)
|
1. Copy the `unleash` folder to an external SSD (FAT32, APFS, or exFAT)
|
||||||
2. Boot to Recovery (hold Power on AS, Cmd+R on Intel)
|
2. Boot to Recovery:
|
||||||
3. Open Terminal from Utilities, then:
|
- **Apple Silicon**: hold the power button until you see "Loading Startup Options", then click Options → Continue
|
||||||
|
- **Intel**: Cmd+R at the startup chime
|
||||||
|
3. Open Terminal from the Utilities menu
|
||||||
|
4. Run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
chmod +x "/Volumes/YourSSD/unleash/unleash"
|
chmod +x "/Volumes/YourSSD/unleash/unleash"
|
||||||
|
"/Volumes/YourSSD/unleash/unleash"
|
||||||
|
```
|
||||||
|
|
||||||
|
Pick "Full bypass" from the menu. Or if you know what you want:
|
||||||
|
|
||||||
|
```bash
|
||||||
"/Volumes/YourSSD/unleash/unleash" bypass
|
"/Volumes/YourSSD/unleash/unleash" bypass
|
||||||
```
|
```
|
||||||
|
|
||||||
No internet needed if running from an SSD. No SIP to disable.
|
No internet needed. No SIP to disable. No typing long URLs.
|
||||||
|
|
||||||
|
If you do have internet in Recovery:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -L https://raw.githubusercontent.com/mateussiqueira/unleash/main/unleash -o /tmp/unleash
|
||||||
|
chmod +x /tmp/unleash && /tmp/unleash bypass
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
| Command | What it does |
|
### bypass — Full MDM bypass (Recovery only)
|
||||||
|---------|-------------|
|
|
||||||
| `bypass` | Full bypass — creates admin user + suppresses MDM |
|
|
||||||
| `suppress` | Silence enrollment, no user created |
|
|
||||||
| `heal` | Check + re-apply suppression after updates |
|
|
||||||
| `persist` | Install LaunchDaemon so heal runs on every boot |
|
|
||||||
| `unpersist` | Remove the boot-time LaunchDaemon |
|
|
||||||
| `firewall` | Block Apple MDM IPs at kernel level via pf (blocks iCloud too) |
|
|
||||||
| `firewall-off` | Remove the pf block |
|
|
||||||
| `whitelist` | Block only MDM endpoints, keep iCloud/App Store |
|
|
||||||
| `harden` | Kill MDM processes, remove profiles, flush DNS |
|
|
||||||
| `audit` | Deep system scan + risk assessment |
|
|
||||||
| `backup` | Save current hosts, profiles, launchd state |
|
|
||||||
| `restore` | Revert from backup |
|
|
||||||
| `dualboot` | Target an external macOS install |
|
|
||||||
| `check` | Pre-format report: will this Mac lock after a wipe? |
|
|
||||||
| `monitor` | Background daemon that watches MDM state and auto-heals |
|
|
||||||
| `monitor-stop` | Stop the background monitor |
|
|
||||||
| `monitor-status` | Check if monitor is running |
|
|
||||||
|
|
||||||
Just `./unleash` with no argument shows an interactive menu.
|
|
||||||
|
|
||||||
### Monitor
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo ./unleash monitor
|
./unleash bypass
|
||||||
```
|
```
|
||||||
|
|
||||||
Runs in the background and checks MDM state every 5 minutes. If MDM tries to re-enroll, it auto-heals and sends a macOS notification. Survives reboots only if combined with `unleash persist` (which can run the monitor instead of heal). Logs to `/var/log/unleash-monitor.log`.
|
Creates a temporary admin account and suppresses MDM. What it does:
|
||||||
|
|
||||||
### Check
|
1. Finds and mounts the macOS Data volume
|
||||||
|
2. Unlocks FileVault if needed (asks for password)
|
||||||
|
3. Creates an admin user (default Apple / 1234)
|
||||||
|
4. Removes DEP activation records
|
||||||
|
5. Blocks 13+ Apple MDM domains plus your org's MDM host
|
||||||
|
6. Disables 4 enrollment daemons
|
||||||
|
7. Cleans user-level MDM artifacts from all home directories
|
||||||
|
8. Sets .AppleSetupDone so Setup Assistant is skipped
|
||||||
|
|
||||||
|
### suppress — Silence enrollment, no user
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./unleash suppress
|
||||||
|
```
|
||||||
|
|
||||||
|
Same as bypass minus the user creation. Useful after a clean bypass breaks from a macOS update.
|
||||||
|
|
||||||
|
### heal — Check and re-apply
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash heal # from booted system
|
||||||
|
./unleash heal # from Recovery
|
||||||
|
```
|
||||||
|
|
||||||
|
Checks if suppression is still intact. If any piece (DEP markers, hosts block, daemon disable) has been reset, it re-applies it. Safe to run repeatedly.
|
||||||
|
|
||||||
|
### persist — Boot-time auto-heal
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash persist
|
||||||
|
```
|
||||||
|
|
||||||
|
Installs a LaunchDaemon at `/Library/LaunchDaemons/com.unleash.heal.plist` that runs `unleash heal` on every boot and every 24 hours after that. Logs go to `/var/log/unleash-heal.log`.
|
||||||
|
|
||||||
|
Use this before a macOS upgrade. When the update finishes and reboots, heal runs automatically and re-applies anything the update reset.
|
||||||
|
|
||||||
|
### unpersist — Remove auto-heal
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash unpersist
|
||||||
|
```
|
||||||
|
|
||||||
|
Removes the LaunchDaemon and unloads it.
|
||||||
|
|
||||||
|
### firewall — Kernel-level MDM block
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash firewall
|
||||||
|
```
|
||||||
|
|
||||||
|
Creates pf firewall rules that drop traffic to Apple's MDM IP ranges (17.0.0.0/8 and 17.128.0.0/10). pf works below DNS — DNS-over-HTTPS cannot bypass it.
|
||||||
|
|
||||||
|
**Warning**: this blocks all Apple services. iCloud, App Store, and system updates will not work while the firewall is active. Use `whitelist` instead if you need those.
|
||||||
|
|
||||||
|
### firewall-off — Remove firewall
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash firewall-off
|
||||||
|
```
|
||||||
|
|
||||||
|
Flushes the Unleash pf anchor and restores pf.conf.
|
||||||
|
|
||||||
|
### whitelist — Block only MDM, keep iCloud
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash whitelist
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternative to `firewall` that resolves only the essential MDM domains (mdmenrollment.apple.com, deviceenrollment.apple.com, iprofiles.apple.com) to IPs and blocks those, leaving everything else untouched. iCloud, App Store, and updates should work normally.
|
||||||
|
|
||||||
|
### harden — Live cleanup from booted system
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash harden
|
||||||
|
```
|
||||||
|
|
||||||
|
Runs from the logged-in desktop after bypass. Does:
|
||||||
|
|
||||||
|
1. Kills ManagedClient, mdmclient, activationd
|
||||||
|
2. Forces profile removal
|
||||||
|
3. Scans and removes MDM LaunchAgents per user
|
||||||
|
4. Flushes DNS cache, restarts mDNSResponder
|
||||||
|
5. Checks keychain for MDM identity certs
|
||||||
|
6. Looks for JAMF/Intune/Workspace ONE agents
|
||||||
|
7. Disables iCloud Private Relay (a DoH loophole)
|
||||||
|
|
||||||
|
### audit — Deep system scan
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash audit
|
||||||
|
```
|
||||||
|
|
||||||
|
Comprehensive scan that checks: installed profiles, enrollment state, keychain certificates, user LaunchAgents, system LaunchDaemons, running processes, MDM agent binaries, pf firewall status. Ends with a risk score (LOW / MEDIUM / HIGH / CRITICAL).
|
||||||
|
|
||||||
|
### status — MDM health check (Recovery only)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./unleash status
|
||||||
|
```
|
||||||
|
|
||||||
|
Shows DEP markers, hosts block, daemon overrides, profile enrollment, and backup status. Only works from Recovery because that's where the Data volume is cleanly accessible.
|
||||||
|
|
||||||
|
### check — Pre-format / pre-upgrade assessment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo ./unleash check
|
sudo ./unleash check
|
||||||
```
|
```
|
||||||
|
|
||||||
Answers one question: **"If I wipe this Mac, will it lock?"** Checks DEP records, profiles, enrollment state, firewall, and persistence. Also checks if a macOS upgrade is safe.
|
Answers: **"If I wipe this Mac, will it lock?"** Checks DEP records, profiles, enrollment state, firewall, and persistence. Also does an upgrade safety check — tells you if `persist` and `firewall` are installed before you upgrade macOS.
|
||||||
|
|
||||||
|
Returns one of two verdicts:
|
||||||
|
|
||||||
|
- **SAFE TO FORMAT** — no MDM enrollment detected
|
||||||
|
- **MDM DETECTED** — this Mac will lock after a wipe. Run bypass from Recovery afterward.
|
||||||
|
|
||||||
|
### monitor — Background MDM watcher
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
Starts a daemon that checks MDM state every 5 minutes. If it detects MDM trying to re-enroll (DEP record appears, hosts block missing, enrollment becomes active), it auto-heals and sends a macOS notification.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash monitor-stop # stop it
|
||||||
|
sudo ./unleash monitor-status # check if it's running
|
||||||
|
```
|
||||||
|
|
||||||
|
Logs everything to `/var/log/unleash-monitor.log`. The daemon does not survive a reboot on its own — combine with `persist` for persistence.
|
||||||
|
|
||||||
|
### backup / restore — State save
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./unleash backup
|
||||||
|
./unleash restore
|
||||||
|
```
|
||||||
|
|
||||||
|
Backup saves hosts, config profiles, and launchd override to `.unleash-backup/`. Restore reverts them.
|
||||||
|
|
||||||
|
### dualboot — External volume target
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./unleash dualboot
|
||||||
|
```
|
||||||
|
|
||||||
|
Same as bypass but lets you pick which volume to target (for external macOS installs or dual-boot setups). Prompts for system and data volume names.
|
||||||
|
|
||||||
|
### version / help
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./unleash version
|
||||||
|
./unleash help
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
Every command has a shorter alias:
|
||||||
|
|
||||||
|
| Alias | Full command |
|
||||||
|
|-------|-------------|
|
||||||
|
| `by` | bypass |
|
||||||
|
| `sv` | suppress |
|
||||||
|
| `st`, `ls` | status |
|
||||||
|
| `fw` | firewall |
|
||||||
|
| `fw-off` | firewall-off |
|
||||||
|
| `wl` | whitelist |
|
||||||
|
| `mn` | monitor |
|
||||||
|
| `mn-stop` | monitor-stop |
|
||||||
|
| `mn-st` | monitor-status |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
Global options that can go before any command:
|
||||||
|
|
||||||
|
| Option | Effect |
|
||||||
|
|--------|--------|
|
||||||
|
| `--verbose` | Show debug messages |
|
||||||
|
| `--log-file <path>` | Write log output to file |
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```bash
|
||||||
|
sudo ./unleash --verbose --log-file /tmp/unleash.log heal
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
MDM enrollment sits on four layers. Unleash hits all of them:
|
MDM enrollment on macOS sits on four layers. Unleash addresses each one.
|
||||||
|
|
||||||
1. **DEP markers** — `/private/var/db/ConfigurationProfiles/Settings/.cloudConfig*` files. Remove them, set decoy files.
|
### Layer 1: DEP activation record
|
||||||
2. **Network** — `/etc/hosts` blocks 13+ Apple MDM domains plus the org MDM host.
|
|
||||||
3. **Launchd daemons** — disable `ManagedClient.enroll`, `ManagedClient.cloudConfiguration`, `mdmclient.daemon.runatboot`, `activationd`.
|
|
||||||
4. **User artifacts** — clean per-user MDM prefs, caches, LaunchAgents from `/Users/*/Library`.
|
|
||||||
|
|
||||||
The pf firewall layer (commands `firewall`/`whitelist`) catches what `/etc/hosts` misses — especially DNS-over-HTTPS bypass.
|
When an organization assigns a device in Apple Business Manager, macOS creates marker files at:
|
||||||
|
|
||||||
## Why not bypass-mdm?
|
```
|
||||||
|
/private/var/db/ConfigurationProfiles/Settings/
|
||||||
|
.cloudConfigHasActivationRecord ← "this serial has DEP"
|
||||||
|
.cloudConfigRecordFound ← "enrollment was triggered"
|
||||||
|
.cloudConfigTimerCheck ← "check again later"
|
||||||
|
```
|
||||||
|
|
||||||
The original project grew into 5 scripts (v2, v3, express, dualboot.sh, verify.sh) with inconsistent CLI. Unleash replaces all of them in one script.
|
Unleash removes these and creates decoy files (`.cloudConfigRecordNotFound`, `.cloudConfigProfileInstalled`) that signal "no enrollment needed."
|
||||||
|
|
||||||
|
### Layer 2: Network blocking
|
||||||
|
|
||||||
|
The enrollment client contacts Apple servers to download the MDM profile. Without network access, it cannot complete enrollment.
|
||||||
|
|
||||||
|
Unleash blocks via `/etc/hosts`:
|
||||||
|
|
||||||
|
- `iprofiles.apple.com` — profile delivery
|
||||||
|
- `deviceenrollment.apple.com` — DEP service
|
||||||
|
- `mdmenrollment.apple.com` — MDM service
|
||||||
|
- `acmdm.apple.com` — Apple Configurator MDM
|
||||||
|
- `axm-adm-mdm.apple.com` — ACM enrollment
|
||||||
|
- `albert.apple.com` — ABM device assignment
|
||||||
|
- `gdmf.apple.com` — MDM framework
|
||||||
|
- `configuration.apple.com` — config service
|
||||||
|
- `xp.apple.com` — device management
|
||||||
|
- `gs.apple.com` — device enrollment
|
||||||
|
- `tb.apple.com` — device trust
|
||||||
|
- `vpp.itunes.apple.com` — volume purchase
|
||||||
|
- Your org's MDM host (extracted from the DEP record)
|
||||||
|
|
||||||
|
Both IPv4 (0.0.0.0) and IPv6 (::) entries are added.
|
||||||
|
|
||||||
|
### Layer 3: Launchd daemon override
|
||||||
|
|
||||||
|
macOS registers enrollment daemons that run at boot:
|
||||||
|
|
||||||
|
| Daemon | What it does |
|
||||||
|
|--------|-------------|
|
||||||
|
| `com.apple.ManagedClient.enroll` | Main enrollment |
|
||||||
|
| `com.apple.ManagedClient.cloudConfiguration` | Cloud config |
|
||||||
|
| `com.apple.mdmclient.daemon.runatboot` | MDM client |
|
||||||
|
| `com.apple.activationd` | Device activation |
|
||||||
|
|
||||||
|
Unleash disables them via the launchd override at `/private/var/db/com.apple.xpc.launchd/disabled.plist`.
|
||||||
|
|
||||||
|
### Layer 4: User-level cleanup
|
||||||
|
|
||||||
|
Home directories carry MDM artifacts that trigger re-enrollment after login:
|
||||||
|
|
||||||
|
```
|
||||||
|
~/Library/Preferences/com.apple.mdm.*
|
||||||
|
~/Library/Preferences/com.apple.ManagedClient.*
|
||||||
|
~/Library/Application Support/com.apple.ManagedClient*/
|
||||||
|
~/Library/LaunchAgents/com.apple.mdm.*
|
||||||
|
```
|
||||||
|
|
||||||
|
Unleash removes these from every home directory on the Data volume. This is the step most scripts miss — and the reason MDM comes back after Migration Assistant.
|
||||||
|
|
||||||
|
### Layer 5: pf firewall (optional)
|
||||||
|
|
||||||
|
The hosts file can be bypassed by DNS-over-HTTPS or cached DNS. pf (packet filter) operates at the kernel level and is immune to both. Unleash installs pf rules that either:
|
||||||
|
|
||||||
|
- **firewall**: blocks Apple's entire IP range (17.0.0.0/8 + 17.128.0.0/10) — aggressive but 100% effective
|
||||||
|
- **whitelist**: resolves only MDM domains to IPs and blocks those specifically — keeps iCloud working
|
||||||
|
|
||||||
## Intel vs Apple Silicon
|
## Intel vs Apple Silicon
|
||||||
|
|
||||||
Recovery entry differs (Cmd+R vs hold Power). On Apple Silicon the system volume is cryptographically signed (SSV) — all writes target the Data volume. Everything else is the same.
|
| | Intel T2 | Apple Silicon |
|
||||||
|
|---|---|---|
|
||||||
|
| Recovery | Cmd+R at boot | Hold power button |
|
||||||
|
| System volume | Writable with SIP disabled | Cryptographically signed (SSV) — read-only |
|
||||||
|
| FileVault unlock | diskutil apfs unlockVolume | Same, but needs user password or recovery key |
|
||||||
|
| Enrollment daemons | Fewer | activationd + cloudConfig |
|
||||||
|
| NVRAM flags | Some | More firmware-level flags |
|
||||||
|
| Migration Assistant | Less risky | **Carries MDM state** — see below |
|
||||||
|
|
||||||
|
On Apple Silicon, all writes target the Data volume. The system volume is never modified. SIP does not need to be disabled.
|
||||||
|
|
||||||
## Migration Assistant failure
|
## Migration Assistant failure
|
||||||
|
|
||||||
If you migrate from Intel to AS, MDM will come back after reboot because Migration Assistant copies user-level artifacts. The old suppress scripts miss these. Unleash cleans `/Users/*/Library` explicitly. If it still returns after that, run `harden` from the booted system.
|
This is the most common reason MDM comes back.
|
||||||
|
|
||||||
## Troubleshooting
|
When you migrate from an Intel Mac to Apple Silicon (or between AS Macs), Migration Assistant copies:
|
||||||
|
|
||||||
**MDM comes back after reboot** — run `unleash suppress` from Recovery again. If it's persistent, you probably have Migration Assistant artifacts. Run `unleash harden` after login.
|
- DEP activation records
|
||||||
|
- Enrolled configuration profiles
|
||||||
|
- User-level MDM preferences and caches
|
||||||
|
- Launch agents that re-trigger enrollment
|
||||||
|
- Keychain identity certificates
|
||||||
|
|
||||||
**profiles shows enrollment** — cosmetic. The SSV stores profile state read-only. Check DEP markers instead with `unleash status`.
|
The old bypass scripts only clean system-level artifacts (DEP markers, hosts, launchd). The user-level stuff gets copied over and re-establishes enrollment on every login.
|
||||||
|
|
||||||
**FileVault unlock fails** — you need a user password or the recovery key.
|
### Symptoms
|
||||||
|
|
||||||
**macOS update resets everything** — run `unleash heal`. If you ran `persist` before the update, it does this automatically.
|
- Remote Management screen appears after the first reboot
|
||||||
|
- Running suppress makes it go away temporarily
|
||||||
|
- MDM profile returns within about a minute of login
|
||||||
|
|
||||||
|
### Solution
|
||||||
|
|
||||||
|
**From Recovery**: run `unleash bypass` (or `suppress`). This cleans both system-level and user-level artifacts.
|
||||||
|
|
||||||
|
**If MDM still comes back**: boot normally, run `sudo ./unleash harden` immediately after login. This kills active MDM processes and removes profiles before they can re-establish.
|
||||||
|
|
||||||
|
**For prevention**: run `sudo ./unleash persist` and `sudo ./unleash whitelist` before Migration Assistant. The LaunchDaemon + pf rules survive the migration and catch anything that slips through.
|
||||||
|
|
||||||
|
## Hard lock: DFU / IPSW restore
|
||||||
|
|
||||||
|
If MDM is unbreakable — even from Recovery — the device may need a full firmware restore. This applies to Apple Silicon Macs only.
|
||||||
|
|
||||||
|
**You need**: a second Mac with Apple Configurator 2 (free from App Store), a USB-C cable, and the correct IPSW file for your Mac model.
|
||||||
|
|
||||||
|
**Steps**:
|
||||||
|
1. On the helper Mac, open Apple Configurator 2
|
||||||
|
2. Connect the locked Mac via USB-C while holding the power button
|
||||||
|
- M1/M2: hold power 10s, keep holding while connecting USB-C
|
||||||
|
- M3/M4: hold power + volume down 10s while connecting
|
||||||
|
3. The locked Mac appears as a DFU device in Configurator
|
||||||
|
4. Right-click → Advanced → Restore (pick the IPSW file)
|
||||||
|
5. Wait 10-30 minutes for restore to finish
|
||||||
|
6. Mac reboots to Setup Assistant — **do not connect to Wi-Fi**
|
||||||
|
7. Immediately boot to Recovery (hold power) and run `unleash bypass`
|
||||||
|
|
||||||
|
**This erases all data.** IPSW files are available at [ipsw.me](https://ipsw.me).
|
||||||
|
|
||||||
|
## Logging
|
||||||
|
|
||||||
|
All commands now log with timestamps and levels:
|
||||||
|
|
||||||
|
```
|
||||||
|
[INF] Data volume: /Volumes/Macintosh HD - Data
|
||||||
|
[ OK] Admin 'apple' created (UID 501)
|
||||||
|
[WRN] DEP activation record present
|
||||||
|
[ERR] Firewall needs sudo: sudo ./unleash firewall
|
||||||
|
[STP] Locating Data volume by APFS role...
|
||||||
|
[DBG] Checking pfctl availability
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `--verbose` to see debug messages and `--log-file <path>` to write everything to a file.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
```
|
||||||
|
unleash/
|
||||||
|
├── unleash # Main script (entry point)
|
||||||
|
├── lib/
|
||||||
|
│ ├── colors.sh # Logging, colors, prompts
|
||||||
|
│ ├── detect.sh # Recovery detection, volume mounting
|
||||||
|
│ ├── validate.sh # Username/password validation
|
||||||
|
│ ├── dscl.sh # Directory Services (user CRUD)
|
||||||
|
│ ├── suppress.sh # DEP removal, hosts, daemon disable
|
||||||
|
│ ├── backup.sh # Backup and restore
|
||||||
|
│ ├── status.sh # Health check and audit
|
||||||
|
│ ├── heal.sh # Auto-heal + LaunchDaemon persist
|
||||||
|
│ ├── firewall.sh # pf rules management
|
||||||
|
│ ├── harden.sh # Live-OS hardening
|
||||||
|
│ ├── whitelist.sh # Selective iCloud-safe block
|
||||||
|
│ ├── check.sh # Pre-format assessment
|
||||||
|
│ └── monitor.sh # Background MDM watcher
|
||||||
|
├── README.md
|
||||||
|
├── CONTRIBUTING.md
|
||||||
|
├── CODE_OF_CONDUCT.md
|
||||||
|
├── SECURITY.md
|
||||||
|
├── CHANGELOG.md
|
||||||
|
└── LICENSE (MIT)
|
||||||
|
```
|
||||||
|
|
||||||
|
The standalone variant (`unleash-standalone.sh`) bundles everything into one file. Build it with `bash examples/build-standalone.sh`.
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
- Your serial stays in Apple Business Manager. Only the organization can remove it.
|
- **Your serial stays in ABM.** Only the organization can remove it. If the device ever connects to the internet with all protections removed, it will re-enroll.
|
||||||
- A full wipe (erase install) clears the Data volume — you need to re-run from Recovery.
|
- **A full wipe requires re-running.** Clean installs clear the Data volume. Boot to Recovery and run bypass again afterward.
|
||||||
- The hosts block can be bypassed by cached DNS or DoH. pf firewall fixes this.
|
- **macOS updates can reset daemons.** Always run `persist` before an update so `heal` runs automatically after.
|
||||||
- If your org uses hardware-based enrollment (DEP + ABM + device lock), you might need a DFU restore. See DFU/IPSW guide in the repo.
|
- **`profiles status` may show enrollment.** This is cosmetic — the SSV stores profile state read-only. DEP markers and daemon disable take precedence.
|
||||||
|
- **The hosts file can be bypassed.** DNS-over-HTTPS and cached DNS bypass `/etc/hosts`. Use `firewall` or `whitelist` for the kernel-level fix.
|
||||||
|
|
||||||
## Legal
|
## Safety
|
||||||
|
|
||||||
This suppresses MDM locally on devices you own. It doesn't touch ABM records. The permanent fix is the organization releasing the device.
|
Unleash is designed to be safe:
|
||||||
|
|
||||||
|
- **No SSV writes** — all changes target the Data volume
|
||||||
|
- **Reversible** — `backup` saves state, `restore` reverts
|
||||||
|
- **No data erasure** — never runs `profiles renew` or erase commands
|
||||||
|
- **Idempotent** — running multiple times is harmless
|
||||||
|
- **Prompts for confirmation** before destructive actions
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### MDM comes back after reboot
|
||||||
|
Run `unleash suppress` from Recovery. If it still returns, you have Migration Assistant artifacts. Run `unleash harden` from the booted system.
|
||||||
|
|
||||||
|
### profiles shows enrollment
|
||||||
|
Cosmetic. The SSV stores profile state but the enrollment daemons are disabled. Run `unleash status` to check the actual state on the Data volume.
|
||||||
|
|
||||||
|
### FileVault unlock fails
|
||||||
|
You need a user password or the FileVault recovery key. If neither is available, the Data volume cannot be mounted from Recovery.
|
||||||
|
|
||||||
|
### "Not a macOS Data volume"
|
||||||
|
Unleash checks for `/private/var/db/dslocal/nodes/Default` on the mounted volume. If it's missing, you mounted the wrong disk. Run `diskutil list` to find the correct one.
|
||||||
|
|
||||||
|
### macOS 27 (or future version)
|
||||||
|
Unleash should work on any macOS version that uses the same MDM enrollment mechanism. If a new macOS changes the enrollment daemons or DEP markers, open an issue.
|
||||||
|
|
||||||
|
### Monitor won't start
|
||||||
|
Check if it's already running (`monitor-status`). Check permissions — it needs root. Check logs at `/var/log/unleash-monitor.log`.
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
**What macOS versions are supported?**
|
||||||
|
12.x (Monterey) through 15.x (Sequoia) and 26.x (Tahoe). Tested on Intel T2, M1, M2, M3, M4.
|
||||||
|
|
||||||
|
**Do I need to disable SIP?**
|
||||||
|
No. All writes target the Data volume.
|
||||||
|
|
||||||
|
**Will this survive an OS reinstall?**
|
||||||
|
No. Clean install wipes the Data volume. Re-run after reinstalling.
|
||||||
|
|
||||||
|
**Can the organization track this?**
|
||||||
|
The serial stays in ABM. If the device connects to the internet with enrollment daemons re-enabled, it will re-enroll.
|
||||||
|
|
||||||
|
**What if I need iCloud?**
|
||||||
|
Use `whitelist` instead of `firewall` or `suppress`. It blocks only MDM endpoints.
|
||||||
|
|
||||||
|
**Why does MDM come back after Migration Assistant?**
|
||||||
|
MA copies user-level caches, preferences, and launch agents. Unleash handles this — run `bypass` or `suppress` from Recovery after migrating.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
See CONTRIBUTING.md. PRs welcome, especially for:
|
||||||
|
|
||||||
|
- New macOS version compatibility
|
||||||
|
- Additional MDM domains or daemon labels
|
||||||
|
- Migration Assistant detection
|
||||||
|
- iCloud / MDM domain research
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT.
|
||||||
|
|||||||
+75
-25
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
RED='\033[1;31m'
|
RED='\033[1;31m'
|
||||||
GRN='\033[1;32m'
|
GRN='\033[1;32m'
|
||||||
BLU='\033[1;34m'
|
BLU='\033[1;34m'
|
||||||
@@ -7,50 +6,101 @@ CYAN='\033[1;36m'
|
|||||||
MAG='\033[1;35m'
|
MAG='\033[1;35m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
|
LOG_FILE=""
|
||||||
|
VERBOSE=false
|
||||||
|
|
||||||
|
log() {
|
||||||
|
local level="$1"
|
||||||
|
local msg="$2"
|
||||||
|
local color=""
|
||||||
|
local label=""
|
||||||
|
|
||||||
|
case "$level" in
|
||||||
|
ERROR) color="$RED"; label="ERR" ;;
|
||||||
|
WARN) color="$YEL"; label="WRN" ;;
|
||||||
|
OK) color="$GRN"; label=" OK" ;;
|
||||||
|
INFO) color="$BLU"; label="INF" ;;
|
||||||
|
STEP) color="$CYAN"; label="STP" ;;
|
||||||
|
DEBUG) color="$MAG"; label="DBG" ;;
|
||||||
|
*) color="$NC"; label="LOG" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$level" = "DEBUG" ] && [ "$VERBOSE" = false ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ts
|
||||||
|
ts=$(date '+%H:%M:%S')
|
||||||
|
echo -e "${color}[${label}]${NC} ${msg}"
|
||||||
|
|
||||||
|
if [ -n "$LOG_FILE" ]; then
|
||||||
|
echo "[${ts}] [${label}] ${msg}" >> "$LOG_FILE" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
error_exit() {
|
error_exit() {
|
||||||
echo -e "${RED}ERROR: $1${NC}" >&2
|
log "ERROR" "$1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
echo -e "${YEL}WARNING: $1${NC}" >&2
|
log "WARN" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
success() {
|
success() {
|
||||||
echo -e "${GRN}\u2713 $1${NC}"
|
log "OK" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
echo -e "${BLU}\u2139 $1${NC}"
|
log "INFO" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
step() {
|
step() {
|
||||||
echo -e "${CYAN}\u25b8 $1${NC}"
|
log "STEP" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
debug() {
|
||||||
|
log "DEBUG" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
header() {
|
header() {
|
||||||
local title="$1"
|
local title="$1"
|
||||||
echo ""
|
local len="${#title}"
|
||||||
echo -e "${CYAN}╔═══════════════════════════════════════════════╗${NC}"
|
local line
|
||||||
echo -e "${CYAN}║ ${title}${NC}"
|
line=$(printf '%*s' "$((len + 4))" | tr ' ' '═')
|
||||||
echo -e "${CYAN}╚═══════════════════════════════════════════════╝${NC}"
|
echo ""
|
||||||
echo ""
|
echo -e "${CYAN}╔${line}╗${NC}"
|
||||||
|
echo -e "${CYAN}║ ${title} ║${NC}"
|
||||||
|
echo -e "${CYAN}╚${line}╝${NC}"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
begin() {
|
||||||
|
local label="$1"
|
||||||
|
echo -ne "${CYAN} ${label} ... ${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
end_ok() {
|
||||||
|
echo -e "${GRN}✓${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
end_fail() {
|
||||||
|
echo -e "${RED}✗${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_default() {
|
prompt_default() {
|
||||||
local var_name="$1"
|
local var_name="$1"
|
||||||
local prompt_text="$2"
|
local prompt_text="$2"
|
||||||
local default="$3"
|
local default="$3"
|
||||||
local value
|
local value
|
||||||
|
read -p "${CYAN}${prompt_text}${NC} (default '${default}'): " value
|
||||||
read -p "$prompt_text (default '$default'): " value
|
value="${value:=$default}"
|
||||||
value="${value:=$default}"
|
eval "$var_name=\"$value\""
|
||||||
eval "$var_name=\"$value\""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
local prompt="$1"
|
local prompt="$1"
|
||||||
local response
|
local response
|
||||||
read -p "$prompt (y/N): " response
|
read -p "${prompt} (y/N): " response
|
||||||
[[ "$response" =~ ^[Yy]$ ]]
|
[[ "$response" =~ ^[Yy]$ ]]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Single-script MDM bypass for macOS. Recovery mode. Apple Silicon + Intel.
|
|
||||||
|
|
||||||
VERSION="1.2.0"
|
VERSION="1.2.0"
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
@@ -11,7 +9,6 @@ LIB_DIR="$SCRIPT_DIR/lib"
|
|||||||
for _lib in colors detect validate dscl suppress backup status heal firewall harden whitelist check monitor; do
|
for _lib in colors detect validate dscl suppress backup status heal firewall harden whitelist check monitor; do
|
||||||
_lib_path="$LIB_DIR/$_lib.sh"
|
_lib_path="$LIB_DIR/$_lib.sh"
|
||||||
if [ -f "$_lib_path" ]; then
|
if [ -f "$_lib_path" ]; then
|
||||||
# shellcheck disable=SC1090
|
|
||||||
source "$_lib_path"
|
source "$_lib_path"
|
||||||
else
|
else
|
||||||
echo "ERROR: Library not found: $_lib_path" >&2
|
echo "ERROR: Library not found: $_lib_path" >&2
|
||||||
@@ -19,6 +16,68 @@ for _lib in colors detect validate dscl suppress backup status heal firewall har
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat <<'HELP'
|
||||||
|
Usage: ./unleash <command> [options]
|
||||||
|
|
||||||
|
Bypass / suppress / monitor MDM enrollment on macOS.
|
||||||
|
|
||||||
|
COMMANDS
|
||||||
|
|
||||||
|
Core:
|
||||||
|
bypass Full MDM bypass from Recovery (creates admin user)
|
||||||
|
suppress Silence enrollment, no user created
|
||||||
|
heal Check + re-apply suppression after macOS updates
|
||||||
|
|
||||||
|
Persistence:
|
||||||
|
persist Install LaunchDaemon (auto-heal on every boot)
|
||||||
|
unpersist Remove the persistence LaunchDaemon
|
||||||
|
|
||||||
|
Firewall:
|
||||||
|
firewall Block Apple MDM at kernel level via pf
|
||||||
|
firewall-off Remove pf rules
|
||||||
|
whitelist Block only MDM endpoints, keep iCloud/App Store
|
||||||
|
|
||||||
|
Living System:
|
||||||
|
harden Kill MDM processes + remove profiles + flush DNS
|
||||||
|
audit Deep system scan with risk score
|
||||||
|
|
||||||
|
Monitoring:
|
||||||
|
check Pre-format / pre-upgrade safety report
|
||||||
|
monitor Background daemon (watches MDM every 5 min)
|
||||||
|
monitor-stop Stop the daemon
|
||||||
|
monitor-status Check if daemon is running
|
||||||
|
|
||||||
|
State:
|
||||||
|
backup Save hosts, profiles, launchd state
|
||||||
|
restore Revert from backup
|
||||||
|
dualboot Target an external macOS install
|
||||||
|
|
||||||
|
Info:
|
||||||
|
status Show MDM enrollment status (Recovery only)
|
||||||
|
version Show version
|
||||||
|
help This message
|
||||||
|
|
||||||
|
ALIASES
|
||||||
|
st status
|
||||||
|
ls status
|
||||||
|
fw firewall
|
||||||
|
fw-off firewall-off
|
||||||
|
wl whitelist
|
||||||
|
sv suppress
|
||||||
|
by bypass
|
||||||
|
mn monitor
|
||||||
|
mn-stop monitor-stop
|
||||||
|
mn-st monitor-status
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
--verbose Show debug messages
|
||||||
|
--log-file <f> Write logs to file (appended)
|
||||||
|
|
||||||
|
Run without arguments for interactive menu.
|
||||||
|
HELP
|
||||||
|
}
|
||||||
|
|
||||||
cmd_version() {
|
cmd_version() {
|
||||||
echo "unleash v$VERSION"
|
echo "unleash v$VERSION"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -26,7 +85,7 @@ cmd_version() {
|
|||||||
|
|
||||||
cmd_bypass() {
|
cmd_bypass() {
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
header "unleash — Full MDM Bypass"
|
header "Full MDM Bypass"
|
||||||
local data_mount
|
local data_mount
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
full_bypass_mode "$data_mount"
|
full_bypass_mode "$data_mount"
|
||||||
@@ -36,30 +95,31 @@ cmd_bypass() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_suppress() {
|
cmd_suppress() {
|
||||||
header "unleash — Suppress Enrollment Only"
|
header "Suppress Enrollment"
|
||||||
local data_mount
|
local data_mount
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
suppress_only_mode "$data_mount"
|
suppress_only_mode "$data_mount"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_backup() {
|
cmd_backup() {
|
||||||
header "unleash — Backup State"
|
header "Backup"
|
||||||
local data_mount
|
local data_mount
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
backup_state "$data_mount"
|
backup_state "$data_mount"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_restore() {
|
cmd_restore() {
|
||||||
header "unleash — Restore State"
|
header "Restore"
|
||||||
restore_state
|
restore_state
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_dualboot() {
|
cmd_dualboot() {
|
||||||
header "unleash — Dual-Boot Mode"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Dual-boot mode requires sudo: sudo ./unleash dualboot"
|
error_exit "Dual-boot needs sudo: sudo ./unleash dualboot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
header "Dual-Boot Mode"
|
||||||
|
|
||||||
local volumes
|
local volumes
|
||||||
volumes=$(resolve_target_volumes)
|
volumes=$(resolve_target_volumes)
|
||||||
local sys_path="${volumes%%|*}"
|
local sys_path="${volumes%%|*}"
|
||||||
@@ -75,67 +135,58 @@ cmd_dualboot() {
|
|||||||
step "Creating admin account on target"
|
step "Creating admin account on target"
|
||||||
|
|
||||||
prompt_default realName "Full name" "Apple"
|
prompt_default realName "Full name" "Apple"
|
||||||
|
|
||||||
local username
|
local username
|
||||||
prompt_username username
|
prompt_username username
|
||||||
|
|
||||||
local passw
|
local passw
|
||||||
prompt_password passw
|
prompt_password passw
|
||||||
|
|
||||||
local uid
|
local uid
|
||||||
uid=$(find_available_uid "$node")
|
uid=$(find_available_uid "$node")
|
||||||
|
|
||||||
create_admin_user "$node" "$data_path" "$username" "$realName" "$passw" "$uid"
|
create_admin_user "$node" "$data_path" "$username" "$realName" "$passw" "$uid"
|
||||||
touch "$data_path/private/var/db/.AppleSetupDone"
|
touch "$data_path/private/var/db/.AppleSetupDone"
|
||||||
|
|
||||||
step "Blocking domains on target..."
|
begin "Blocking domains"
|
||||||
local hosts_file="$data_path/private/etc/hosts"
|
local hosts_file="$data_path/private/etc/hosts"
|
||||||
[ -f "$hosts_file" ] || touch "$hosts_file"
|
[ -f "$hosts_file" ] || touch "$hosts_file"
|
||||||
echo "0.0.0.0 deviceenrollment.apple.com" >>"$hosts_file"
|
echo "0.0.0.0 deviceenrollment.apple.com" >>"$hosts_file"
|
||||||
echo "0.0.0.0 mdmenrollment.apple.com" >>"$hosts_file"
|
echo "0.0.0.0 mdmenrollment.apple.com" >>"$hosts_file"
|
||||||
echo "0.0.0.0 iprofiles.apple.com" >>"$hosts_file"
|
echo "0.0.0.0 iprofiles.apple.com" >>"$hosts_file"
|
||||||
success "MDM domains blocked"
|
end_ok
|
||||||
|
|
||||||
|
begin "Resetting config profiles"
|
||||||
local config_path="$data_path/private/var/db/ConfigurationProfiles/Settings"
|
local config_path="$data_path/private/var/db/ConfigurationProfiles/Settings"
|
||||||
mkdir -p "$config_path"
|
mkdir -p "$config_path"
|
||||||
rm -f "$config_path/.cloudConfigHasActivationRecord" \
|
rm -f "$config_path/.cloudConfigHasActivationRecord" \
|
||||||
"$config_path/.cloudConfigRecordFound"
|
"$config_path/.cloudConfigRecordFound"
|
||||||
touch "$config_path/.cloudConfigProfileInstalled" \
|
touch "$config_path/.cloudConfigProfileInstalled" \
|
||||||
"$config_path/.cloudConfigRecordNotFound"
|
"$config_path/.cloudConfigRecordNotFound"
|
||||||
success "Configuration profiles reset"
|
end_ok
|
||||||
|
|
||||||
echo ""
|
info "User: $username"
|
||||||
echo -e "${GRN}============================================${NC}"
|
info "Pass: $passw"
|
||||||
echo -e "${GRN} Dual-Boot Bypass Applied ${NC}"
|
info "Boot the target and login."
|
||||||
echo -e "${GRN}============================================${NC}"
|
|
||||||
echo ""
|
|
||||||
echo -e "${CYAN}Boot into the target installation and login:${NC}"
|
|
||||||
echo -e "${YEL} User: $username${NC}"
|
|
||||||
echo -e "${YEL} Pass: $passw${NC}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_heal() {
|
cmd_heal() {
|
||||||
header "unleash — Auto-Heal"
|
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
local data_mount
|
local data_mount
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
heal_suppress "$data_mount"
|
heal_suppress "$data_mount"
|
||||||
else
|
else
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Heal from booted system requires sudo: sudo ./unleash heal"
|
error_exit "Heal needs sudo: sudo ./unleash heal"
|
||||||
fi
|
fi
|
||||||
heal_suppress ""
|
heal_suppress ""
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_persist() {
|
cmd_persist() {
|
||||||
header "unleash — Install Persistence"
|
|
||||||
local data_mount
|
local data_mount
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
else
|
else
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Persistence requires sudo: sudo ./unleash persist"
|
error_exit "Persistence needs sudo: sudo ./unleash persist"
|
||||||
fi
|
fi
|
||||||
data_mount=""
|
data_mount=""
|
||||||
fi
|
fi
|
||||||
@@ -143,7 +194,6 @@ cmd_persist() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_unpersist() {
|
cmd_unpersist() {
|
||||||
header "unleash — Remove Persistence"
|
|
||||||
local data_mount
|
local data_mount
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
@@ -154,9 +204,8 @@ cmd_unpersist() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_firewall() {
|
cmd_firewall() {
|
||||||
header "unleash — pf Firewall MDM Block"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Firewall requires sudo: sudo ./unleash firewall"
|
error_exit "Firewall needs sudo: sudo ./unleash firewall"
|
||||||
fi
|
fi
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
local data_mount
|
local data_mount
|
||||||
@@ -168,9 +217,8 @@ cmd_firewall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_firewall_off() {
|
cmd_firewall_off() {
|
||||||
header "unleash — Remove pf Firewall"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Requires sudo: sudo ./unleash firewall-off"
|
error_exit "Needs sudo: sudo ./unleash firewall-off"
|
||||||
fi
|
fi
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
local data_mount
|
local data_mount
|
||||||
@@ -182,30 +230,25 @@ cmd_firewall_off() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_harden() {
|
cmd_harden() {
|
||||||
header "unleash — Live-OS Hardening"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Hardening requires sudo: sudo ./unleash harden"
|
error_exit "Hardening needs sudo: sudo ./unleash harden"
|
||||||
fi
|
fi
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
info "Hardening from Recovery will skip live-OS checks"
|
info "In Recovery — will skip live-OS checks"
|
||||||
harden_live_os
|
|
||||||
else
|
|
||||||
harden_live_os
|
|
||||||
fi
|
fi
|
||||||
|
harden_live_os
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_audit() {
|
cmd_audit() {
|
||||||
header "unleash — Deep MDM Audit"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Audit requires sudo: sudo ./unleash audit"
|
error_exit "Audit needs sudo: sudo ./unleash audit"
|
||||||
fi
|
fi
|
||||||
deep_status
|
deep_status
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_whitelist() {
|
cmd_whitelist() {
|
||||||
header "unleash — Selective MDM Block"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Whitelist requires sudo: sudo ./unleash whitelist"
|
error_exit "Whitelist needs sudo: sudo ./unleash whitelist"
|
||||||
fi
|
fi
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
local data_mount
|
local data_mount
|
||||||
@@ -222,52 +265,44 @@ cmd_status() {
|
|||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
check_mdm_status "$data_mount"
|
check_mdm_status "$data_mount"
|
||||||
else
|
else
|
||||||
error_exit "Status check must run from Recovery mode."
|
error_exit "Status works from Recovery. Try 'check' or 'audit' instead."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_check() {
|
cmd_check() {
|
||||||
header "unleash — Pre-Format Assessment"
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Check requires sudo: sudo ./unleash check"
|
error_exit "Check needs sudo: sudo ./unleash check"
|
||||||
fi
|
fi
|
||||||
run_preformat_check
|
run_preformat_check
|
||||||
echo ""
|
echo ""
|
||||||
check_upgrade_safety
|
check_upgrade_safety
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_monitor() {
|
cmd_monitor() { monitor_mdm; }
|
||||||
monitor_mdm
|
cmd_monitor_stop() { stop_monitor; }
|
||||||
}
|
cmd_monitor_status() { monitor_status; }
|
||||||
|
|
||||||
cmd_monitor_stop() {
|
|
||||||
stop_monitor
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_monitor_status() {
|
|
||||||
monitor_status
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_interactive_recovery() {
|
cmd_interactive_recovery() {
|
||||||
header "unleash — Recovery Mode"
|
header "unleash"
|
||||||
|
|
||||||
local data_mount
|
local data_mount
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
PS3="Choose an option: "
|
PS3="Choose: "
|
||||||
local options=(
|
local options=(
|
||||||
"Full bypass (create admin + suppress MDM)"
|
"Full bypass (create admin + suppress MDM)"
|
||||||
"Suppress enrollment only (no user)"
|
"Suppress enrollment only"
|
||||||
"Auto-heal (check and re-suppress)"
|
"Auto-heal"
|
||||||
"Install pf firewall (blocks all Apple services)"
|
"Install pf firewall"
|
||||||
"Remove pf firewall"
|
"Remove pf firewall"
|
||||||
"Install selective block (iCloud-safe)"
|
"Install selective block (iCloud-safe)"
|
||||||
"Live-OS harden (kill MDM processes)"
|
"Live-OS harden"
|
||||||
"Deep MDM audit"
|
"Deep MDM audit"
|
||||||
"Backup current state"
|
"Backup state"
|
||||||
"Restore from backup"
|
"Restore from backup"
|
||||||
"Check MDM status"
|
"Check MDM status"
|
||||||
|
"Pre-format check"
|
||||||
"Reboot"
|
"Reboot"
|
||||||
"Exit"
|
"Exit"
|
||||||
)
|
)
|
||||||
@@ -275,15 +310,15 @@ cmd_interactive_recovery() {
|
|||||||
case $opt in
|
case $opt in
|
||||||
"Full bypass (create admin + suppress MDM)")
|
"Full bypass (create admin + suppress MDM)")
|
||||||
full_bypass_mode "$data_mount"
|
full_bypass_mode "$data_mount"
|
||||||
echo -e "${CYAN}Reboot to apply changes.${NC}"
|
info "Reboot to apply."
|
||||||
;;
|
;;
|
||||||
"Suppress enrollment only (no user)")
|
"Suppress enrollment only")
|
||||||
suppress_only_mode "$data_mount"
|
suppress_only_mode "$data_mount"
|
||||||
;;
|
;;
|
||||||
"Auto-heal (check and re-suppress)")
|
"Auto-heal")
|
||||||
heal_suppress "$data_mount"
|
heal_suppress "$data_mount"
|
||||||
;;
|
;;
|
||||||
"Install pf firewall (blocks all Apple services)")
|
"Install pf firewall")
|
||||||
install_pf_mdm_block "$data_mount"
|
install_pf_mdm_block "$data_mount"
|
||||||
;;
|
;;
|
||||||
"Remove pf firewall")
|
"Remove pf firewall")
|
||||||
@@ -292,13 +327,13 @@ cmd_interactive_recovery() {
|
|||||||
"Install selective block (iCloud-safe)")
|
"Install selective block (iCloud-safe)")
|
||||||
install_selective_block "$data_mount"
|
install_selective_block "$data_mount"
|
||||||
;;
|
;;
|
||||||
"Live-OS harden (kill MDM processes)")
|
"Live-OS harden")
|
||||||
harden_live_os
|
harden_live_os
|
||||||
;;
|
;;
|
||||||
"Deep MDM audit")
|
"Deep MDM audit")
|
||||||
deep_status
|
deep_status
|
||||||
;;
|
;;
|
||||||
"Backup current state")
|
"Backup state")
|
||||||
backup_state "$data_mount"
|
backup_state "$data_mount"
|
||||||
;;
|
;;
|
||||||
"Restore from backup")
|
"Restore from backup")
|
||||||
@@ -307,6 +342,9 @@ cmd_interactive_recovery() {
|
|||||||
"Check MDM status")
|
"Check MDM status")
|
||||||
check_mdm_status "$data_mount"
|
check_mdm_status "$data_mount"
|
||||||
;;
|
;;
|
||||||
|
"Pre-format check")
|
||||||
|
run_preformat_check
|
||||||
|
;;
|
||||||
"Reboot")
|
"Reboot")
|
||||||
info "Rebooting..."
|
info "Rebooting..."
|
||||||
reboot
|
reboot
|
||||||
@@ -323,73 +361,80 @@ cmd_interactive_recovery() {
|
|||||||
|
|
||||||
cmd_interactive_normal() {
|
cmd_interactive_normal() {
|
||||||
header "unleash"
|
header "unleash"
|
||||||
echo -e "${YEL}Not in Recovery mode. Limited options.${NC}"
|
echo -e "${YEL}Not in Recovery. Limited options.${NC}"
|
||||||
|
echo " Try: sudo ./unleash heal | harden | audit | check | monitor"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
PS3="Choose an option: "
|
PS3="Choose: "
|
||||||
local options=(
|
local options=(
|
||||||
"Suppress enrollment only"
|
"Auto-heal"
|
||||||
"Auto-heal (check and re-suppress)"
|
"Backup state"
|
||||||
"Backup current state"
|
|
||||||
"Restore from backup"
|
"Restore from backup"
|
||||||
"Exit"
|
"Exit"
|
||||||
)
|
)
|
||||||
select opt in "${options[@]}"; do
|
select opt in "${options[@]}"; do
|
||||||
case $opt in
|
case $opt in
|
||||||
"Suppress enrollment only")
|
"Auto-heal")
|
||||||
local data_mount
|
|
||||||
data_mount=$(resolve_data_volume)
|
|
||||||
suppress_only_mode "$data_mount"
|
|
||||||
;;
|
|
||||||
"Auto-heal (check and re-suppress)")
|
|
||||||
if ! is_root; then
|
if ! is_root; then
|
||||||
error_exit "Heal from booted system requires sudo. Run: sudo ./unleash"
|
error_exit "Heal needs sudo. Run: sudo ./unleash"
|
||||||
fi
|
fi
|
||||||
heal_suppress ""
|
heal_suppress ""
|
||||||
;;
|
;;
|
||||||
"Backup current state")
|
"Backup state")
|
||||||
local data_mount
|
local data_mount
|
||||||
data_mount=$(resolve_data_volume)
|
data_mount=$(resolve_data_volume)
|
||||||
backup_state "$data_mount"
|
backup_state "$data_mount"
|
||||||
;;
|
;;
|
||||||
"Restore from backup")
|
"Restore from backup")
|
||||||
restore_state
|
restore_state
|
||||||
;;
|
;;
|
||||||
"Exit")
|
"Exit")
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "${RED}Invalid option $REPLY${NC}"
|
echo -e "${RED}Invalid $REPLY${NC}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parse_global_opts() {
|
||||||
|
local args=()
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--verbose) VERBOSE=true; shift ;;
|
||||||
|
--log-file) LOG_FILE="$2"; shift 2 ;;
|
||||||
|
*) args+=("$1"); shift ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
set -- "${args[@]}"
|
||||||
|
echo "$@"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
eval "set -- $(parse_global_opts "$@")"
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
bypass) cmd_bypass ;;
|
bypass|by) cmd_bypass ;;
|
||||||
suppress) cmd_suppress ;;
|
suppress|sv) cmd_suppress ;;
|
||||||
heal) cmd_heal ;;
|
heal) cmd_heal ;;
|
||||||
persist) cmd_persist ;;
|
persist) cmd_persist ;;
|
||||||
unpersist) cmd_unpersist ;;
|
unpersist) cmd_unpersist ;;
|
||||||
firewall) cmd_firewall ;;
|
firewall|fw) cmd_firewall ;;
|
||||||
firewall-off) cmd_firewall_off ;;
|
firewall-off|fw-off) cmd_firewall_off ;;
|
||||||
harden) cmd_harden ;;
|
harden) cmd_harden ;;
|
||||||
audit) cmd_audit ;;
|
audit) cmd_audit ;;
|
||||||
whitelist) cmd_whitelist ;;
|
whitelist|wl) cmd_whitelist ;;
|
||||||
backup) cmd_backup ;;
|
backup) cmd_backup ;;
|
||||||
restore) cmd_restore ;;
|
restore) cmd_restore ;;
|
||||||
dualboot) cmd_dualboot ;;
|
dualboot) cmd_dualboot ;;
|
||||||
status) cmd_status ;;
|
status|st|ls) cmd_status ;;
|
||||||
check) cmd_check ;;
|
check) cmd_check ;;
|
||||||
monitor) cmd_monitor ;;
|
monitor|mn) cmd_monitor ;;
|
||||||
monitor-stop) cmd_monitor_stop ;;
|
monitor-stop|mn-stop) cmd_monitor_stop ;;
|
||||||
monitor-status) cmd_monitor_status ;;
|
monitor-status|mn-st) cmd_monitor_status ;;
|
||||||
version|-v|--version) cmd_version ;;
|
version|-v|--version) cmd_version ;;
|
||||||
help|-h|--help)
|
help|-h|--help) show_help; exit 0 ;;
|
||||||
echo "Usage: $0 {bypass|suppress|heal|persist|unpersist|firewall|firewall-off|harden|audit|whitelist|check|monitor|monitor-stop|monitor-status|backup|restore|dualboot|status|version|help}"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"")
|
"")
|
||||||
if is_recovery; then
|
if is_recovery; then
|
||||||
cmd_interactive_recovery
|
cmd_interactive_recovery
|
||||||
@@ -398,8 +443,8 @@ main() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "${RED}Unknown command: $1${NC}" >&2
|
echo -e "${RED}Unknown: $1${NC}" >&2
|
||||||
echo "Usage: $0 {bypass|suppress|heal|persist|unpersist|firewall|firewall-off|harden|audit|whitelist|check|monitor|monitor-stop|monitor-status|backup|restore|dualboot|status|version|help}" >&2
|
show_help >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user