Files
TEESimulator-RS/module/action.sh
T
Enginex0 2f21cd57a0 feat(action): require vol+ confirm to clear keys
Users reported accidentally triggering the module action button from
the root manager UI, which wiped /data/adb/tricky_store/persistent_keys
and forced every attestation-dependent app to re-enroll.

Gate the destructive operation behind an explicit Vol+ confirmation
with a 10-second timeout. Vol- or timeout aborts and preserves keys.
Pattern mirrors tricky-addon-enhanced/install_func.sh choose_automation
(getevent -qlc 1 polled per second), but defaults to cancel on timeout
because the destructive default of the previous script is the
behavior we are correcting.
2026-05-19 18:31:16 +01:00

66 lines
1.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/system/bin/sh
MODDIR=${0%/*}
CONFIG_DIR=/data/adb/tricky_store
echo " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " ⚠️ Clear Persistent Key Storage"
echo " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " "
echo " This deletes all cached attestation keys."
echo " Apps using attestation will re-enroll on next use."
echo " "
echo " 🔊 Vol+ = Confirm clear"
echo " 🔉 Vol- = Cancel (default after 10s)"
echo " "
confirm() {
vol_tmp="${TMPDIR:-/data/local/tmp}/teesim_vol_key"
seconds=10
: > "$vol_tmp"
getevent -qlc 1 > "$vol_tmp" 2>/dev/null &
ge_pid=$!
while [ "$seconds" -gt 0 ]; do
sleep 1
if ! kill -0 "$ge_pid" 2>/dev/null; then
key=$(awk '/KEY_/{print $3}' "$vol_tmp" 2>/dev/null)
case "$key" in
KEY_VOLUMEUP)
rm -f "$vol_tmp"
return 0
;;
KEY_VOLUMEDOWN)
rm -f "$vol_tmp"
return 1
;;
esac
: > "$vol_tmp"
getevent -qlc 1 > "$vol_tmp" 2>/dev/null &
ge_pid=$!
fi
seconds=$((seconds - 1))
done
kill "$ge_pid" 2>/dev/null
wait "$ge_pid" 2>/dev/null
rm -f "$vol_tmp"
return 1
}
if ! confirm; then
echo " "
echo " ❌ Cancelled — keys preserved"
exit 0
fi
if [ -d "$CONFIG_DIR/persistent_keys" ]; then
rm -rf "$CONFIG_DIR/persistent_keys"
mkdir -p "$CONFIG_DIR/persistent_keys"
echo " "
echo " ✅ Persistent key storage cleared"
else
echo " "
echo " ️ No persistent key storage found"
fi