From a0aa2be86d25aab2803901b4100fdc75461e94bc Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 5 Oct 2023 17:28:10 +0200 Subject: [PATCH] fix(Relay for Reddit - Spoof client): Prevent OAuth login being disabled remotely --- .../relayforreddit/api/SpoofClientPatch.kt | 29 +++++++++++++++++-- .../RedditCheckDisableAPIFingerprint.kt | 9 ++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/RedditCheckDisableAPIFingerprint.kt 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 690e17861..1606817c3 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 @@ -9,6 +9,9 @@ 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.* +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10t +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( @@ -28,7 +31,10 @@ object SpoofClientPatch : AbstractSpoofClientPatch( GetLoggedOutBearerTokenFingerprint, GetRefreshTokenFingerprint ), - miscellaneousFingerprints = listOf(SetRemoteConfigFingerprint) + miscellaneousFingerprints = listOf( + SetRemoteConfigFingerprint, + RedditCheckDisableAPIFingerprint + ) ) { override fun List.patchClientId(context: BytecodeContext) { forEach { @@ -44,7 +50,24 @@ object SpoofClientPatch : AbstractSpoofClientPatch( } } - override fun List.patchMiscellaneous(context: BytecodeContext) = - // Do not load remote config which disables OAuth login remotely + override fun List.patchMiscellaneous(context: BytecodeContext) { + // Do not load remote config which disables OAuth login remotely. first().mutableMethod.addInstructions(0, "return-void") + + // Prevent OAuth login being disabled remotely. + last().let { + val checkIsOAuthRequestIndex = it.scanResult.patternScanResult!!.startIndex + + it.mutableMethod.apply { + val returnNextChain = getInstruction(checkIsOAuthRequestIndex).target + replaceInstruction( + checkIsOAuthRequestIndex, + BuilderInstruction10t( + Opcode.GOTO, + returnNextChain + ) + ) + } + } + } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/RedditCheckDisableAPIFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/RedditCheckDisableAPIFingerprint.kt new file mode 100644 index 000000000..fc0cee335 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/RedditCheckDisableAPIFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.Opcode + +object RedditCheckDisableAPIFingerprint : MethodFingerprint( + strings = listOf("Reddit Disabled"), + opcodes = listOf(Opcode.IF_EQZ) +) \ No newline at end of file