-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathservice.sh
More file actions
195 lines (165 loc) · 5.09 KB
/
service.sh
File metadata and controls
195 lines (165 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/system/bin/sh
MODPATH="${0%/*}"
. $MODPATH/common_func.sh
# Module path and file references
ROOT_SOL=$(detect_root_solution)
SCRIPT="$MODPATH/webroot/common_scripts/autopilot.sh"
LOG_DIR="/data/adb/Box-Brain/Integrity-Box-Logs"
PROP="/data/adb/modules/playintegrityfix/system.prop"
PROP1="ro.crypto.state=encrypted"
PROP2="ro.build.tags=release-keys"
PROP3="ro.build.type=user"
PIF="/data/adb/modules/playintegrityfix"
LOG="$LOG_DIR/service.log"
LOG2="$LOG_DIR/encrypt.log"
LOG3="$LOG_DIR/autopif.log"
LOG4="$LOG_DIR/twrp.log"
LOG5="$LOG_DIR/tag.log"
LOG6="$LOG_DIR/build.log"
# Log folder
mkdir -p "$LOG_DIR"
# Logger function
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') | $1" | tee -a "$LOG"
}
setup_resetprop
# Boot-Phase Properties
# Wait for boot
case "$ROOT_SOL" in
magisk|kernelsu|apatch) $PROP_WAIT sys.boot_completed 0 ;;
esac
# •••• EARLY BOOT PROPS ••••
# Bootloader/VBMeta
resetprop_if_diff "ro.boot.vbmeta.device_state" "locked"
resetprop_if_diff "vendor.boot.vbmeta.device_state" "locked"
resetprop_if_diff "ro.boot.verifiedbootstate" "green"
resetprop_if_diff "vendor.boot.verifiedbootstate" "green"
resetprop_if_diff "ro.boot.flash.locked" "1"
resetprop_if_diff "ro.boot.veritymode" "enforcing"
# Warranty/Debug
resetprop_if_diff "ro.boot.warranty_bit" "0"
resetprop_if_diff "ro.warranty_bit" "0"
resetprop_if_diff "ro.vendor.boot.warranty_bit" "0"
resetprop_if_diff "ro.vendor.warranty_bit" "0"
resetprop_if_diff "ro.debuggable" "0"
resetprop_if_diff "ro.force.debuggable" "0"
resetprop_if_diff "ro.secure" "1"
resetprop_if_diff "ro.adb.secure" "1"
resetprop_if_diff "sys.oem_unlock_allowed" "0"
# Build
resetprop_if_diff "ro.build.type" "user"
resetprop_if_diff "ro.build.tags" "release-keys"
# OEM-Specific
resetprop_if_diff "ro.secureboot.lockstate" "locked" # MIUI
resetprop_if_diff "ro.boot.realmebootstate" "green" # Realme
resetprop_if_diff "ro.boot.realme.lockstate" "1" # Realme
# Recovery Mode Hiding
resetprop_if_match "ro.bootmode" "recovery" "unknown"
resetprop_if_match "ro.boot.bootmode" "recovery" "unknown"
resetprop_if_match "vendor.boot.bootmode" "recovery" "unknown"
# USB/ADB
resetprop_if_diff "sys.usb.adb.disabled" "1"
resetprop_if_diff "service.adb.root" "0"
resetprop_if_diff "persist.sys.developer_options" "0"
resetprop_if_diff "persist.sys.dev_mode" "0"
resetprop_if_diff "persist.sys.debuggable" "0"
resetprop_if_diff "ro.oem_unlock_supported" "0"
resetprop_if_diff "ro.hardware.virtual_device" "0"
# SELinux
resetprop_if_diff "ro.boot.selinux" "enforcing"
[ "$ROOT_SOL" = "magisk" ] && ! [ -f "$MODPATH/skipdelprop" ] && delprop_if_exist "ro.build.selinux"
# Fix SELinux permissions if permissive
#if [ "$(cat /sys/fs/selinux/enforce 2>/dev/null)" = "0" ]; then
# chmod 640 /sys/fs/selinux/enforce 2>/dev/null
# chmod 440 /sys/fs/selinux/policy 2>/dev/null
#fi
# Run compact after early props if supported
run_compact
sleep 120
# Spoof Encryption
{
echo "ENCRYPT CHECK ($(date))"
if [ -f /data/adb/Box-Brain/encrypt ]; then
if grep -qxF "$PROP1" "$PROP"; then
echo "Prop already exists, no action needed"
else
echo "$PROP1" >> "$PROP"
echo "Spoofed prop: $PROP1"
fi
else
if grep -qxF "$PROP1" "$PROP"; then
sed -i "\|^$LINE\$|d" "$PROP"
echo "Removed line: $PROP1"
else
echo "Prop not present, no action needed"
fi
fi
echo
} >> "$LOG2" 2>&1
# Spoof Tag
{
echo "TAG CHECK ($(date))"
if [ -f /data/adb/Box-Brain/tag ]; then
if grep -qxF "$PROP2" "$PROP"; then
echo "Prop already exists, no action needed"
else
echo "$PROP2" >> "$PROP"
echo "Spoofed prop: $PROP2"
fi
else
if grep -qxF "$PROP2" "$PROP"; then
sed -i "\|^$PROP2\$|d" "$PROP"
echo "Removed line: $PROP2"
else
echo "Prop not present, no action needed"
fi
fi
echo
} >> "$LOG5" 2>&1
# Spoof Build
{
echo "BUILD CHECK ($(date))"
if [ -f /data/adb/Box-Brain/build ]; then
if grep -qxF "$PROP3" "$PROP"; then
echo "Prop already exists, no action needed"
else
echo "$PROP3" >> "$PROP"
echo "Spoofed prop: $PROP3"
fi
else
if grep -qxF "$PROP3" "$PROP"; then
sed -i "\|^$PROP3\$|d" "$PROP"
echo "Removed line: $PROP3"
else
echo "Prop not present, no action needed"
fi
fi
echo
} >> "$LOG6" 2>&1
# Rename twrp folder to avoid root detection
{
echo "TWRP/FOX RENAME ($(date))"
echo
[ -f /data/adb/Box-Brain/twrp ] && hide_recovery_folders
} >> "$LOG4" 2>&1
# Stop daemon if needed
if [ -f "/data/adb/Box-Brain/rukja" ]; then
exit 0
fi
# Restart daemon if dead
while true; do
if [ -f "/data/adb/Box-Brain/autopilot" ]; then
# Check heartbeat
last=$(cat /data/adb/Box-Brain/daemon_heartbeat 2>/dev/null || echo "0")
now=$(date +%s)
# Dead if no heartbeat for 3+ minutes
if [ $((now - last)) -gt 180 ]; then
# Clean stale locks
rm -rf /data/adb/Box-Brain/autorun.lockdir \
/data/adb/Box-Brain/.executing 2>/dev/null
# Restart
sh "$SCRIPT" >/dev/null 2>&1 &
fi
fi
sleep 60
done