diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt index 3c198aeb72..373589f0dd 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt @@ -14,9 +14,11 @@ abstract class AbstractSpoofClientPatch( private val redirectUri: String, private val clientIdFingerprints: List, private val userAgentFingerprints: List? = null, + private val miscellaneousFingerprints: List? = 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.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.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.patchMiscellaneous(context: BytecodeContext) { } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt index e9765be153..8cd5613f5a 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt @@ -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.patchClientId(context: BytecodeContext) { forEach { @@ -46,4 +45,8 @@ object SpoofClientPatch : AbstractSpoofClientPatch( } } } + + override fun List.patchMiscellaneous(context: BytecodeContext) = + // Do not load remote config which disables OAuth login remotely + first().mutableMethod.addInstructions(0, "return-void") } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/SetRemoteConfigFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/SetRemoteConfigFingerprint.kt new file mode 100644 index 0000000000..caba6282c7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/SetRemoteConfigFingerprint.kt @@ -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;") +) \ No newline at end of file