fix(Relay - Spoof client): Restore OAuth login

This commit is contained in:
oSumAtrIX 2023-09-24 23:54:26 +02:00
parent f355dbf1d2
commit 96e01f7a7b
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 31 additions and 7 deletions

View File

@ -14,9 +14,11 @@ abstract class AbstractSpoofClientPatch(
private val redirectUri: String,
private val clientIdFingerprints: List<MethodFingerprint>,
private val userAgentFingerprints: List<MethodFingerprint>? = null,
private val miscellaneousFingerprints: List<MethodFingerprint>? = null
) : BytecodePatch(buildSet {
addAll(clientIdFingerprints)
userAgentFingerprints?.let(::addAll)
miscellaneousFingerprints?.let(::addAll)
}) {
var clientId by stringPatchOption(
"client-id",
@ -56,10 +58,12 @@ abstract class AbstractSpoofClientPatch(
clientIdFingerprints.executePatch { patchClientId(context) }
userAgentFingerprints.executePatch { patchUserAgent(context) }
miscellaneousFingerprints.executePatch { patchMiscellaneous(context) }
}
/**
* Patch the client ID. The fingerprints are guaranteed to be in the same order as in [clientIdFingerprints].
* Patch the client ID.
* The fingerprints are guaranteed to be in the same order as in [clientIdFingerprints].
*
* @param context The current [BytecodeContext].
*
@ -67,10 +71,19 @@ abstract class AbstractSpoofClientPatch(
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext)
/**
* Patch the user agent. The fingerprints are guaranteed to be in the same order as in [userAgentFingerprints].
* Patch the user agent.
* The fingerprints are guaranteed to be in the same order as in [userAgentFingerprints].
*
* @param context The current [BytecodeContext].
*/
// Not every client needs to patch the user agent.
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {}
/**
* Patch miscellaneous things such as protection measures.
* The fingerprints are guaranteed to be in the same order as in [miscellaneousFingerprints].
*
* @param context The current [BytecodeContext].
*/
open fun List<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) { }
}

View File

@ -1,16 +1,14 @@
package app.revanced.patches.reddit.customclients.relayforreddit.api
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedInBearerTokenFingerprint
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedOutBearerTokenFingerprint
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetRefreshTokenFingerprint
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.LoginActivityClientIdFingerprint
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.*
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(
@ -31,7 +29,8 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
GetLoggedInBearerTokenFingerprint,
GetLoggedOutBearerTokenFingerprint,
GetRefreshTokenFingerprint
)
),
miscellaneousFingerprints = listOf(SetRemoteConfigFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
forEach {
@ -46,4 +45,8 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
}
}
}
override fun List<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) =
// Do not load remote config which disables OAuth login remotely
first().mutableMethod.addInstructions(0, "return-void")
}

View File

@ -0,0 +1,8 @@
package app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SetRemoteConfigFingerprint : MethodFingerprint(
strings = listOf("reddit_oauth_url"),
parameters = listOf("Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig;")
)