mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(YouTube): add Spoof client
patch
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
package app.revanced.patches.shared.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint.indexOfModelInstruction
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint.indexOfReleaseInstruction
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
|
||||
internal object CreatePlayerRequestBodyWithModelFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
opcodes = listOf(Opcode.OR_INT_LIT16),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
indexOfModelInstruction(methodDef) >= 0
|
||||
&& indexOfReleaseInstruction(methodDef) >= 0
|
||||
}
|
||||
) {
|
||||
fun indexOfModelInstruction(methodDef: Method) =
|
||||
methodDef.indexOfFirstInstruction {
|
||||
getReference<FieldReference>().toString() == "Landroid/os/Build;->MODEL:Ljava/lang/String;"
|
||||
}
|
||||
|
||||
fun indexOfReleaseInstruction(methodDef: Method) =
|
||||
methodDef.indexOfFirstInstruction {
|
||||
getReference<FieldReference>().toString() == "Landroid/os/Build${'$'}VERSION;->RELEASE:Ljava/lang/String;"
|
||||
}
|
||||
}
|
@ -4,10 +4,9 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoFingerprint
|
||||
import app.revanced.patches.shared.spoofappversion.fingerprints.ClientInfoParentFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint.indexOfReleaseInstruction
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceName
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
@ -15,27 +14,21 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
abstract class BaseSpoofAppVersionPatch(
|
||||
private val descriptor: String
|
||||
) : BytecodePatch(
|
||||
setOf(ClientInfoParentFingerprint)
|
||||
setOf(CreatePlayerRequestBodyWithModelFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
ClientInfoParentFingerprint.resultOrThrow().let { parentResult ->
|
||||
ClientInfoFingerprint.resolve(context, parentResult.classDef)
|
||||
CreatePlayerRequestBodyWithModelFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val versionIndex = indexOfReleaseInstruction(this) + 1
|
||||
val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT)
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
ClientInfoFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val versionIndex = getTargetIndexWithFieldReferenceName("RELEASE") + 1
|
||||
val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT)
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $descriptor
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $descriptor
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package app.revanced.patches.shared.spoofappversion.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
|
||||
|
||||
internal object ClientInfoFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
opcodes = listOf(Opcode.OR_INT_LIT16)
|
||||
)
|
@ -1,8 +0,0 @@
|
||||
package app.revanced.patches.shared.spoofappversion.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object ClientInfoParentFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
strings = listOf("Android Wear")
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.shared.clientspoof
|
||||
package app.revanced.patches.shared.spoofuseragent
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
@ -16,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
abstract class BaseClientSpoofPatch(
|
||||
abstract class BaseSpoofUserAgentPatch(
|
||||
private val packageName: String
|
||||
) : BaseTransformInstructionsPatch<Instruction35cInfo>() {
|
||||
override fun filterMap(
|
Reference in New Issue
Block a user