From 61e383915bfae31fc21da758c6c1568893a3cd78 Mon Sep 17 00:00:00 2001 From: Joar Heimonen Date: Sun, 3 Sep 2023 13:08:51 +0200 Subject: [PATCH] Merged grindr patch into dev --- .../annotations/GrindrPatchCompatibility.kt | 8 ++ .../app/revanced/patches/grindr/constants.kt | 6 + .../GetCertRegistrationFingerprint.kt | 12 ++ .../GetMessagingCertFingerprint.kt | 12 ++ .../patch/bytecode/FirebaseGetCertPatch.kt | 50 +++++++ .../UnlockUnlimitedCompatibility.kt | 9 ++ .../fingerprints/HasFeatureFingerprint.kt | 17 +++ ...InnaccessibleProfileManagerbFingerprint.kt | 30 +++++ ...InnaccessibleProfileManagerdFingerprint.kt | 15 +++ .../fingerprints/IsFreeFingerprint.kt | 13 ++ .../fingerprints/IsNoPlusUpsellFingerprint.kt | 30 +++++ .../fingerprints/IsNoXtraUpsellFingerprint.kt | 27 ++++ .../fingerprints/IsPlusFingerprint.kt | 30 +++++ .../fingerprints/IsUnlimitedFingerprint.kt | 30 +++++ .../fingerprints/IsXtraFingerprint.kt | 30 +++++ .../fingerprints/ShowStoreFingerprint.kt | 35 +++++ .../grindr/unlimited/patch/setUnlimited.kt | 125 ++++++++++++++++++ 17 files changed, 479 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/grindr/annotations/GrindrPatchCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/constants.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetCertRegistrationFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetMessagingCertFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/patch/bytecode/FirebaseGetCertPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/annotations/UnlockUnlimitedCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/HasFeatureFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerbFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerdFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsFreeFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoPlusUpsellFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoXtraUpsellFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsPlusFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsUnlimitedFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsXtraFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/ShowStoreFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/grindr/unlimited/patch/setUnlimited.kt diff --git a/src/main/kotlin/app/revanced/patches/grindr/annotations/GrindrPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/grindr/annotations/GrindrPatchCompatibility.kt new file mode 100644 index 0000000000..98e901b76e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/annotations/GrindrPatchCompatibility.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.grindr.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.grindrapp.android", arrayOf("9.15.0"))]) +@Target(AnnotationTarget.CLASS) +internal annotation class GrindrPatchCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/constants.kt b/src/main/kotlin/app/revanced/patches/grindr/constants.kt new file mode 100644 index 0000000000..098a4c424d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/constants.kt @@ -0,0 +1,6 @@ +package app.revanced.patches.grindr + +internal object Constants { + const val PACKAGE_NAME = "com.grindrapp.android" + const val SPOOFED_PACKAGE_SIGNATURE = "823F5A17C33B16B4775480B31607E7DF35D67AF8" +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetCertRegistrationFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetCertRegistrationFingerprint.kt new file mode 100644 index 0000000000..3d68435044 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetCertRegistrationFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.grindr.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object GetReqistrationCertFingerprint : MethodFingerprint( + "Ljava/lang/String;", + strings = listOf( + "FirebaseRemoteConfig", + "Could not get fingerprint hash for package: ", + "No such package: " + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetMessagingCertFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetMessagingCertFingerprint.kt new file mode 100644 index 0000000000..76b923ea2e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/fingerprints/GetMessagingCertFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.grindr.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object GetMessagingCertFingerprint : MethodFingerprint( + "Ljava/lang/String;", + strings = listOf( + "ContentValues", + "Could not get fingerprint hash for package: ", + "No such package: " + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/patch/bytecode/FirebaseGetCertPatch.kt b/src/main/kotlin/app/revanced/patches/grindr/patch/bytecode/FirebaseGetCertPatch.kt new file mode 100644 index 0000000000..13400f9d20 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/patch/bytecode/FirebaseGetCertPatch.kt @@ -0,0 +1,50 @@ +package app.revanced.patches.grindr.patch.bytecode + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patches.grindr.fingerprints.GetMessagingCertFingerprint +import app.revanced.patches.grindr.fingerprints.GetReqistrationCertFingerprint +import app.revanced.patches.grindr.Constants.SPOOFED_PACKAGE_SIGNATURE + +import app.revanced.patches.grindr.annotations.GrindrPatchCompatibility + +@Patch +@Name("Firebase patch") +@Description("Allows Grindr to run after being modified by ReVanced.") +@GrindrPatchCompatibility + +class FirebaseGetCertPatch : BytecodePatch( + listOf( + GetReqistrationCertFingerprint, + GetMessagingCertFingerprint + ) +) { + override fun execute(context: BytecodeContext) { + + val spoofedInstruction = + """ + const-string v0, "$SPOOFED_PACKAGE_SIGNATURE" + return-object v0 + """ + + val registrationCertMethod = GetReqistrationCertFingerprint.result!!.mutableMethod + val messagingCertMethod = GetMessagingCertFingerprint.result!!.mutableMethod + + registrationCertMethod.addInstructions( + 0, + spoofedInstruction + ) + messagingCertMethod.addInstructions( + 0, + spoofedInstruction + ) + + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/annotations/UnlockUnlimitedCompatibility.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/annotations/UnlockUnlimitedCompatibility.kt new file mode 100644 index 0000000000..13e4e6010e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/annotations/UnlockUnlimitedCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.grindr.unlimited.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.grindrapp.android")]) +@Target(AnnotationTarget.CLASS) +internal annotation class UnlockUnlimitedCompatibility + diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/HasFeatureFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/HasFeatureFingerprint.kt new file mode 100644 index 0000000000..3489ec8db2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/HasFeatureFingerprint.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +//a + +object HasFeatureFingerprint : MethodFingerprint( + "Z", + parameters = listOf("Lcom/grindrapp/android/model/Feature;"), + customFingerprint = { methodDef, _ -> + methodDef.name.contains("a") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerbFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerbFingerprint.kt new file mode 100644 index 0000000000..c38a786bff --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerbFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +//b + +@FuzzyPatternScanMethod(2) +object InnaccessibleProfileManagerbFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ, + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.SGET_OBJECT, + Opcode.IF_EQ, + Opcode.CONST_4, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.RETURN + ), +) diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerdFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerdFingerprint.kt new file mode 100644 index 0000000000..7dc0057297 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/InnaccessibleProfileManagerdFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +//d + +object InnaccessibleProfileManagerdFingerprint : MethodFingerprint( + customFingerprint = { methodDef, _ -> + methodDef.name == "d" && methodDef.definingClass.contains("InaccessibleProfileManager") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsFreeFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsFreeFingerprint.kt new file mode 100644 index 0000000000..162eb1d91e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsFreeFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object IsFreeFingerprint : MethodFingerprint( + customFingerprint = { methodDef, _ -> + methodDef.name == "r" && methodDef.definingClass.endsWith("storage/s0;") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoPlusUpsellFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoPlusUpsellFingerprint.kt new file mode 100644 index 0000000000..82ddc1d2ec --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoPlusUpsellFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +//A + +object IsNoPlusUpsellFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.RETURN + ), +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoXtraUpsellFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoXtraUpsellFingerprint.kt new file mode 100644 index 0000000000..01e795094d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsNoXtraUpsellFingerprint.kt @@ -0,0 +1,27 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object IsNoXtraUpsellFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.CONST_4, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.RETURN + ), + customFingerprint = { methodDef, _ -> + methodDef.name.contains("h") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsPlusFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsPlusFingerprint.kt new file mode 100644 index 0000000000..2cc03c8a01 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsPlusFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object IsPlusFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.CHECK_CAST, + Opcode.CONST_4, + Opcode.NEW_ARRAY, + Opcode.CONST_4, + Opcode.SGET_OBJECT, + Opcode.APUT_OBJECT, + Opcode.CONST_4, + Opcode.SGET_OBJECT, + Opcode.APUT_OBJECT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT, + Opcode.RETURN + ), + customFingerprint = { methodDef, _ -> + methodDef.name.contains("y") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsUnlimitedFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsUnlimitedFingerprint.kt new file mode 100644 index 0000000000..7a5c35637a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsUnlimitedFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object IsUnlimitedFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.CHECK_CAST, + Opcode.CONST_4, + Opcode.NEW_ARRAY, + Opcode.CONST_4, + Opcode.SGET_OBJECT, + Opcode.APUT_OBJECT, + Opcode.CONST_4, + Opcode.SGET_OBJECT, + Opcode.APUT_OBJECT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT, + Opcode.RETURN + ), + customFingerprint = { methodDef, _ -> + methodDef.name.contains("x") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsXtraFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsXtraFingerprint.kt new file mode 100644 index 0000000000..9c3fb82b3e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/IsXtraFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object IsXtraFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.CHECK_CAST, + Opcode.CONST_4, + Opcode.NEW_ARRAY, + Opcode.CONST_4, + Opcode.SGET_OBJECT, + Opcode.APUT_OBJECT, + Opcode.CONST_4, + Opcode.SGET_OBJECT, + Opcode.APUT_OBJECT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT, + Opcode.RETURN + ), + customFingerprint = { methodDef, _ -> + methodDef.name.contains("p") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/ShowStoreFingerprint.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/ShowStoreFingerprint.kt new file mode 100644 index 0000000000..906d3a9597 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/fingerprints/ShowStoreFingerprint.kt @@ -0,0 +1,35 @@ +package app.revanced.patches.grindr.unlimited.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +//A + +@FuzzyPatternScanMethod(2) +object ShowStoreFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.SGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ, + Opcode.SGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.RETURN + ), +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/grindr/unlimited/patch/setUnlimited.kt b/src/main/kotlin/app/revanced/patches/grindr/unlimited/patch/setUnlimited.kt new file mode 100644 index 0000000000..e4bf07a43e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/grindr/unlimited/patch/setUnlimited.kt @@ -0,0 +1,125 @@ +package app.revanced.patches.grindr.unlimited.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.extensions.exception + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patches.grindr.unlimited.annotations.UnlockUnlimitedCompatibility +import app.revanced.patches.grindr.unlimited.fingerprints.* +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction + +import app.revanced.patches.grindr.patch.bytecode.FirebaseGetCertPatch + +@Patch +@Name("Unlock unlimited") +@Description("Unlocks unlimited features.") +@UnlockUnlimitedCompatibility +@DependsOn([FirebaseGetCertPatch::class]) +class UnlockUnlimitedPatch : BytecodePatch( + listOf( + HasFeatureFingerprint, + IsFreeFingerprint, + IsNoPlusUpsellFingerprint, + IsNoXtraUpsellFingerprint, + IsPlusFingerprint, + IsUnlimitedFingerprint, + IsXtraFingerprint, + InnaccessibleProfileManagerbFingerprint, + InnaccessibleProfileManagerdFingerprint + ) +) { + override fun execute(context: BytecodeContext) { + + val _true = """ + const/4 v0, 0x1 + return v0 + """.trimIndent() + + val _false = """ + const/4 v0, 0x0 + return v0 + """.trimIndent() + + /* + Based on: https://github.com/ElJaviLuki/GrindrPlus + */ + + HasFeatureFingerprint.result?.let { result -> + println("Found HasFeatureFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _true) + } + } ?: throw HasFeatureFingerprint.exception + + IsFreeFingerprint.result?.let { result -> + println("Found IsFreeFingerprint!") + result.mutableMethod.apply { + addInstruction(3, """ + const/4 v0, 0x0 + """.trimIndent()) + } + } ?: throw IsFreeFingerprint.exception + + IsNoPlusUpsellFingerprint.result?.let { result -> + println("Found IsNoPlusUpsellFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _true) + } + } ?: throw IsNoPlusUpsellFingerprint.exception + + IsNoXtraUpsellFingerprint.result?.let { result -> + println("Found IsNoXtraUpsellFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _true) + } + } ?: throw IsNoXtraUpsellFingerprint.exception + + IsPlusFingerprint.result?.let { result -> + println("Found IsPlusFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _false) + } + } ?: throw IsPlusFingerprint.exception + + IsUnlimitedFingerprint.result?.let { result -> + println("Found IsUnlimitedFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _true) + } + } ?: throw IsUnlimitedFingerprint.exception + + IsXtraFingerprint.result?.let { result -> + println("Found IsXtraFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _false) + } + } ?: throw IsXtraFingerprint.exception + + //this must always be true + InnaccessibleProfileManagerbFingerprint.result?.let { result -> + println("Found InnaccessibleProfileManagerbFingerprint!") + result.mutableMethod.apply { + replaceInstructions(0, _true) + } + } ?: throw InnaccessibleProfileManagerbFingerprint.exception + + //this must always be false (the opposite of InnaccessibleProfileManagerbFingerprint) + InnaccessibleProfileManagerdFingerprint.result?.let { result -> + println("Found InnaccessibleProfileManagerdFingerprint!") + result.mutableMethod.apply { + addInstruction(3, """ + const/4 v0, 0x0 + """.trimIndent()) + } + } ?: throw InnaccessibleProfileManagerdFingerprint.exception + } +} \ No newline at end of file