Skip to content

Commit

Permalink
fix(Reddit is Fun - Spoof client): Fix login by updating the authoriz…
Browse files Browse the repository at this point in the history
…ation subdomain from "old" to "ssl"
  • Loading branch information
oSumAtrIX committed May 6, 2024
1 parent a517250 commit b156cb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
/**
Expand Down Expand Up @@ -59,7 +61,23 @@ object SpoofClientPatch : BaseSpoofClientPatch(
"""
const-string v0, "$userAgent"
return-object v0
"""
""",
)
}
}

override fun Set<MethodFingerprintResult>.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<StringReference>()?.contains("old.reddit.com") == true
}

val targetRegister = getInstruction<OneRegisterInstruction>(index).registerA
replaceInstruction(
index,
"const-string v$targetRegister, \"https://ssl.reddit.com/api/v1/authorize.compact\"",
)
}
}
}

0 comments on commit b156cb1

Please sign in to comment.