From b156cb1d8996c4314d59e3441c6b85d8f704cdff Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 6 May 2024 20:41:37 +0200 Subject: [PATCH] fix(Reddit is Fun - Spoof client): Fix login by updating the authorization subdomain from "old" to "ssl" --- api/revanced-patches.api | 1 + .../redditisfun/api/SpoofClientPatch.kt | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 356a6d2d7e..d6540eac87 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -576,6 +576,7 @@ public final class app/revanced/patches/reddit/customclients/joeyforreddit/detec public final class app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V + public fun patchMiscellaneous (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index ab110821ec..5663a0223e 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -10,8 +10,10 @@ import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BasicAuthorizationFingerprint import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BuildAuthorizationStringFingerprint import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.GetUserAgentFingerprint +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction - +import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") object SpoofClientPatch : BaseSpoofClientPatch( @@ -20,8 +22,8 @@ object SpoofClientPatch : BaseSpoofClientPatch( userAgentFingerprints = setOf(GetUserAgentFingerprint), compatiblePackages = setOf( CompatiblePackage("com.andrewshu.android.reddit"), - CompatiblePackage("com.andrewshu.android.redditdonation") - ) + CompatiblePackage("com.andrewshu.android.redditdonation"), + ), ) { override fun Set.patchClientId(context: BytecodeContext) { /** @@ -59,7 +61,23 @@ object SpoofClientPatch : BaseSpoofClientPatch( """ const-string v0, "$userAgent" return-object v0 - """ + """, ) } -} \ No newline at end of file + + override fun Set.patchMiscellaneous(context: BytecodeContext) { + // Reddit messed up and does not append a redirect uri to the authorization url to old.reddit.com/login. + // Replace old.reddit.com with ssl.reddit.com to fix this. + BuildAuthorizationStringFingerprint.result!!.mutableMethod.apply { + val index = indexOfFirstInstruction { + getReference()?.contains("old.reddit.com") == true + } + + val targetRegister = getInstruction(index).registerA + replaceInstruction( + index, + "const-string v$targetRegister, \"https://ssl.reddit.com/api/v1/authorize.compact\"", + ) + } + } +}