From d639151641352ce651037b17fb65bd58953cd51c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 15 Apr 2025 12:53:26 +0200 Subject: [PATCH] fix(Spotify): Fix login by replacing `Spoof signature` patch with new `Spoof package info` patch (#4794) Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> --- patches/api/patches.api | 4 ++ .../patches/spotify/misc/fix/Fingerprints.kt | 14 +++- .../spotify/misc/fix/SpoofPackageInfoPatch.kt | 72 +++++++++++++++++++ .../spotify/misc/fix/SpoofSignaturePatch.kt | 26 +------ 4 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofPackageInfoPatch.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index 52dd8348a..711eccede 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -842,6 +842,10 @@ public final class app/revanced/patches/spotify/misc/extension/ExtensionPatchKt public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/spotify/misc/fix/SpoofPackageInfoPatchKt { + public static final fun getSpoofPackageInfoPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/spotify/misc/fix/SpoofSignaturePatchKt { public static final fun getSpoofSignaturePatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt index c6e476c56..f8959ae64 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt @@ -2,4 +2,16 @@ package app.revanced.patches.spotify.misc.fix import app.revanced.patcher.fingerprint -internal val getAppSignatureFingerprint = fingerprint { strings("Failed to get the application signatures") } +internal val getPackageInfoFingerprint = fingerprint { + strings( + "Failed to get the application signatures", + "Failed to get installer package" + ) +} + +internal val getPackageInfoLegacyFingerprint = fingerprint { + strings( + "Failed to get the application signatures" + ) +} + diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofPackageInfoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofPackageInfoPatch.kt new file mode 100644 index 000000000..c06f2a04c --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofPackageInfoPatch.kt @@ -0,0 +1,72 @@ +package app.revanced.patches.spotify.misc.fix + +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.spotify.misc.extension.IS_SPOTIFY_LEGACY_APP_TARGET +import app.revanced.util.addInstructionsAtControlFlowLabel +import app.revanced.util.indexOfFirstInstructionOrThrow +import app.revanced.util.indexOfFirstInstructionReversedOrThrow +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction + +@Suppress("unused") +val spoofPackageInfoPatch = bytecodePatch( + name = "Spoof package info", + description = "Spoofs the package info of the app to fix various functions of the app.", +) { + compatibleWith("com.spotify.music") + + execute { + val getPackageInfoFingerprint = if (IS_SPOTIFY_LEGACY_APP_TARGET) { + getPackageInfoLegacyFingerprint + } else { + getPackageInfoFingerprint + } + + getPackageInfoFingerprint.method.apply { + val stringMatches = getPackageInfoFingerprint.stringMatches!! + + // region Spoof signature. + + val failedToGetSignaturesStringIndex = stringMatches.first().index + + val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow( + failedToGetSignaturesStringIndex, + Opcode.MOVE_RESULT_OBJECT, + ) + + val signatureRegister = getInstruction(concatSignaturesIndex).registerA + val expectedSignature = "d6a6dced4a85f24204bf9505ccc1fce114cadb32" + + replaceInstruction(concatSignaturesIndex, "const-string v$signatureRegister, \"$expectedSignature\"") + + // endregion + + // region Spoof installer name. + + if (IS_SPOTIFY_LEGACY_APP_TARGET) { + // Installer name is not used in the legacy app target. + return@execute + } + + val expectedInstallerName = "com.android.vending" + + val returnInstallerNameIndex = indexOfFirstInstructionOrThrow( + stringMatches.last().index, + Opcode.RETURN_OBJECT + ) + + val installerNameRegister = getInstruction( + returnInstallerNameIndex + ).registerA + + addInstructionsAtControlFlowLabel( + returnInstallerNameIndex, + "const-string v$installerNameRegister, \"$expectedInstallerName\"" + ) + + // endregion + } + } +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofSignaturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofSignaturePatch.kt index 6dfd31e45..7ac278ff3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofSignaturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofSignaturePatch.kt @@ -1,33 +1,13 @@ package app.revanced.patches.spotify.misc.fix -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.util.indexOfFirstInstructionReversedOrThrow -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +@Deprecated("Superseded by spoofPackageInfoPatch", ReplaceWith("spoofPackageInfoPatch")) @Suppress("unused") val spoofSignaturePatch = bytecodePatch( - name = "Spoof signature", - description = "Spoofs the signature of the app to fix various functions of the app.", + description = "Spoofs the signature of the app fix various functions of the app.", ) { compatibleWith("com.spotify.music") - execute { - getAppSignatureFingerprint.method.apply { - val failedToGetSignaturesStringMatch = getAppSignatureFingerprint.stringMatches!!.first() - - val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow( - failedToGetSignaturesStringMatch.index, - Opcode.MOVE_RESULT_OBJECT, - ) - - val register = getInstruction(concatSignaturesIndex).registerA - - val expectedSignature = "d6a6dced4a85f24204bf9505ccc1fce114cadb32" - - replaceInstruction(concatSignaturesIndex, "const-string v$register, \"$expectedSignature\"") - } - } + dependsOn(spoofPackageInfoPatch) }