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 new file mode 100644 index 000000000..766147aca --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootStateFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.finanzonline.detection.bootloader.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object BootStateFingerprint : MethodFingerprint( + "Z", + access = AccessFlags.PUBLIC.value, + strings = listOf("Boot state of device: %s"), + customFingerprint = { methodDef -> + methodDef.definingClass.endsWith("/AttestationHelper;") + } +) 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 new file mode 100644 index 000000000..2d24a6ccc --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/fingerprints/BootloaderDetectionFingerprint.kt @@ -0,0 +1,13 @@ +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", + access = 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/patch/BootloaderDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt new file mode 100644 index 000000000..f608d7529 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.finanzonline.detection.bootloader.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch +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.shared.annotations.DetectionCompatibility + + +@Patch +@Name("remove-bootloader-detection") +@Description("Removes the check for an unlocked bootloader.") +@DetectionCompatibility +@Version("0.0.1") +class BootloaderDetectionPatch : BytecodePatch( + listOf(BootloaderDetectionFingerprint, BootStateFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + arrayOf(BootloaderDetectionFingerprint, BootStateFingerprint).forEach { fingerprint -> + fingerprint.result?.mutableMethod?.addInstruction( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) ?: 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 new file mode 100644 index 000000000..b2e793da4 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/fingerprints/RootDetectionFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.finanzonline.detection.root.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object RootDetectionFingerprint : MethodFingerprint( + "L", + customFingerprint = { methodDef -> + methodDef.definingClass == "Lat/gv/bmf/bmf2go/tools/utils/z;" + } +) 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 new file mode 100644 index 000000000..216ba2cd9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt @@ -0,0 +1,34 @@ +package app.revanced.patches.finanzonline.detection.root.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +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.root.fingerprints.RootDetectionFingerprint +import app.revanced.patches.finanzonline.detection.shared.annotations.DetectionCompatibility + +@Patch +@Name("remove-root-detection") +@Description("Removes the check for root permissions") +@DetectionCompatibility +@Version("0.0.1") +class RootDetectionPatch : BytecodePatch( + listOf(RootDetectionFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + RootDetectionFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + sget-object v0, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean; + 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 new file mode 100644 index 000000000..6bbc58977 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/shared/annotations/DetectionCompatibility.kt @@ -0,0 +1,9 @@ +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"))]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class DetectionCompatibility