-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: Install FRP wipe script into recovery /system/bin
Change-Id: I24e217e6af87f2002193ac7b6defb158cce0a776
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/system/bin/sh | ||
# | ||
# SPDX-FileCopyrightText: 2025 The LineageOS Project | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
FRP_BLOCK=$(getprop ro.frp.pst) | ||
|
||
if [[ -z "${FRP_BLOCK}" ]]; then | ||
echo "FRP prop not set" | ||
exit -1 | ||
fi | ||
|
||
FRP_BLOCK_SIZE=$(blockdev --getsize64 "${FRP_BLOCK}") | ||
|
||
if [[ "${FRP_BLOCK_SIZE}" -le 0 ]]; then | ||
echo "FRP block size <= 0" | ||
exit -1 | ||
fi | ||
|
||
# Calculate offsets | ||
DIGEST_SIZE=32 | ||
DIGEST_OFFSET=0 | ||
|
||
FRP_OEM_UNLOCK_SIZE=1 | ||
FRP_OEM_UNLOCK_OFFSET=$((${FRP_BLOCK_SIZE} - 1)) | ||
|
||
FRP_CREDENTIAL_RESERVED_SIZE=1000 | ||
FRP_CREDENTIAL_RESERVED_OFFSET=$((${FRP_OEM_UNLOCK_OFFSET} - ${FRP_CREDENTIAL_RESERVED_SIZE})) | ||
|
||
TEST_MODE_RESERVED_SIZE=10000 | ||
TEST_MODE_RESERVED_OFFSET=$((${FRP_CREDENTIAL_RESERVED_OFFSET} - ${TEST_MODE_RESERVED_SIZE})) | ||
|
||
FRP_SECRET_SIZE=32 | ||
FRP_SECRET_OFFSET=$((${TEST_MODE_RESERVED_OFFSET} - ${FRP_SECRET_SIZE})) | ||
|
||
FRP_SECRET_MAGIC_SIZE=8 | ||
FRP_SECRET_MAGIC_OFFSET=$((${FRP_SECRET_OFFSET} - ${FRP_SECRET_MAGIC_SIZE})) | ||
|
||
# Clear digest | ||
dd if=/dev/zero of="${FRP_BLOCK}" \ | ||
seek="${DIGEST_OFFSET}" \ | ||
count="${DIGEST_SIZE}" \ | ||
bs=1 | ||
|
||
# Clear credential storage | ||
dd if=/dev/zero of="${FRP_BLOCK}" \ | ||
seek="${FRP_CREDENTIAL_RESERVED_OFFSET}" \ | ||
count="${FRP_CREDENTIAL_RESERVED_SIZE}" \ | ||
bs=1 | ||
|
||
# Clear FRP secret | ||
dd if=/dev/zero of="${FRP_BLOCK}" \ | ||
seek="${FRP_SECRET_OFFSET}" \ | ||
count="${FRP_SECRET_SIZE}" \ | ||
bs=1 | ||
|
||
# Write default FRP secret magic | ||
printf "\xDA\xC2\xFC\xCD\xB9\x1B\x09\x88" | dd of="${FRP_BLOCK}" \ | ||
seek="${FRP_SECRET_MAGIC_OFFSET}" \ | ||
count="${FRP_SECRET_MAGIC_SIZE}" \ | ||
bs=1 | ||
|
||
# Write digest | ||
sha256sum -b "${FRP_BLOCK}" | xxd -r -p | dd of="${FRP_BLOCK}" \ | ||
seek="${DIGEST_OFFSET}" \ | ||
count="${DIGEST_SIZE}" \ | ||
bs=1 |