From cc66b1fc6200bbdcc2697ddd7085d46447775be2 Mon Sep 17 00:00:00 2001 From: fe <58902674+1fexd@users.noreply.github.com> Date: Sat, 10 Jun 2023 18:05:47 +0200 Subject: [PATCH] feat(finanzonline): support any version (#2347) --- .../fingerprints/BootStateFingerprint.kt | 25 ++++++++++++++++--- .../BootloaderDetectionFingerprint.kt | 13 ---------- .../fingerprints/CreateKeyFingerprint.kt | 11 ++++++++ .../patch/BootloaderDetectionPatch.kt | 9 ++++--- .../fingerprints/RootDetectionFingerprint.kt | 18 ++++++++++--- .../root/patch/RootDetectionPatch.kt | 1 + .../annotations/DetectionCompatibility.kt | 2 +- 7 files changed, 54 insertions(+), 25 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootloaderDetectionFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/CreateKeyFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootStateFingerprint.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootStateFingerprint.kt index f6aff1191..082ca3121 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootStateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootStateFingerprint.kt @@ -2,12 +2,29 @@ package app.revanced.patches.finanzonline.detection.bootloader.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode +// Located @ at.gv.bmf.bmf2go.taxequalization.tools.utils.AttestationHelper#isBootStateOk (3.0.1) object BootStateFingerprint : MethodFingerprint( "Z", accessFlags = AccessFlags.PUBLIC.value, - strings = listOf("Boot state of device: %s"), - customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/AttestationHelper;") - } + opcodes = listOf( + Opcode.INVOKE_DIRECT, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CONST_4, + Opcode.NEW_ARRAY, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CONST_4, + Opcode.APUT_OBJECT, + Opcode.CONST_STRING, + Opcode.INVOKE_STATIC, + Opcode.SGET_OBJECT, + Opcode.IF_EQ, + Opcode.SGET_OBJECT, + Opcode.IF_NE, + Opcode.GOTO, + Opcode.MOVE, + Opcode.RETURN + ) ) diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootloaderDetectionFingerprint.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootloaderDetectionFingerprint.kt deleted file mode 100644 index 9bfe0ba21..000000000 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootloaderDetectionFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.finanzonline.detection.bootloader.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object BootloaderDetectionFingerprint : MethodFingerprint( - "Z", - accessFlags = AccessFlags.PUBLIC.value, - strings = listOf("Creation of attestation key succeeded", "Creation of attestation key failed"), - customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/AttestationHelper;") - } -) diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/CreateKeyFingerprint.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/CreateKeyFingerprint.kt new file mode 100644 index 000000000..dcfcb0b8e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/CreateKeyFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.finanzonline.detection.bootloader.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +// Located @ at.gv.bmf.bmf2go.taxequalization.tools.utils.AttestationHelper#createKey (3.0.1) +object CreateKeyFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + strings = listOf("attestation", "SHA-256", "random", "EC", "AndroidKeyStore") +) diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt index 0e22b04aa..49ce18b10 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.finanzonline.detection.bootloader.fingerprints.BootStateFingerprint -import app.revanced.patches.finanzonline.detection.bootloader.fingerprints.BootloaderDetectionFingerprint +import app.revanced.patches.finanzonline.detection.bootloader.fingerprints.CreateKeyFingerprint import app.revanced.patches.finanzonline.detection.shared.annotations.DetectionCompatibility @@ -21,11 +21,11 @@ import app.revanced.patches.finanzonline.detection.shared.annotations.DetectionC @DetectionCompatibility @Version("0.0.1") class BootloaderDetectionPatch : BytecodePatch( - listOf(BootloaderDetectionFingerprint, BootStateFingerprint) + listOf(CreateKeyFingerprint, BootStateFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - arrayOf(BootloaderDetectionFingerprint, BootStateFingerprint).forEach { fingerprint -> - fingerprint.result?.mutableMethod?.addInstruction( + arrayOf(CreateKeyFingerprint, BootStateFingerprint).forEach { fingerprint -> + fingerprint.result?.mutableMethod?.addInstructions( 0, """ const/4 v0, 0x1 @@ -33,6 +33,7 @@ class BootloaderDetectionPatch : BytecodePatch( """ ) ?: return fingerprint.toErrorResult() } + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/fingerprints/RootDetectionFingerprint.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/fingerprints/RootDetectionFingerprint.kt index 3c3617dcd..8c0bb011d 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/fingerprints/RootDetectionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/fingerprints/RootDetectionFingerprint.kt @@ -1,10 +1,22 @@ package app.revanced.patches.finanzonline.detection.root.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode +// Located @ at.gv.bmf.bmf2go.taxequalization.tools.utils.RootDetection#isRooted (3.0.1) object RootDetectionFingerprint : MethodFingerprint( "L", - customFingerprint = { methodDef, _ -> - methodDef.definingClass == "Lat/gv/bmf/bmf2go/tools/utils/z;" - } + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("L"), + opcodes = listOf( + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.RETURN_OBJECT + ) ) diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt index 4a3878c8a..c77dac6c8 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt @@ -29,6 +29,7 @@ class RootDetectionPatch : BytecodePatch( return-object v0 """ ) ?: return RootDetectionFingerprint.toErrorResult() + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/shared/annotations/DetectionCompatibility.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/shared/annotations/DetectionCompatibility.kt index 97ddeadb4..8da838bae 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/shared/annotations/DetectionCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/shared/annotations/DetectionCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.finanzonline.detection.shared.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("at.gv.bmf.bmf2go", arrayOf("2.2.0"))]) +@Compatibility([Package("at.gv.bmf.bmf2go")]) @Target(AnnotationTarget.CLASS) internal annotation class DetectionCompatibility