fix(Reddit is Fun - Spoof client): Fix login by updating the authorization subdomain from "old" to "ssl"

This commit is contained in:
oSumAtrIX 2024-05-06 20:41:37 +02:00
parent a5172509ec
commit b156cb1d89
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 24 additions and 5 deletions

View file

@ -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 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 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 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 public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V
} }

View file

@ -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.BasicAuthorizationFingerprint
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BuildAuthorizationStringFingerprint import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BuildAuthorizationStringFingerprint
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.GetUserAgentFingerprint 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.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
@Suppress("unused") @Suppress("unused")
object SpoofClientPatch : BaseSpoofClientPatch( object SpoofClientPatch : BaseSpoofClientPatch(
@ -20,8 +22,8 @@ object SpoofClientPatch : BaseSpoofClientPatch(
userAgentFingerprints = setOf(GetUserAgentFingerprint), userAgentFingerprints = setOf(GetUserAgentFingerprint),
compatiblePackages = setOf( compatiblePackages = setOf(
CompatiblePackage("com.andrewshu.android.reddit"), CompatiblePackage("com.andrewshu.android.reddit"),
CompatiblePackage("com.andrewshu.android.redditdonation") CompatiblePackage("com.andrewshu.android.redditdonation"),
) ),
) { ) {
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) { override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
/** /**
@ -59,7 +61,23 @@ object SpoofClientPatch : BaseSpoofClientPatch(
""" """
const-string v0, "$userAgent" const-string v0, "$userAgent"
return-object v0 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\"",
) )
} }
} }
}