From 60492aea7863e07d8bf1af9380ae9295ca161f3c Mon Sep 17 00:00:00 2001 From: Cedric Date: Sun, 28 Jul 2024 15:56:12 -0600 Subject: [PATCH] feat(SwissID): Add `Remove Google Play Integrity Integrity check` patch (#3478) Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 6 +++ .../RemoveGooglePlayIntegrityCheck.kt | 37 +++++++++++++++++++ .../fingerprints/CheckIntegrityFingerprint.kt | 11 ++++++ 3 files changed, 54 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheck.kt create mode 100644 src/main/kotlin/app/revanced/patches/swissid/integritycheck/fingerprints/CheckIntegrityFingerprint.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index cba63bcab..e8eba4ec4 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -1178,6 +1178,12 @@ public final class app/revanced/patches/strava/upselling/DisableSubscriptionSugg public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheck : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheck; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/ticktick/misc/themeunlock/UnlockProPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/ticktick/misc/themeunlock/UnlockProPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheck.kt b/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheck.kt new file mode 100644 index 000000000..e65105cc3 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheck.kt @@ -0,0 +1,37 @@ +package app.revanced.patches.swissid.integritycheck + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.swissid.integritycheck.fingerprints.CheckIntegrityFingerprint +import app.revanced.util.resultOrThrow + +@Patch( + name = "Remove Google Play Integrity Integrity check", + description = "Removes the Google Play Integrity check. With this it's possible to use SwissID on custom ROMS." + + "If the device is rooted, root permissions must be hidden from the app.", + compatiblePackages = [CompatiblePackage("com.swisssign.swissid.mobile")], +) +@Suppress("unused") +object RemoveGooglePlayIntegrityCheck : BytecodePatch( + setOf(CheckIntegrityFingerprint), +) { + private const val RESULT_METHOD_REFERENCE = " Lcom/swisssign/deviceintegrity/" + + "DeviceintegrityPlugin\$onMethodCall\$1;->\$result:" + + "Lio/flutter/plugin/common/MethodChannel\$Result;" + private const val SUCCESS_METHOD_REFERENCE = + "Lio/flutter/plugin/common/MethodChannel\$Result;->success(Ljava/lang/Object;)V" + + override fun execute(context: BytecodeContext) = + CheckIntegrityFingerprint.resultOrThrow().mutableMethod.addInstructions( + 0, + """ + iget-object p1, p0, $RESULT_METHOD_REFERENCE + const-string v0, "VALID" + invoke-interface {p1, v0}, $SUCCESS_METHOD_REFERENCE + return-void + """, + ) +} diff --git a/src/main/kotlin/app/revanced/patches/swissid/integritycheck/fingerprints/CheckIntegrityFingerprint.kt b/src/main/kotlin/app/revanced/patches/swissid/integritycheck/fingerprints/CheckIntegrityFingerprint.kt new file mode 100644 index 000000000..ad1fe4fe6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/swissid/integritycheck/fingerprints/CheckIntegrityFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.swissid.integritycheck.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +internal object CheckIntegrityFingerprint : MethodFingerprint( + returnType = "V", + parameters = listOf("Lcom/swisssign/deviceintegrity/model/DeviceIntegrityResult;"), + strings = listOf("it", "result") +)