From 8a5311b1e645ca2aab1e416d647cf52bf0be6e7f Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 28 Aug 2023 20:20:04 +0200 Subject: [PATCH] fix(Infinity for Reddit - Spoof client): Support latest version --- .../AbstractClientIdFingerprint.kt | 21 ++++++++++++------- .../GetHttpBasicAuthHeaderFingerprint.kt | 5 +---- .../LoginActivityOnCreateFingerprint.kt | 7 +++---- .../api/patch/SpoofClientPatch.kt | 1 + 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/AbstractClientIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/AbstractClientIdFingerprint.kt index 9099dfefa..03546ebdc 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/AbstractClientIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/AbstractClientIdFingerprint.kt @@ -1,12 +1,17 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.iface.ClassDef +import com.android.tools.smali.dexlib2.iface.Method -abstract class AbstractClientIdFingerprint(classTypeSuffix: String, methodName: String) : MethodFingerprint( - strings = listOf("NOe2iKrPPzwscA"), - customFingerprint = custom@{ methodDef, classDef -> - if (!classDef.type.endsWith(classTypeSuffix)) return@custom false - - methodDef.name == methodName - } -) \ No newline at end of file +/** + * Fingerprint for a method that has the client id hardcoded in it. + * The first string in the fingerprint is the client id. + * + * @param customFingerprint A custom fingerprint. + * @param additionalStrings Additional strings to add to the fingerprint. + */ +abstract class AbstractClientIdFingerprint( + customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null, + vararg additionalStrings: String +) : MethodFingerprint(strings = listOf("NOe2iKrPPzwscA", *additionalStrings), customFingerprint = customFingerprint) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/GetHttpBasicAuthHeaderFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/GetHttpBasicAuthHeaderFingerprint.kt index c7e3f0ae9..59c897deb 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/GetHttpBasicAuthHeaderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/GetHttpBasicAuthHeaderFingerprint.kt @@ -1,6 +1,3 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints -object GetHttpBasicAuthHeaderFingerprint : AbstractClientIdFingerprint( - "APIUtils;", - "getHttpBasicAuthHeader" -) \ No newline at end of file +object GetHttpBasicAuthHeaderFingerprint : AbstractClientIdFingerprint(additionalStrings = arrayOf("Authorization")) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt index 740fd318d..26687b4ee 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt @@ -1,6 +1,5 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints -object LoginActivityOnCreateFingerprint : AbstractClientIdFingerprint( - "LoginActivity;", - "onCreate" -) \ No newline at end of file +object LoginActivityOnCreateFingerprint : AbstractClientIdFingerprint(custom@{ methodDef, classDef -> + methodDef.name == "onCreate" && classDef.type.endsWith("LoginActivity;") +}) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/patch/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/patch/SpoofClientPatch.kt index 180ff8931..646afb11e 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/patch/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/patch/SpoofClientPatch.kt @@ -25,6 +25,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch( ) { override fun List.patchClientId(context: BytecodeContext) { forEach { + // First is index of the clientId string. val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index it.mutableMethod.apply { val oAuthClientIdRegister = getInstruction(clientIdIndex).registerA