@@ -9,6 +9,13 @@ MODDIR="$MODPATH"
99_PROP_SPOOF_COUNT=0
1010_PROP_FAIL_COUNT=0
1111
12+ _ZEROMOUNT_ACTIVE=false
13+ _zm_dir=" /data/adb/modules/meta-zeromount"
14+ if [ -d " $_zm_dir " ] && [ ! -f " $_zm_dir /disable" ] && [ ! -f " $_zm_dir /remove" ]; then
15+ _ZEROMOUNT_ACTIVE=true
16+ _log " INFO" " ZeroMount active — deferring overlapping props"
17+ fi
18+
1219ensure_prop () {
1320 NAME=$1
1421 NEWVAL=$2
@@ -28,34 +35,34 @@ if ! resetprop -w sys.boot_completed 0 2>/dev/null; then
2835 _log " WARN" " resetprop -w sys.boot_completed timeout or failure"
2936fi
3037
31- # Core boot verification props
32- check_reset_prop " ro.boot.vbmeta.device_state" " locked"
33- check_reset_prop " ro.boot.verifiedbootstate" " green"
34- check_reset_prop " ro.boot.flash.locked" " 1"
35- check_reset_prop " ro.boot.veritymode" " enforcing"
36- check_reset_prop " ro.boot.warranty_bit" " 0"
37- check_reset_prop " ro.warranty_bit" " 0"
38- check_reset_prop " ro.debuggable" " 0"
39- check_reset_prop " ro.force.debuggable" " 0"
40- check_reset_prop " ro.secure" " 1"
41- check_reset_prop " ro.adb.secure" " 1"
42- check_reset_prop " ro.build.type" " user"
43- check_reset_prop " ro.build.tags" " release-keys"
44- check_reset_prop " ro.vendor.boot.warranty_bit" " 0"
45- check_reset_prop " ro.vendor.warranty_bit" " 0"
46- check_reset_prop " vendor.boot.vbmeta.device_state" " locked"
47- check_reset_prop " vendor.boot.verifiedbootstate" " green"
48- check_reset_prop " sys.oem_unlock_allowed" " 0"
49-
50- # MIUI specific
51- check_reset_prop " ro.secureboot.lockstate " " locked "
52-
53- # Realme specific
54- check_reset_prop " ro.boot.realmebootstate " " green "
55- check_reset_prop " ro.boot.realme.lockstate " " 1 "
56-
57- check_reset_prop " ro.crypto.state " " encrypted "
58- check_reset_prop " ro.is_ever_orange " " 0 "
38+ if [ " $_ZEROMOUNT_ACTIVE " != " true " ] ; then
39+ check_reset_prop " ro.boot.vbmeta.device_state" " locked"
40+ check_reset_prop " ro.boot.verifiedbootstate" " green"
41+ check_reset_prop " ro.boot.flash.locked" " 1"
42+ check_reset_prop " ro.boot.veritymode" " enforcing"
43+ check_reset_prop " ro.boot.warranty_bit" " 0"
44+ check_reset_prop " ro.warranty_bit" " 0"
45+ check_reset_prop " ro.debuggable" " 0"
46+ check_reset_prop " ro.force.debuggable" " 0"
47+ check_reset_prop " ro.secure" " 1"
48+ check_reset_prop " ro.adb.secure" " 1"
49+ check_reset_prop " ro.build.type" " user"
50+ check_reset_prop " ro.build.tags" " release-keys"
51+ check_reset_prop " ro.vendor.boot.warranty_bit" " 0"
52+ check_reset_prop " ro.vendor.warranty_bit" " 0"
53+ check_reset_prop " vendor.boot.vbmeta.device_state" " locked"
54+ check_reset_prop " vendor.boot.verifiedbootstate" " green"
55+ check_reset_prop " sys.oem_unlock_allowed" " 0"
56+
57+ check_reset_prop " ro.secureboot.lockstate " " locked "
58+
59+ check_reset_prop " ro.boot.realmebootstate " " green "
60+ check_reset_prop " ro.boot.realme.lockstate " " 1 "
61+
62+ check_reset_prop " ro.crypto.state " " encrypted "
63+ check_reset_prop " ro.is_ever_orange " " 0 "
64+ fi
65+
5966check_reset_prop " ro.oem_unlock_supported" " 0"
6067check_reset_prop " ro.secureboot.devicelock" " 1"
6168
@@ -72,14 +79,16 @@ if [ "$_region_enabled" = "true" ]; then
7279 [ -n " $_cfg_hw_sku " ] && check_reset_prop " ro.boot.product.hardware.sku" " $_cfg_hw_sku "
7380fi
7481
75- # Delete qemu property entirely -- some detectors check existence, not value
76- if [ -n " $( resetprop ro.kernel.qemu) " ]; then
77- if resetprop --delete ro.kernel.qemu 2> /dev/null; then
78- _PROP_SPOOF_COUNT=$(( _PROP_SPOOF_COUNT + 1 ))
79- else
80- resetprop -n ro.kernel.qemu " " 2> /dev/null
81- _PROP_FAIL_COUNT=$(( _PROP_FAIL_COUNT + 1 ))
82- _log " WARN" " Could not delete ro.kernel.qemu, blanked instead"
82+ if [ " $_ZEROMOUNT_ACTIVE " != " true" ]; then
83+ # Delete qemu property entirely -- some detectors check existence, not value
84+ if [ -n " $( resetprop ro.kernel.qemu) " ]; then
85+ if resetprop --delete ro.kernel.qemu 2> /dev/null; then
86+ _PROP_SPOOF_COUNT=$(( _PROP_SPOOF_COUNT + 1 ))
87+ else
88+ resetprop -n ro.kernel.qemu " " 2> /dev/null
89+ _PROP_FAIL_COUNT=$(( _PROP_FAIL_COUNT + 1 ))
90+ _log " WARN" " Could not delete ro.kernel.qemu, blanked instead"
91+ fi
8392 fi
8493fi
8594
@@ -91,49 +100,49 @@ contains_reset_prop "vendor.bootmode" "recovery" "unknown"
91100contains_reset_prop " vendor.boot.bootmode" " recovery" " unknown"
92101contains_reset_prop " vendor.boot.mode" " recovery" " unknown"
93102
94- # VBMeta digest — prefer TEESimulator's persisted value, fall back to ours
95- _hash_src=" "
96- hash_value=" "
97- if [ -f " $TS_DIR /boot_hash.bin" ]; then
98- hash_value=$( od -A n -t x1 " $TS_DIR /boot_hash.bin" 2> /dev/null | tr -d ' \n' )
99- [ -n " $hash_value " ] && _hash_src=" teesim"
100- fi
101- if [ -z " $hash_value " ] && [ -f " /data/adb/boot_hash" ]; then
102- hash_value=$( grep -v ' ^#' " /data/adb/boot_hash" 2> /dev/null | tr -d ' [:space:]' | tr ' [:upper:]' ' [:lower:]' )
103- [ -n " $hash_value " ] && _hash_src=" boot_hash"
104- fi
105- if echo " $hash_value " | grep -qE ' ^[a-f0-9]{64}$' ; then
106- if resetprop -n ro.boot.vbmeta.digest " $hash_value " 2> /dev/null; then
107- _PROP_SPOOF_COUNT=$(( _PROP_SPOOF_COUNT + 1 ))
108- _log " INFO" " VBMeta digest set from $_hash_src : $( printf ' %.16s' " $hash_value " ) ..."
109- else
110- _PROP_FAIL_COUNT=$(( _PROP_FAIL_COUNT + 1 ))
111- _log " ERROR" " Failed to set vbmeta.digest from $_hash_src "
103+ if [ " $_ZEROMOUNT_ACTIVE " != " true" ]; then
104+ # VBMeta digest — prefer TEESimulator's persisted value, fall back to ours
105+ _hash_src=" "
106+ hash_value=" "
107+ if [ -f " $TS_DIR /boot_hash.bin" ]; then
108+ hash_value=$( od -A n -t x1 " $TS_DIR /boot_hash.bin" 2> /dev/null | tr -d ' \n' )
109+ [ -n " $hash_value " ] && _hash_src=" teesim"
112110 fi
113- elif [ -n " $hash_value " ]; then
114- _log " WARN" " boot_hash invalid from $_hash_src (not 64-char hex)"
115- fi
116-
117- # VBMeta metadata props -- ensure they exist even if kernel didn't set them
118- ensure_prop " ro.boot.vbmeta.device_state" " locked"
119- ensure_prop " ro.boot.vbmeta.invalidate_on_error" " yes"
120- ensure_prop " ro.boot.vbmeta.avb_version" " 1.2"
121- ensure_prop " ro.boot.vbmeta.hash_alg" " sha256"
122-
123- # Dynamic vbmeta_size -- use partition byte size with A/B slot suffix + multi-path fallback
124- slot_suffix=$( getprop ro.boot.slot_suffix 2> /dev/null)
125- VBMETA_SIZE=" "
126- for candidate in \
127- " /dev/block/by-name/vbmeta${slot_suffix} " \
128- " /dev/block/by-name/vbmeta" \
129- " /dev/block/by-name/vbmeta_a" \
130- " /dev/block/by-name/vbmeta_b" ; do
131- if [ -b " $candidate " ]; then
132- VBMETA_SIZE=$( blockdev --getsize64 " $candidate " 2> /dev/null)
133- [ -n " $VBMETA_SIZE " ] && [ " $VBMETA_SIZE " -gt 0 ] 2> /dev/null && break
134- VBMETA_SIZE=" "
111+ if [ -z " $hash_value " ] && [ -f " /data/adb/boot_hash" ]; then
112+ hash_value=$( grep -v ' ^#' " /data/adb/boot_hash" 2> /dev/null | tr -d ' [:space:]' | tr ' [:upper:]' ' [:lower:]' )
113+ [ -n " $hash_value " ] && _hash_src=" boot_hash"
114+ fi
115+ if echo " $hash_value " | grep -qE ' ^[a-f0-9]{64}$' ; then
116+ if resetprop -n ro.boot.vbmeta.digest " $hash_value " 2> /dev/null; then
117+ _PROP_SPOOF_COUNT=$(( _PROP_SPOOF_COUNT + 1 ))
118+ _log " INFO" " VBMeta digest set from $_hash_src : $( printf ' %.16s' " $hash_value " ) ..."
119+ else
120+ _PROP_FAIL_COUNT=$(( _PROP_FAIL_COUNT + 1 ))
121+ _log " ERROR" " Failed to set vbmeta.digest from $_hash_src "
122+ fi
123+ elif [ -n " $hash_value " ]; then
124+ _log " WARN" " boot_hash invalid from $_hash_src (not 64-char hex)"
135125 fi
136- done
137- ensure_prop " ro.boot.vbmeta.size" " ${VBMETA_SIZE:- 4096} "
126+
127+ ensure_prop " ro.boot.vbmeta.device_state" " locked"
128+ ensure_prop " ro.boot.vbmeta.invalidate_on_error" " yes"
129+ ensure_prop " ro.boot.vbmeta.avb_version" " 1.3"
130+ ensure_prop " ro.boot.vbmeta.hash_alg" " sha256"
131+
132+ slot_suffix=$( getprop ro.boot.slot_suffix 2> /dev/null)
133+ VBMETA_SIZE=" "
134+ for candidate in \
135+ " /dev/block/by-name/vbmeta${slot_suffix} " \
136+ " /dev/block/by-name/vbmeta" \
137+ " /dev/block/by-name/vbmeta_a" \
138+ " /dev/block/by-name/vbmeta_b" ; do
139+ if [ -b " $candidate " ]; then
140+ VBMETA_SIZE=$( blockdev --getsize64 " $candidate " 2> /dev/null)
141+ [ -n " $VBMETA_SIZE " ] && [ " $VBMETA_SIZE " -gt 0 ] 2> /dev/null && break
142+ VBMETA_SIZE=" "
143+ fi
144+ done
145+ ensure_prop " ro.boot.vbmeta.size" " ${VBMETA_SIZE:- 4096} "
146+ fi
138147
139148_log " INFO" " Property spoofing complete: $_PROP_SPOOF_COUNT spoofed, $_PROP_FAIL_COUNT failed"
0 commit comments