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