config: Install FRP wipe script into recovery /system/bin

Change-Id: I24e217e6af87f2002193ac7b6defb158cce0a776
This commit is contained in:
LuK1337
2025-02-22 17:04:11 +01:00
parent 3d683b1cdc
commit 4d616dc2bb
2 changed files with 72 additions and 0 deletions

View File

@@ -178,6 +178,10 @@ PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST += \
system/%/libfuse-lite.so \
system/%/libntfs-3g.so
# FRP
PRODUCT_COPY_FILES += \
vendor/lineage/prebuilt/common/bin/wipe-frp.sh:$(TARGET_COPY_OUT_RECOVERY)/root/system/bin/wipe-frp
# Openssh
PRODUCT_PACKAGES += \
scp \

68
prebuilt/common/bin/wipe-frp.sh Executable file
View File

@@ -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