feat(bypass): allow --username/--password/--full-name for unattended runs
This commit is contained in:
@@ -49,7 +49,15 @@ chmod +x /tmp/runaway && /tmp/runaway bypass
|
||||
./runaway bypass
|
||||
```
|
||||
|
||||
Creates a temporary admin account and suppresses MDM. What it does:
|
||||
Creates a temporary admin account and suppresses MDM. Username and password are
|
||||
prompted interactively (defaults `Apple` / `1234`); to run unattended, pass them as flags:
|
||||
|
||||
```bash
|
||||
./runaway bypass --username me --password 'hunter2!' --full-name "My Name"
|
||||
```
|
||||
|
||||
`--password` lands in your shell history and process list — prefer the interactive
|
||||
prompt when someone might be watching. What bypass does:
|
||||
|
||||
1. Finds and mounts the macOS Data volume
|
||||
2. Unlocks FileVault if needed (asks for password)
|
||||
|
||||
+7
-1
@@ -45,7 +45,13 @@ chmod +x /tmp/runaway && /tmp/runaway bypass
|
||||
./runaway bypass
|
||||
```
|
||||
|
||||
创建临时管理员账户并压制 MDM。具体做这些事:
|
||||
创建临时管理员账户并压制 MDM。用户名和密码走交互式输入(直接回车用默认值 `Apple` / `1234`);无人值守场景可以用参数直接传入:
|
||||
|
||||
```bash
|
||||
./runaway bypass --username me --password 'hunter2!' --full-name "My Name"
|
||||
```
|
||||
|
||||
注意 `--password` 会留在 shell 历史和进程列表里,手动操作时建议还是用交互输入。具体做这些事:
|
||||
|
||||
1. 查找并挂载 macOS 数据卷
|
||||
2. 需要时解锁 FileVault(会询问密码)
|
||||
|
||||
+3
-2
@@ -17,9 +17,10 @@ title: Commands Reference — runaway
|
||||
|
||||
### `bypass`
|
||||
Creates a temporary admin account and suppresses all 5 layers of MDM.
|
||||
**Must run from Recovery.**
|
||||
**Must run from Recovery.** Credentials are prompted interactively (defaults `Apple` / `1234`);
|
||||
flags make it unattended (also works for `admin` and `dualboot`):
|
||||
```bash
|
||||
./runaway bypass
|
||||
./runaway bypass --username me --password 'hunter2!' --full-name "My Name"
|
||||
```
|
||||
|
||||
### `suppress`
|
||||
|
||||
@@ -16,6 +16,8 @@ title: Referência de Comandos — runaway
|
||||
| `unpersist` | Remove o LaunchDaemon de auto-recuperação | ✗ | ✓ |
|
||||
|
||||
### `bypass`
|
||||
Credenciais podem ser passadas via flags (também valem para `admin` e `dualboot`):
|
||||
`--username <u>`, `--password <p>`, `--full-name <n>`; sem flags, o script pergunta.
|
||||
Cria uma conta admin temporária e suprime todas as 5 camadas do MDM.
|
||||
**Deve executar do Recovery.**
|
||||
```bash
|
||||
|
||||
+6
-6
@@ -170,11 +170,11 @@ admin_only_mode() {
|
||||
echo ""
|
||||
step "Creating local admin account"
|
||||
|
||||
prompt_default realName "Full name" "Apple"
|
||||
acquire_realname realName
|
||||
|
||||
local username
|
||||
while true; do
|
||||
prompt_username username
|
||||
acquire_username username
|
||||
if check_user_exists "$node" "$username"; then
|
||||
warn "User '$username' already exists."
|
||||
if confirm "Delete and recreate?"; then
|
||||
@@ -189,7 +189,7 @@ admin_only_mode() {
|
||||
done
|
||||
|
||||
local passw
|
||||
prompt_password passw
|
||||
acquire_password passw
|
||||
|
||||
local uid
|
||||
uid=$(find_available_uid "$node")
|
||||
@@ -227,11 +227,11 @@ full_bypass_mode() {
|
||||
step "Creating temporary admin account"
|
||||
|
||||
local realName
|
||||
prompt_default realName "Full name" "Apple"
|
||||
acquire_realname realName
|
||||
|
||||
local username
|
||||
while true; do
|
||||
prompt_username username
|
||||
acquire_username username
|
||||
if check_user_exists "$node" "$username"; then
|
||||
warn "User '$username' already exists."
|
||||
if confirm "Delete and recreate?"; then
|
||||
@@ -246,7 +246,7 @@ full_bypass_mode() {
|
||||
done
|
||||
|
||||
local passw
|
||||
prompt_password passw
|
||||
acquire_password passw
|
||||
|
||||
local uid
|
||||
uid=$(find_available_uid "$node")
|
||||
|
||||
@@ -45,3 +45,60 @@ prompt_password() {
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Account credentials: CLI flags (--username/--password/--full-name) win over
|
||||
# interactive prompts so bypass/admin/dualboot can run unattended.
|
||||
OPT_USERNAME="${OPT_USERNAME:-}"
|
||||
OPT_PASSWORD="${OPT_PASSWORD:-}"
|
||||
OPT_REALNAME="${OPT_REALNAME:-}"
|
||||
|
||||
parse_account_opts() {
|
||||
ACCOUNT_ARGS=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--username|--password|--full-name)
|
||||
local key="$1"
|
||||
if [ $# -lt 2 ] || [ -z "$2" ] || [[ "$2" == --* ]]; then
|
||||
error_exit "$key requires a value"
|
||||
fi
|
||||
case "$key" in
|
||||
--username) OPT_USERNAME="$2" ;;
|
||||
--password) OPT_PASSWORD="$2" ;;
|
||||
--full-name) OPT_REALNAME="$2" ;;
|
||||
esac
|
||||
shift 2 ;;
|
||||
*) ACCOUNT_ARGS+=("$1"); shift ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
acquire_username() {
|
||||
local var_name="$1"
|
||||
if [ -n "$OPT_USERNAME" ]; then
|
||||
local msg
|
||||
msg=$(validate_username "$OPT_USERNAME" 2>&1) || error_exit "Invalid --username: $msg"
|
||||
eval "$var_name=\"\$OPT_USERNAME\""
|
||||
else
|
||||
prompt_username "$var_name"
|
||||
fi
|
||||
}
|
||||
|
||||
acquire_password() {
|
||||
local var_name="$1"
|
||||
if [ -n "$OPT_PASSWORD" ]; then
|
||||
local msg
|
||||
msg=$(validate_password "$OPT_PASSWORD" 2>&1) || error_exit "Invalid --password: $msg"
|
||||
eval "$var_name=\"\$OPT_PASSWORD\""
|
||||
else
|
||||
prompt_password "$var_name"
|
||||
fi
|
||||
}
|
||||
|
||||
acquire_realname() {
|
||||
local var_name="$1"
|
||||
if [ -n "$OPT_REALNAME" ]; then
|
||||
eval "$var_name=\"\$OPT_REALNAME\""
|
||||
else
|
||||
prompt_default "$var_name" "Full name" "Apple"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ done
|
||||
|
||||
show_cmd_help() {
|
||||
case "$1" in
|
||||
bypass) echo "Bypass MDM from Recovery. Creates admin user." ;;
|
||||
bypass) echo "Bypass MDM from Recovery. Creates admin user (accepts --username/--password/--full-name)." ;;
|
||||
suppress) echo "Suppress enrollment without creating a user." ;;
|
||||
admin) echo "Create an admin user without suppressing enrollment." ;;
|
||||
admin) echo "Create an admin user without suppressing enrollment (accepts --username/--password/--full-name)." ;;
|
||||
heal) echo "Re-apply suppression after macOS updates." ;;
|
||||
persist) echo "Install auto-heal LaunchDaemon." ;;
|
||||
unpersist) echo "Remove auto-heal LaunchDaemon." ;;
|
||||
@@ -36,7 +36,7 @@ show_cmd_help() {
|
||||
whitelist) echo "Block only MDM domains, keep iCloud/App Store." ;;
|
||||
backup) echo "Save current state." ;;
|
||||
restore) echo "Restore from backup." ;;
|
||||
dualboot) echo "Target an external macOS install." ;;
|
||||
dualboot) echo "Target an external macOS install (accepts --username/--password/--full-name)." ;;
|
||||
status) echo "Show MDM enrollment status (Recovery only)." ;;
|
||||
check) echo "Pre-format / pre-upgrade safety report." ;;
|
||||
history) echo "Show event log from monitor/heal runs." ;;
|
||||
@@ -170,6 +170,12 @@ OPTIONS
|
||||
--dry-run Simulate without making changes
|
||||
--log-file <f> Write logs to file (appended)
|
||||
|
||||
Account options (bypass / admin / dualboot):
|
||||
--username <u> Pre-set the admin username (skips the prompt)
|
||||
--password <p> Pre-set the admin password (skips the prompt)
|
||||
--full-name <n> Pre-set the display name
|
||||
Note: --password is visible in shell history and process lists.
|
||||
|
||||
Run without arguments for interactive menu.
|
||||
HELP
|
||||
}
|
||||
@@ -180,6 +186,7 @@ cmd_version() {
|
||||
}
|
||||
|
||||
cmd_bypass() {
|
||||
parse_account_opts "$@"
|
||||
if is_recovery; then
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
full_bypass_mode "the selected Data volume"
|
||||
@@ -213,6 +220,7 @@ cmd_backup() {
|
||||
}
|
||||
|
||||
cmd_admin() {
|
||||
parse_account_opts "$@"
|
||||
if ! is_recovery; then
|
||||
error_exit "Admin creation must run from Recovery mode."
|
||||
fi
|
||||
@@ -241,6 +249,7 @@ cmd_dualboot() {
|
||||
error_exit "Dual-boot needs sudo: sudo ./runaway dualboot"
|
||||
fi
|
||||
|
||||
parse_account_opts "$@"
|
||||
header "Dual-Boot Mode"
|
||||
|
||||
local volumes
|
||||
@@ -258,11 +267,11 @@ cmd_dualboot() {
|
||||
step "Creating admin account on target"
|
||||
|
||||
local realName
|
||||
prompt_default realName "Full name" "Apple"
|
||||
acquire_realname realName
|
||||
local username
|
||||
prompt_username username
|
||||
acquire_username username
|
||||
local passw
|
||||
prompt_password passw
|
||||
acquire_password passw
|
||||
local uid
|
||||
uid=$(find_available_uid "$node")
|
||||
|
||||
@@ -605,9 +614,9 @@ main() {
|
||||
fi
|
||||
|
||||
case "${1:-}" in
|
||||
bypass|by) cmd_bypass ;;
|
||||
bypass|by) cmd_bypass "$@" ;;
|
||||
suppress|sv) cmd_suppress ;;
|
||||
admin|adm) cmd_admin ;;
|
||||
admin|adm) cmd_admin "$@" ;;
|
||||
heal) cmd_heal ;;
|
||||
persist) cmd_persist ;;
|
||||
unpersist) cmd_unpersist ;;
|
||||
@@ -618,7 +627,7 @@ main() {
|
||||
whitelist|wl) cmd_whitelist ;;
|
||||
backup) cmd_backup ;;
|
||||
restore) cmd_restore ;;
|
||||
dualboot) cmd_dualboot ;;
|
||||
dualboot) cmd_dualboot "$@" ;;
|
||||
status|st|ls) cmd_status ;;
|
||||
check) cmd_check ;;
|
||||
history) cmd_history ;;
|
||||
|
||||
+81
-15
@@ -358,6 +358,63 @@ prompt_password() {
|
||||
done
|
||||
}
|
||||
|
||||
# Account credentials: CLI flags (--username/--password/--full-name) win over
|
||||
# interactive prompts so bypass/admin/dualboot can run unattended.
|
||||
OPT_USERNAME="${OPT_USERNAME:-}"
|
||||
OPT_PASSWORD="${OPT_PASSWORD:-}"
|
||||
OPT_REALNAME="${OPT_REALNAME:-}"
|
||||
|
||||
parse_account_opts() {
|
||||
ACCOUNT_ARGS=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--username|--password|--full-name)
|
||||
local key="$1"
|
||||
if [ $# -lt 2 ] || [ -z "$2" ] || [[ "$2" == --* ]]; then
|
||||
error_exit "$key requires a value"
|
||||
fi
|
||||
case "$key" in
|
||||
--username) OPT_USERNAME="$2" ;;
|
||||
--password) OPT_PASSWORD="$2" ;;
|
||||
--full-name) OPT_REALNAME="$2" ;;
|
||||
esac
|
||||
shift 2 ;;
|
||||
*) ACCOUNT_ARGS+=("$1"); shift ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
acquire_username() {
|
||||
local var_name="$1"
|
||||
if [ -n "$OPT_USERNAME" ]; then
|
||||
local msg
|
||||
msg=$(validate_username "$OPT_USERNAME" 2>&1) || error_exit "Invalid --username: $msg"
|
||||
eval "$var_name=\"\$OPT_USERNAME\""
|
||||
else
|
||||
prompt_username "$var_name"
|
||||
fi
|
||||
}
|
||||
|
||||
acquire_password() {
|
||||
local var_name="$1"
|
||||
if [ -n "$OPT_PASSWORD" ]; then
|
||||
local msg
|
||||
msg=$(validate_password "$OPT_PASSWORD" 2>&1) || error_exit "Invalid --password: $msg"
|
||||
eval "$var_name=\"\$OPT_PASSWORD\""
|
||||
else
|
||||
prompt_password "$var_name"
|
||||
fi
|
||||
}
|
||||
|
||||
acquire_realname() {
|
||||
local var_name="$1"
|
||||
if [ -n "$OPT_REALNAME" ]; then
|
||||
eval "$var_name=\"\$OPT_REALNAME\""
|
||||
else
|
||||
prompt_default "$var_name" "Full name" "Apple"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
dscl_node() {
|
||||
local data_mount="$1"
|
||||
@@ -620,11 +677,11 @@ admin_only_mode() {
|
||||
echo ""
|
||||
step "Creating local admin account"
|
||||
|
||||
prompt_default realName "Full name" "Apple"
|
||||
acquire_realname realName
|
||||
|
||||
local username
|
||||
while true; do
|
||||
prompt_username username
|
||||
acquire_username username
|
||||
if check_user_exists "$node" "$username"; then
|
||||
warn "User '$username' already exists."
|
||||
if confirm "Delete and recreate?"; then
|
||||
@@ -639,7 +696,7 @@ admin_only_mode() {
|
||||
done
|
||||
|
||||
local passw
|
||||
prompt_password passw
|
||||
acquire_password passw
|
||||
|
||||
local uid
|
||||
uid=$(find_available_uid "$node")
|
||||
@@ -677,11 +734,11 @@ full_bypass_mode() {
|
||||
step "Creating temporary admin account"
|
||||
|
||||
local realName
|
||||
prompt_default realName "Full name" "Apple"
|
||||
acquire_realname realName
|
||||
|
||||
local username
|
||||
while true; do
|
||||
prompt_username username
|
||||
acquire_username username
|
||||
if check_user_exists "$node" "$username"; then
|
||||
warn "User '$username' already exists."
|
||||
if confirm "Delete and recreate?"; then
|
||||
@@ -696,7 +753,7 @@ full_bypass_mode() {
|
||||
done
|
||||
|
||||
local passw
|
||||
prompt_password passw
|
||||
acquire_password passw
|
||||
|
||||
local uid
|
||||
uid=$(find_available_uid "$node")
|
||||
@@ -2844,9 +2901,9 @@ vpn_kill_status() {
|
||||
|
||||
show_cmd_help() {
|
||||
case "$1" in
|
||||
bypass) echo "Bypass MDM from Recovery. Creates admin user." ;;
|
||||
bypass) echo "Bypass MDM from Recovery. Creates admin user (accepts --username/--password/--full-name)." ;;
|
||||
suppress) echo "Suppress enrollment without creating a user." ;;
|
||||
admin) echo "Create an admin user without suppressing enrollment." ;;
|
||||
admin) echo "Create an admin user without suppressing enrollment (accepts --username/--password/--full-name)." ;;
|
||||
heal) echo "Re-apply suppression after macOS updates." ;;
|
||||
persist) echo "Install auto-heal LaunchDaemon." ;;
|
||||
unpersist) echo "Remove auto-heal LaunchDaemon." ;;
|
||||
@@ -2857,7 +2914,7 @@ show_cmd_help() {
|
||||
whitelist) echo "Block only MDM domains, keep iCloud/App Store." ;;
|
||||
backup) echo "Save current state." ;;
|
||||
restore) echo "Restore from backup." ;;
|
||||
dualboot) echo "Target an external macOS install." ;;
|
||||
dualboot) echo "Target an external macOS install (accepts --username/--password/--full-name)." ;;
|
||||
status) echo "Show MDM enrollment status (Recovery only)." ;;
|
||||
check) echo "Pre-format / pre-upgrade safety report." ;;
|
||||
history) echo "Show event log from monitor/heal runs." ;;
|
||||
@@ -2991,6 +3048,12 @@ OPTIONS
|
||||
--dry-run Simulate without making changes
|
||||
--log-file <f> Write logs to file (appended)
|
||||
|
||||
Account options (bypass / admin / dualboot):
|
||||
--username <u> Pre-set the admin username (skips the prompt)
|
||||
--password <p> Pre-set the admin password (skips the prompt)
|
||||
--full-name <n> Pre-set the display name
|
||||
Note: --password is visible in shell history and process lists.
|
||||
|
||||
Run without arguments for interactive menu.
|
||||
HELP
|
||||
}
|
||||
@@ -3001,6 +3064,7 @@ cmd_version() {
|
||||
}
|
||||
|
||||
cmd_bypass() {
|
||||
parse_account_opts "$@"
|
||||
if is_recovery; then
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
full_bypass_mode "the selected Data volume"
|
||||
@@ -3034,6 +3098,7 @@ cmd_backup() {
|
||||
}
|
||||
|
||||
cmd_admin() {
|
||||
parse_account_opts "$@"
|
||||
if ! is_recovery; then
|
||||
error_exit "Admin creation must run from Recovery mode."
|
||||
fi
|
||||
@@ -3062,6 +3127,7 @@ cmd_dualboot() {
|
||||
error_exit "Dual-boot needs sudo: sudo ./runaway dualboot"
|
||||
fi
|
||||
|
||||
parse_account_opts "$@"
|
||||
header "Dual-Boot Mode"
|
||||
|
||||
local volumes
|
||||
@@ -3079,11 +3145,11 @@ cmd_dualboot() {
|
||||
step "Creating admin account on target"
|
||||
|
||||
local realName
|
||||
prompt_default realName "Full name" "Apple"
|
||||
acquire_realname realName
|
||||
local username
|
||||
prompt_username username
|
||||
acquire_username username
|
||||
local passw
|
||||
prompt_password passw
|
||||
acquire_password passw
|
||||
local uid
|
||||
uid=$(find_available_uid "$node")
|
||||
|
||||
@@ -3426,9 +3492,9 @@ main() {
|
||||
fi
|
||||
|
||||
case "${1:-}" in
|
||||
bypass|by) cmd_bypass ;;
|
||||
bypass|by) cmd_bypass "$@" ;;
|
||||
suppress|sv) cmd_suppress ;;
|
||||
admin|adm) cmd_admin ;;
|
||||
admin|adm) cmd_admin "$@" ;;
|
||||
heal) cmd_heal ;;
|
||||
persist) cmd_persist ;;
|
||||
unpersist) cmd_unpersist ;;
|
||||
@@ -3439,7 +3505,7 @@ main() {
|
||||
whitelist|wl) cmd_whitelist ;;
|
||||
backup) cmd_backup ;;
|
||||
restore) cmd_restore ;;
|
||||
dualboot) cmd_dualboot ;;
|
||||
dualboot) cmd_dualboot "$@" ;;
|
||||
status|st|ls) cmd_status ;;
|
||||
check) cmd_check ;;
|
||||
history) cmd_history ;;
|
||||
|
||||
Reference in New Issue
Block a user