From 00ff1b5ec537edf997192c15e95d1465c99e4c66 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Thu, 6 Mar 2025 12:02:58 +0900 Subject: [PATCH] fix(YouTube - Spoof streaming data): Skip response encryption in OnesiePlayerRequest https://github.com/ReVanced/revanced-patches/pull/4521 --- .../shared/patches/spoof/BlockRequestPatch.java | 14 ++++++++++++++ .../shared/spoof/blockrequest/BlockRequestPatch.kt | 14 +++++++++++++- .../shared/spoof/blockrequest/Fingerprints.kt | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java index 7e90cfce9..cd67891ef 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java @@ -106,4 +106,18 @@ public class BlockRequestPatch { return initPlaybackRequestUri; } + + /** + * Injection point. + * Skip response encryption in OnesiePlayerRequest. + */ + public static boolean skipResponseEncryption(boolean original) { + Logger.printDebug(() -> "response Encryption: " + original); + + if (BLOCK_REQUEST) { + return false; + } + + return original; + } } diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt index dbb60c9af..a2716d3e8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt @@ -4,9 +4,10 @@ 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.extension.Constants.SPOOF_PATH +import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall import app.revanced.util.fingerprint.methodOrThrow +import app.revanced.util.fingerprint.resolvable import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction const val EXTENSION_CLASS_DESCRIPTOR = "$SPOOF_PATH/BlockRequestPatch;" @@ -50,5 +51,16 @@ val blockRequestPatch = bytecodePatch( } // endregion + + // region Skip response encryption in OnesiePlayerRequest + + if (onesieEncryptionFeatureFlagFingerprint.resolvable()) { + onesieEncryptionFeatureFlagFingerprint.injectLiteralInstructionBooleanCall( + ONESIE_ENCRYPTION_FEATURE_FLAG, + "$EXTENSION_CLASS_DESCRIPTOR->skipResponseEncryption(Z)Z" + ) + } + + // endregion } } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt index 2fc03222d..587992c6d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt @@ -41,3 +41,13 @@ internal fun indexOfUriToStringInstruction(method: Method) = getReference().toString() == "Landroid/net/Uri;->toString()Ljava/lang/String;" } +// Feature flag that turns on Platypus programming language code compiled to native C++. +// This code appears to replace the player config after the streams are loaded. +// Flag is present in YouTube 19.34, but is missing Platypus stream replacement code until 19.43. +// Flag and Platypus code is also present in newer versions of YouTube Music. +internal const val ONESIE_ENCRYPTION_FEATURE_FLAG = 45645570L + +internal val onesieEncryptionFeatureFlagFingerprint = legacyFingerprint( + name = "onesieEncryptionFeatureFlagFingerprint", + literals = listOf(ONESIE_ENCRYPTION_FEATURE_FLAG), +)