diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 672e1808..79cdad29 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -555,6 +555,7 @@ public final class app/revanced/patches/reddit/customclients/baconreader/api/Spo public final class app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V + public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } public final class app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { @@ -577,6 +578,11 @@ public final class app/revanced/patches/reddit/customclients/joeyforreddit/ads/D public final class app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V + public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V +} + +public final class app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/AuthUtilityUserAgent : app/revanced/patcher/fingerprint/MethodFingerprint { + public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/AuthUtilityUserAgent; } public final class app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch : app/revanced/patcher/patch/BytecodePatch { @@ -621,6 +627,7 @@ public final class app/revanced/patches/reddit/customclients/syncforreddit/api/S public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforreddit/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 } public final class app/revanced/patches/reddit/customclients/syncforreddit/detection/piracy/DisablePiracyDetectionPatch : app/revanced/patcher/patch/BytecodePatch { diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index e7a76441..27cbaf88 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -5,15 +5,14 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint -import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.LoginActivityOnCreateFingerprint - +import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.JRAWUserAgent @Suppress("unused") object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "http://rubenmayayo.com", clientIdFingerprints = setOf(GetClientIdFingerprint), - userAgentFingerprints = setOf(LoginActivityOnCreateFingerprint), - compatiblePackages = setOf(CompatiblePackage("com.rubenmayayo.reddit")) + userAgentFingerprints = setOf(JRAWUserAgent), + compatiblePackages = setOf(CompatiblePackage("com.rubenmayayo.reddit")), ) { override fun Set.patchClientId(context: BytecodeContext) { first().mutableMethod.addInstructions( @@ -21,7 +20,17 @@ object SpoofClientPatch : BaseSpoofClientPatch( """ const-string v0, "$clientId" return-object v0 - """ + """, + ) + } + + override fun Set.patchUserAgent(context: BytecodeContext) { + // Use a random user agent. + val randomName = (0..100000).random() + + first().mutableMethod.addInstructions( + 1, + "const-string v3, \"$randomName\"", ) } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/JRAWUserAgent.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/JRAWUserAgent.kt new file mode 100644 index 00000000..feff6358 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/JRAWUserAgent.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object JRAWUserAgent : MethodFingerprint( + strings = listOf("platform", "appId", "version", "redditUsername"), +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt deleted file mode 100644 index be328cdb..00000000 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode - -internal object LoginActivityOnCreateFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST_4 - ), - customFingerprint = { method, classDef -> - method.name == "onCreate" && classDef.type.endsWith("LoginActivity;") - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 78269569..9707df7b 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -2,8 +2,10 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch +import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.AuthUtilityUserAgent import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.DisablePiracyDetectionPatch @@ -12,6 +14,7 @@ import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy. object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "https://127.0.0.1:65023/authorize_callback", clientIdFingerprints = setOf(GetClientIdFingerprint), + userAgentFingerprints = setOf(AuthUtilityUserAgent), compatiblePackages = setOf( CompatiblePackage("o.o.joey"), CompatiblePackage("o.o.joey.pro"), @@ -28,4 +31,18 @@ object SpoofClientPatch : BaseSpoofClientPatch( """ ) } + + override fun Set.patchUserAgent(context: BytecodeContext) { + // Use a random user agent. + val randomName = (0..100000).random() + val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" + + first().mutableMethod.replaceInstructions( + 0, + """ + const-string v0, "$userAgent" + return-object v0 + """, + ) + } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/AuthUtilityUserAgent.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/AuthUtilityUserAgent.kt new file mode 100644 index 00000000..3514e490 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/AuthUtilityUserAgent.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object AuthUtilityUserAgent : MethodFingerprint( + returnType = "Ljava/lang/String;", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + opcodes = listOf(Opcode.APUT_OBJECT), + customFingerprint = { _, classDef -> + classDef.sourceFile == "AuthUtility.java" + }, +) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt index e2a60686..5bab3faa 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,18 +1,16 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint +import app.revanced.util.exception object DisablePiracyDetectionPatch : BytecodePatch(setOf(PiracyDetectionFingerprint)) { override fun execute(context: BytecodeContext) { PiracyDetectionFingerprint.result?.mutableMethod?.addInstruction( 0, - """ - return-void - """ + "return-void", ) ?: throw PiracyDetectionFingerprint.exception } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index 5663a022..3d954c19 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -14,7 +14,6 @@ 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( redirectUri = "redditisfun://auth", @@ -54,7 +53,7 @@ object SpoofClientPatch : BaseSpoofClientPatch( override fun Set.patchUserAgent(context: BytecodeContext) { // Use a random user agent. val randomName = (0..100000).random() - val userAgent = "android:app.revanced.$randomName:v1.0.0 (by /u/revanced)" + val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" first().mutableMethod.addInstructions( 0, diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch.kt index ce058a5c..411a1d18 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch.kt @@ -6,10 +6,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch +import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.* import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetAuthorizationStringFingerprint import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetBearerTokenFingerprint import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.ImgurImageAPIFingerprint -import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.LoadBrowserURLFingerprint import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.DisablePiracyDetectionPatch import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -17,19 +17,18 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference import java.util.* - @Suppress("unused") object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "http://redditsync/auth", miscellaneousFingerprints = setOf(ImgurImageAPIFingerprint), clientIdFingerprints = setOf(GetAuthorizationStringFingerprint), - userAgentFingerprints = setOf(LoadBrowserURLFingerprint), + userAgentFingerprints = setOf(GetUserAgentFingerprint), compatiblePackages = setOf( CompatiblePackage("com.laurencedawson.reddit_sync"), CompatiblePackage("com.laurencedawson.reddit_sync.pro"), - CompatiblePackage("com.laurencedawson.reddit_sync.dev") + CompatiblePackage("com.laurencedawson.reddit_sync.dev"), ), - dependencies = setOf(DisablePiracyDetectionPatch::class) + dependencies = setOf(DisablePiracyDetectionPatch::class), ) { override fun Set.patchClientId(context: BytecodeContext) { forEach { fingerprintResult -> @@ -41,7 +40,7 @@ object SpoofClientPatch : BaseSpoofClientPatch( """ const-string v0, "Basic $auth" return-object v0 - """ + """, ) } ?: throw GetBearerTokenFingerprint.exception }.let { @@ -54,12 +53,12 @@ object SpoofClientPatch : BaseSpoofClientPatch( val newAuthorizationUrl = reference.string.replace( "client_id=.*?&".toRegex(), - "client_id=$clientId&" + "client_id=$clientId&", ) replaceInstruction( occurrenceIndex, - "const-string v$targetRegister, \"$newAuthorizationUrl\"" + "const-string v$targetRegister, \"$newAuthorizationUrl\"", ) } } @@ -72,7 +71,21 @@ object SpoofClientPatch : BaseSpoofClientPatch( it.mutableMethod.replaceInstruction( apiUrlIndex, - "const-string v1, \"https://api.imgur.com/3/image\"" + "const-string v1, \"https://api.imgur.com/3/image\"", + ) + } + + override fun Set.patchUserAgent(context: BytecodeContext) { + // Use a random user agent. + val randomName = (0..100000).random() + val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" + + first().mutableMethod.replaceInstruction( + 0, + """ + const-string v0, "$userAgent" + return-object v0 + """, ) } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/fingerprints/GetUserAgentFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/fingerprints/GetUserAgentFingerprint.kt new file mode 100644 index 00000000..e1aa170e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/fingerprints/GetUserAgentFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object GetUserAgentFingerprint : MethodFingerprint( + strings = listOf("android:com.laurencedawson.reddit_sync"), +)