mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-24 19:55:57 +01:00
fix(YouTube - Client spoof): Spoof all user agents
This commit is contained in:
parent
be42124d5c
commit
44a8a13998
@ -1514,10 +1514,12 @@ public final class app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDevic
|
|||||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch : app/revanced/patcher/patch/BytecodePatch {
|
public final class app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch {
|
||||||
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch;
|
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch;
|
||||||
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
|
public synthetic fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Ljava/lang/Object;
|
||||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
public fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Lkotlin/Triple;
|
||||||
|
public synthetic fun transform (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Ljava/lang/Object;)V
|
||||||
|
public fun transform (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Lkotlin/Triple;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch : app/revanced/patcher/patch/BytecodePatch {
|
public final class app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch : app/revanced/patcher/patch/BytecodePatch {
|
||||||
|
@ -1,51 +1,87 @@
|
|||||||
package app.revanced.patches.youtube.misc.fix.playback
|
package app.revanced.patches.youtube.misc.fix.playback
|
||||||
|
|
||||||
import app.revanced.util.exception
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.UserAgentHeaderBuilderFingerprint
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import app.revanced.patches.all.misc.transformation.BaseTransformInstructionsPatch
|
||||||
|
import app.revanced.patches.all.misc.transformation.IMethodCall
|
||||||
|
import app.revanced.patches.all.misc.transformation.Instruction35cInfo
|
||||||
|
import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
|
||||||
|
import app.revanced.util.getReference
|
||||||
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
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
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Client spoof",
|
name = "Client spoof",
|
||||||
description = "Adds options to spoof the client to allow video playback.",
|
description = "Adds options to spoof the client to allow video playback.",
|
||||||
dependencies = [SpoofSignaturePatch::class],
|
dependencies = [SpoofSignaturePatch::class],
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage(
|
CompatiblePackage("com.google.android.youtube"),
|
||||||
"com.google.android.youtube", [
|
],
|
||||||
"18.48.39",
|
|
||||||
"18.49.37",
|
|
||||||
"19.01.34",
|
|
||||||
"19.02.39",
|
|
||||||
"19.03.36",
|
|
||||||
"19.04.38",
|
|
||||||
"19.05.36",
|
|
||||||
"19.06.39",
|
|
||||||
"19.07.40",
|
|
||||||
"19.08.36",
|
|
||||||
"19.09.37"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
object ClientSpoofPatch : BytecodePatch(
|
object ClientSpoofPatch : BaseTransformInstructionsPatch<Instruction35cInfo>() {
|
||||||
setOf(UserAgentHeaderBuilderFingerprint)
|
|
||||||
) {
|
|
||||||
private const val ORIGINAL_PACKAGE_NAME = "com.google.android.youtube"
|
private const val ORIGINAL_PACKAGE_NAME = "com.google.android.youtube"
|
||||||
|
private const val USER_AGENT_STRING_BUILDER_APPEND_METHOD_REFERENCE =
|
||||||
|
"Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;"
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun filterMap(
|
||||||
UserAgentHeaderBuilderFingerprint.result?.let { result ->
|
classDef: ClassDef,
|
||||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
method: Method,
|
||||||
result.mutableMethod.apply {
|
instruction: Instruction,
|
||||||
val packageNameRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
instructionIndex: Int,
|
||||||
|
) = filterMapInstruction35c<MethodCall>(
|
||||||
|
"Lapp/revanced/integrations",
|
||||||
|
classDef,
|
||||||
|
instruction,
|
||||||
|
instructionIndex,
|
||||||
|
)
|
||||||
|
|
||||||
addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"")
|
override fun transform(mutableMethod: MutableMethod, entry: Instruction35cInfo) {
|
||||||
}
|
val (_, _, instructionIndex) = entry
|
||||||
|
|
||||||
} ?: throw UserAgentHeaderBuilderFingerprint.exception
|
// Replace the result of context.getPackageName(), if it is used in a user agent string.
|
||||||
|
mutableMethod.apply {
|
||||||
|
// After context.getPackageName() the result is moved to a register.
|
||||||
|
val targetRegister = (
|
||||||
|
getInstruction(instructionIndex + 1)
|
||||||
|
as? OneRegisterInstruction ?: return
|
||||||
|
).registerA
|
||||||
|
|
||||||
|
// IndexOutOfBoundsException is not possible here,
|
||||||
|
// but no such occurrences are present in the app.
|
||||||
|
val referee = getInstruction(instructionIndex + 2).getReference<MethodReference>()?.toString()
|
||||||
|
|
||||||
|
// This can technically also match non-user agent string builder append methods,
|
||||||
|
// but no such occurrences are present in the app.
|
||||||
|
if (referee != USER_AGENT_STRING_BUILDER_APPEND_METHOD_REFERENCE) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overwrite the result of context.getPackageName() with the original package name.
|
||||||
|
replaceInstruction(
|
||||||
|
instructionIndex + 1,
|
||||||
|
"const-string v$targetRegister, \"${ORIGINAL_PACKAGE_NAME}\"",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
private enum class MethodCall(
|
||||||
|
override val definedClassName: String,
|
||||||
|
override val methodName: String,
|
||||||
|
override val methodParams: Array<String>,
|
||||||
|
override val returnType: String,
|
||||||
|
) : IMethodCall {
|
||||||
|
GetPackageName(
|
||||||
|
"Landroid/content/Context;",
|
||||||
|
"getPackageName",
|
||||||
|
emptyArray(),
|
||||||
|
"Ljava/lang/String;",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
internal object UserAgentHeaderBuilderFingerprint : MethodFingerprint(
|
|
||||||
parameters = listOf("L", "L", "L"),
|
|
||||||
opcodes = listOf(Opcode.MOVE_RESULT_OBJECT, Opcode.INVOKE_VIRTUAL),
|
|
||||||
strings = listOf("(Linux; U; Android "),
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user