From ae7a150629e8d5ee1a7727f7d0dec99df68e0f4d Mon Sep 17 00:00:00 2001 From: secp192k1 Date: Mon, 9 Mar 2026 02:32:24 +0000 Subject: [PATCH] feat(Universal): Spoof Security Level Forces apps to see Keymaster and Attestation security levels as 'StrongBox' (Level 2). --- .../spoof/SpoofKeystoreSecurityLevelPatch.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 patches/src/main/kotlin/app/revanced/patches/all/misc/spoof/SpoofKeystoreSecurityLevelPatch.kt diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/spoof/SpoofKeystoreSecurityLevelPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/spoof/SpoofKeystoreSecurityLevelPatch.kt new file mode 100644 index 0000000000..199aca86b8 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/spoof/SpoofKeystoreSecurityLevelPatch.kt @@ -0,0 +1,28 @@ +package app.revanced.patches.all.misc.spoof + +import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.patch.bytecodePatch + +@Suppress("unused") +val spoofKeystoreSecurityLevelPatch = bytecodePatch( + name = "Spoof Security Level", + description = "Forces apps to see Keymaster and Attestation security levels as 'StrongBox' (Level 2).", + use = false +) { + apply { + classDefs.toList().forEach { classDef -> + val mutableClass = classDefs.getOrReplaceMutable(classDef) + + mutableClass.methods.forEach { method -> + val name = method.name.lowercase() + + // Match methods like getKeymasterSecurityLevel or getAttestationSecurityLevel + if (name.contains("securitylevel") && method.returnType == "I") { + if (method.implementation?.instructions?.iterator()?.hasNext() == true) { + method.replaceInstructions(0, "const/4 v0, 0x2\nreturn v0") + } + } + } + } + } +} \ No newline at end of file