pentest-prep-module — a scripts-only module¶
No system/ overlay, no files installed. This module exists purely to run code at defined points
during boot, and to make those points measurable.
Used by Lab 02 Part 3.
Layout¶
pentest-prep-module/
├── module.prop required metadata
├── skip_mount empty sentinel: do NOT mount a system/ overlay
├── system.prop key=value, applied with resetprop at boot
├── sepolicy.rule magiskpolicy rules, applied at boot
├── post-fs-data.sh BLOCKING, before zygote
├── service.sh NON-BLOCKING, at late_start
├── uninstall.sh at removal
└── README.md this file, not part of the module
The boot stages, and why the split matters¶
| Stage | Script | Blocking? | What exists |
|---|---|---|---|
post-fs-data |
post-fs-data.sh |
Yes — the boot waits | /data mounted. No framework, no services, no apps, no network |
late_start service |
service.sh |
No — runs in parallel | zygote up, framework coming up, boot animation showing |
boot-completed |
boot-completed.sh |
No | Everything |
The single most common way to bootloop a device with a module is to put a wait in
post-fs-data.sh for something that the framework provides. The framework cannot start until you
return; you are waiting for the framework; the boot never completes. Both scripts here are written
to make that impossible: post-fs-data.sh has no loop at all, and service.sh's loop is bounded at
120 iterations.
Install the module, reboot, and read the log to see the stages on your own device:
# adb shell as root
cat /data/local/tmp/pentestprep.log
You get four timestamps with uptimes attached. That is chapter §3.5's table, measured rather than believed.
Build and install¶
# host
cd pentest-prep-module
zip -r /tmp/pentestprep.zip . -x '.*' -x '__MACOSX/*' -x 'README.md'
cd ..
unzip -l /tmp/pentestprep.zip
adb push /tmp/pentestprep.zip /sdcard/Download/
adb shell "su -c 'magisk --install-module /sdcard/Download/pentestprep.zip'"
adb reboot
Testing a change without rebooting¶
Rebooting to test a one-line edit is intolerable. For everything except mounts:
# adb shell as root — run the service script by hand
sh /data/adb/modules/pentestprep/service.sh; echo "exit=$?"
# adb shell as root — apply system.prop by hand
while IFS='=' read -r k v; do
[ -z "$k" ] && continue
case "$k" in \#*) continue;; esac
resetprop "$k" "$v"
done < /data/adb/modules/pentestprep/system.prop
# adb shell as root — apply sepolicy rules live
magiskpolicy --live --apply /data/adb/modules/pentestprep/sepolicy.rule
Mount changes genuinely need a reboot, because they happen at post-fs-data.
Line endings¶
Scripts edited on Windows and saved with CRLF fail on the device with errors like not found on the
first line, because the interpreter treats the trailing carriage return as part of the command name.
# host — diagnose and fix
file service.sh # "with CRLF line terminators" is the smoking gun
sed -i 's/\r$//' service.sh
What this module deliberately does not do¶
| Not done | Why |
|---|---|
Spoof ro.boot.verifiedbootstate, ro.build.tags, ro.debuggable |
Achieves nothing against a check that matters, and makes the device less representative. See the comments in system.prop |
setenforce 0 |
Changes app behaviour and invalidates results. Use targeted magiskpolicy rules |
| Download frida-server | A boot script that fetches an executable is the exact pattern lab 04 teaches you to reject. If you would not accept it from a stranger, do not write it yourself |
| Hide anything | Hiding is DenyList's job, and DenyList's limits are lab 03's subject |