refactor: Simplify AbstractSpoofClientPatch
class
This commit is contained in:
parent
840b29e989
commit
c003f40a65
|
@ -1,6 +1,7 @@
|
||||||
package app.revanced.patches.reddit.customclients
|
package app.revanced.patches.reddit.customclients
|
||||||
|
|
||||||
import app.revanced.extensions.exception
|
import app.revanced.extensions.exception
|
||||||
|
import app.revanced.patcher.PatchClass
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
||||||
|
@ -9,14 +10,22 @@ import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatc
|
||||||
|
|
||||||
abstract class AbstractSpoofClientPatch(
|
abstract class AbstractSpoofClientPatch(
|
||||||
redirectUri: String,
|
redirectUri: String,
|
||||||
private val clientIdFingerprints: List<MethodFingerprint>,
|
private val miscellaneousFingerprints: Set<MethodFingerprint> = emptySet(),
|
||||||
private val userAgentFingerprints: List<MethodFingerprint>? = null,
|
private val clientIdFingerprints: Set<MethodFingerprint> = emptySet(),
|
||||||
private val miscellaneousFingerprints: List<MethodFingerprint>? = null
|
private val userAgentFingerprints: Set<MethodFingerprint> = emptySet(),
|
||||||
) : BytecodePatch(buildSet {
|
compatiblePackages: Set<CompatiblePackage>,
|
||||||
addAll(clientIdFingerprints)
|
dependencies: Set<PatchClass> = emptySet(),
|
||||||
userAgentFingerprints?.let(::addAll)
|
) : BytecodePatch(
|
||||||
miscellaneousFingerprints?.let(::addAll)
|
name = "Spoof client",
|
||||||
}) {
|
description = "Restores functionality of the app by using custom client ID.",
|
||||||
|
fingerprints = buildSet {
|
||||||
|
addAll(clientIdFingerprints)
|
||||||
|
userAgentFingerprints.let(::addAll)
|
||||||
|
miscellaneousFingerprints.let(::addAll)
|
||||||
|
},
|
||||||
|
compatiblePackages = compatiblePackages,
|
||||||
|
dependencies = dependencies
|
||||||
|
) {
|
||||||
var clientId by stringPatchOption(
|
var clientId by stringPatchOption(
|
||||||
"client-id",
|
"client-id",
|
||||||
null,
|
null,
|
||||||
|
@ -30,9 +39,9 @@ abstract class AbstractSpoofClientPatch(
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
fun List<MethodFingerprint>?.executePatch(
|
fun Set<MethodFingerprint>.executePatch(
|
||||||
patch: List<MethodFingerprintResult>.(BytecodeContext) -> Unit
|
patch: Set<MethodFingerprintResult>.(BytecodeContext) -> Unit
|
||||||
) = this?.map { it.result ?: throw it.exception }?.patch(context)
|
) = this.map { it.result ?: throw it.exception }.toSet().patch(context)
|
||||||
|
|
||||||
clientIdFingerprints.executePatch { patchClientId(context) }
|
clientIdFingerprints.executePatch { patchClientId(context) }
|
||||||
userAgentFingerprints.executePatch { patchUserAgent(context) }
|
userAgentFingerprints.executePatch { patchUserAgent(context) }
|
||||||
|
@ -46,7 +55,7 @@ abstract class AbstractSpoofClientPatch(
|
||||||
* @param context The current [BytecodeContext].
|
* @param context The current [BytecodeContext].
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext)
|
open fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch the user agent.
|
* Patch the user agent.
|
||||||
|
@ -54,8 +63,7 @@ abstract class AbstractSpoofClientPatch(
|
||||||
*
|
*
|
||||||
* @param context The current [BytecodeContext].
|
* @param context The current [BytecodeContext].
|
||||||
*/
|
*/
|
||||||
// Not every client needs to patch the user agent.
|
open fun Set<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {}
|
||||||
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch miscellaneous things such as protection measures.
|
* Patch miscellaneous things such as protection measures.
|
||||||
|
@ -63,6 +71,5 @@ abstract class AbstractSpoofClientPatch(
|
||||||
*
|
*
|
||||||
* @param context The current [BytecodeContext].
|
* @param context The current [BytecodeContext].
|
||||||
*/
|
*/
|
||||||
// Not every client needs to patch miscellaneous things.
|
open fun Set<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) {}
|
||||||
open fun List<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) {}
|
|
||||||
}
|
}
|
|
@ -4,27 +4,22 @@ import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.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.AbstractSpoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint
|
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint
|
||||||
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.RequestTokenFingerprint
|
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.RequestTokenFingerprint
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
|
||||||
compatiblePackages = [
|
|
||||||
CompatiblePackage("com.onelouder.baconreader"),
|
|
||||||
CompatiblePackage("com.onelouder.baconreader.premium")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"http://baconreader.com/auth", listOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint)
|
redirectUri = "http://baconreader.com/auth",
|
||||||
|
clientIdFingerprints = setOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint),
|
||||||
|
compatiblePackages = setOf(
|
||||||
|
CompatiblePackage("com.onelouder.baconreader"),
|
||||||
|
CompatiblePackage("com.onelouder.baconreader.premium")
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
fun MethodFingerprintResult.patch(replacementString: String) {
|
fun MethodFingerprintResult.patch(replacementString: String) {
|
||||||
val clientIdIndex = scanResult.stringsScanResult!!.matches.first().index
|
val clientIdIndex = scanResult.stringsScanResult!!.matches.first().index
|
||||||
|
|
||||||
|
|
|
@ -3,25 +3,20 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.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.AbstractSpoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.Constants.OAUTH_USER_AGENT
|
import app.revanced.patches.reddit.customclients.Constants.OAUTH_USER_AGENT
|
||||||
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
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.LoginActivityOnCreateFingerprint
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
|
||||||
compatiblePackages = [CompatiblePackage("com.rubenmayayo.reddit")]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"http://rubenmayayo.com",
|
redirectUri = "http://rubenmayayo.com",
|
||||||
clientIdFingerprints = listOf(GetClientIdFingerprint),
|
clientIdFingerprints = setOf(GetClientIdFingerprint),
|
||||||
userAgentFingerprints = listOf(LoginActivityOnCreateFingerprint)
|
userAgentFingerprints = setOf(LoginActivityOnCreateFingerprint),
|
||||||
|
compatiblePackages = setOf(CompatiblePackage("com.rubenmayayo.reddit"))
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
first().mutableMethod.addInstructions(
|
first().mutableMethod.addInstructions(
|
||||||
0,
|
0,
|
||||||
"""
|
"""
|
||||||
|
@ -31,7 +26,7 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
||||||
first().let { result ->
|
first().let { result ->
|
||||||
result.mutableMethod.apply {
|
result.mutableMethod.apply {
|
||||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
||||||
|
|
|
@ -3,8 +3,6 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.patcher.util.smali.toInstructions
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||||
|
@ -13,19 +11,13 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
||||||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
|
||||||
compatiblePackages = [
|
|
||||||
CompatiblePackage("ml.docilealligator.infinityforreddit")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"infinity://localhost",
|
redirectUri = "infinity://localhost",
|
||||||
clientIdFingerprints = listOf(APIUtilsFingerprint),
|
clientIdFingerprints = setOf(APIUtilsFingerprint),
|
||||||
|
compatiblePackages = setOf(CompatiblePackage("ml.docilealligator.infinityforreddit"))
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
first().mutableClass.methods.apply {
|
first().mutableClass.methods.apply {
|
||||||
val getClientIdMethod = single { it.name == "getId" }.also(::remove)
|
val getClientIdMethod = single { it.name == "getId" }.also(::remove)
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ import app.revanced.util.Utils.returnEarly
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Unlock subscription",
|
name = "Unlock subscription",
|
||||||
description = "Unlocks the subscription feature but requires a custom client ID.",
|
description = "Unlocks the subscription feature but requires a custom client ID.",
|
||||||
dependencies = [SpoofClientPatch::class],
|
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage("ml.docilealligator.infinityforreddit")
|
CompatiblePackage("ml.docilealligator.infinityforreddit")
|
||||||
]
|
],
|
||||||
|
dependencies = [SpoofClientPatch::class]
|
||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object UnlockSubscriptionPatch : BytecodePatch(
|
object UnlockSubscriptionPatch : BytecodePatch(
|
||||||
|
|
|
@ -3,28 +3,23 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.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.AbstractSpoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint
|
import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint
|
||||||
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.DisablePiracyDetectionPatch
|
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.DisablePiracyDetectionPatch
|
||||||
|
|
||||||
|
|
||||||
@Patch(
|
@Suppress("unused")
|
||||||
name = "Spoof client",
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
redirectUri = "https://127.0.0.1:65023/authorize_callback",
|
||||||
dependencies = [DisablePiracyDetectionPatch::class],
|
clientIdFingerprints = setOf(GetClientIdFingerprint),
|
||||||
compatiblePackages = [
|
compatiblePackages = setOf(
|
||||||
CompatiblePackage("o.o.joey"),
|
CompatiblePackage("o.o.joey"),
|
||||||
CompatiblePackage("o.o.joey.pro"),
|
CompatiblePackage("o.o.joey.pro"),
|
||||||
CompatiblePackage("o.o.joey.dev")
|
CompatiblePackage("o.o.joey.dev")
|
||||||
]
|
),
|
||||||
)
|
dependencies = setOf(DisablePiracyDetectionPatch::class)
|
||||||
@Suppress("unused")
|
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
|
||||||
"https://127.0.0.1:65023/authorize_callback", listOf(GetClientIdFingerprint)
|
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
first().mutableMethod.addInstructions(
|
first().mutableMethod.addInstructions(
|
||||||
0,
|
0,
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -6,29 +6,24 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
|
import app.revanced.patcher.fingerprint.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
|
||||||
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.AbstractSpoofClientPatch
|
||||||
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 com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
|
||||||
compatiblePackages = [
|
|
||||||
CompatiblePackage("com.andrewshu.android.reddit"),
|
|
||||||
CompatiblePackage("com.andrewshu.android.redditdonation")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"redditisfun://auth",
|
redirectUri = "redditisfun://auth",
|
||||||
listOf(BuildAuthorizationStringFingerprint, BasicAuthorizationFingerprint),
|
clientIdFingerprints = setOf(BuildAuthorizationStringFingerprint, BasicAuthorizationFingerprint),
|
||||||
listOf(GetUserAgentFingerprint)
|
userAgentFingerprints = setOf(GetUserAgentFingerprint),
|
||||||
|
compatiblePackages = setOf(
|
||||||
|
CompatiblePackage("com.andrewshu.android.reddit"),
|
||||||
|
CompatiblePackage("com.andrewshu.android.redditdonation")
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
/**
|
/**
|
||||||
* Replaces a one register instruction with a const-string instruction
|
* Replaces a one register instruction with a const-string instruction
|
||||||
* at the index returned by [getReplacementIndex].
|
* at the index returned by [getReplacementIndex].
|
||||||
|
@ -54,7 +49,7 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
last().replaceWith("$clientId:") { last().index + 7 }
|
last().replaceWith("$clientId:") { last().index + 7 }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
||||||
// Use a random user agent.
|
// Use a random user agent.
|
||||||
val randomName = (0..100000).random()
|
val randomName = (0..100000).random()
|
||||||
val userAgent = "android:app.revanced.$randomName:v1.0.0 (by /u/revanced)"
|
val userAgent = "android:app.revanced.$randomName:v1.0.0 (by /u/revanced)"
|
||||||
|
|
|
@ -5,8 +5,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.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.AbstractSpoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.*
|
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.*
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
@ -14,29 +12,26 @@ import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10t
|
||||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t
|
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
|
||||||
compatiblePackages = [
|
|
||||||
CompatiblePackage("free.reddit.news"),
|
|
||||||
CompatiblePackage("reddit.news")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"dbrady://relay",
|
redirectUri = "dbrady://relay",
|
||||||
listOf(
|
miscellaneousFingerprints = setOf(
|
||||||
|
SetRemoteConfigFingerprint,
|
||||||
|
RedditCheckDisableAPIFingerprint
|
||||||
|
),
|
||||||
|
clientIdFingerprints = setOf(
|
||||||
LoginActivityClientIdFingerprint,
|
LoginActivityClientIdFingerprint,
|
||||||
GetLoggedInBearerTokenFingerprint,
|
GetLoggedInBearerTokenFingerprint,
|
||||||
GetLoggedOutBearerTokenFingerprint,
|
GetLoggedOutBearerTokenFingerprint,
|
||||||
GetRefreshTokenFingerprint
|
GetRefreshTokenFingerprint
|
||||||
),
|
),
|
||||||
miscellaneousFingerprints = listOf(
|
compatiblePackages = setOf(
|
||||||
SetRemoteConfigFingerprint,
|
CompatiblePackage("free.reddit.news"),
|
||||||
RedditCheckDisableAPIFingerprint
|
CompatiblePackage("reddit.news")
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
forEach {
|
forEach {
|
||||||
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
|
@ -50,7 +45,7 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun List<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) {
|
||||||
// Do not load remote config which disables OAuth login remotely.
|
// Do not load remote config which disables OAuth login remotely.
|
||||||
first().mutableMethod.addInstructions(0, "return-void")
|
first().mutableMethod.addInstructions(0, "return-void")
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,17 @@ package app.revanced.patches.reddit.customclients.slide.api
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.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.AbstractSpoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
|
||||||
compatiblePackages = [CompatiblePackage("me.ccrama.redditslide")]
|
|
||||||
)
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"http://www.ccrama.me", listOf(GetClientIdFingerprint)
|
redirectUri = "http://www.ccrama.me",
|
||||||
|
clientIdFingerprints = setOf(GetClientIdFingerprint),
|
||||||
|
compatiblePackages = setOf(CompatiblePackage("me.ccrama.redditslide"))
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
first().mutableMethod.addInstructions(
|
first().mutableMethod.addInstructions(
|
||||||
0,
|
0,
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -6,8 +6,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.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.AbstractSpoofClientPatch
|
||||||
import app.revanced.patches.reddit.customclients.Constants.OAUTH_USER_AGENT
|
import app.revanced.patches.reddit.customclients.Constants.OAUTH_USER_AGENT
|
||||||
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetAuthorizationStringFingerprint
|
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetAuthorizationStringFingerprint
|
||||||
|
@ -20,24 +18,21 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@Patch(
|
|
||||||
name = "Spoof client",
|
@Suppress("unused")
|
||||||
description = "Restores functionality of the app by using custom client ID's.",
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
dependencies = [DisablePiracyDetectionPatch::class],
|
redirectUri = "http://redditsync/auth",
|
||||||
compatiblePackages = [
|
miscellaneousFingerprints = setOf(ImgurImageAPIFingerprint),
|
||||||
|
clientIdFingerprints = setOf(GetAuthorizationStringFingerprint),
|
||||||
|
userAgentFingerprints = setOf(LoadBrowserURLFingerprint),
|
||||||
|
compatiblePackages = setOf(
|
||||||
CompatiblePackage("com.laurencedawson.reddit_sync"),
|
CompatiblePackage("com.laurencedawson.reddit_sync"),
|
||||||
CompatiblePackage("com.laurencedawson.reddit_sync.pro"),
|
CompatiblePackage("com.laurencedawson.reddit_sync.pro"),
|
||||||
CompatiblePackage("com.laurencedawson.reddit_sync.dev")
|
CompatiblePackage("com.laurencedawson.reddit_sync.dev")
|
||||||
]
|
),
|
||||||
)
|
dependencies = setOf(DisablePiracyDetectionPatch::class)
|
||||||
@Suppress("unused")
|
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
|
||||||
"http://redditsync/auth",
|
|
||||||
clientIdFingerprints = listOf(GetAuthorizationStringFingerprint),
|
|
||||||
userAgentFingerprints = listOf(LoadBrowserURLFingerprint),
|
|
||||||
miscellaneousFingerprints = listOf(ImgurImageAPIFingerprint)
|
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
forEach { fingerprintResult ->
|
forEach { fingerprintResult ->
|
||||||
fingerprintResult.also { result ->
|
fingerprintResult.also { result ->
|
||||||
GetBearerTokenFingerprint.also { it.resolve(context, result.classDef) }.result?.mutableMethod?.apply {
|
GetBearerTokenFingerprint.also { it.resolve(context, result.classDef) }.result?.mutableMethod?.apply {
|
||||||
|
@ -73,7 +68,7 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the non-commercial Imgur API endpoint.
|
// Use the non-commercial Imgur API endpoint.
|
||||||
override fun List<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) = first().let {
|
override fun Set<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) = first().let {
|
||||||
val apiUrlIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
val apiUrlIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||||
|
|
||||||
it.mutableMethod.replaceInstruction(
|
it.mutableMethod.replaceInstruction(
|
||||||
|
@ -82,7 +77,7 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
override fun Set<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
||||||
first().let { result ->
|
first().let { result ->
|
||||||
val insertIndex = result.scanResult.patternScanResult!!.startIndex
|
val insertIndex = result.scanResult.patternScanResult!!.startIndex
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue