Skip to content

Commit d639151

Browse files
fix(Spotify): Fix login by replacing Spoof signature patch with new Spoof package info patch (#4794)
Co-authored-by: LisoUseInAIKyrios <[email protected]>
1 parent 36e2596 commit d639151

File tree

4 files changed

+92
-24
lines changed

4 files changed

+92
-24
lines changed

patches/api/patches.api

+4
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,10 @@ public final class app/revanced/patches/spotify/misc/extension/ExtensionPatchKt
842842
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
843843
}
844844

845+
public final class app/revanced/patches/spotify/misc/fix/SpoofPackageInfoPatchKt {
846+
public static final fun getSpoofPackageInfoPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
847+
}
848+
845849
public final class app/revanced/patches/spotify/misc/fix/SpoofSignaturePatchKt {
846850
public static final fun getSpoofSignaturePatch ()Lapp/revanced/patcher/patch/BytecodePatch;
847851
}

patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@ package app.revanced.patches.spotify.misc.fix
22

33
import app.revanced.patcher.fingerprint
44

5-
internal val getAppSignatureFingerprint = fingerprint { strings("Failed to get the application signatures") }
5+
internal val getPackageInfoFingerprint = fingerprint {
6+
strings(
7+
"Failed to get the application signatures",
8+
"Failed to get installer package"
9+
)
10+
}
11+
12+
internal val getPackageInfoLegacyFingerprint = fingerprint {
13+
strings(
14+
"Failed to get the application signatures"
15+
)
16+
}
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package app.revanced.patches.spotify.misc.fix
2+
3+
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
4+
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
5+
import app.revanced.patcher.patch.bytecodePatch
6+
import app.revanced.patches.spotify.misc.extension.IS_SPOTIFY_LEGACY_APP_TARGET
7+
import app.revanced.util.addInstructionsAtControlFlowLabel
8+
import app.revanced.util.indexOfFirstInstructionOrThrow
9+
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
10+
import com.android.tools.smali.dexlib2.Opcode
11+
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
12+
13+
@Suppress("unused")
14+
val spoofPackageInfoPatch = bytecodePatch(
15+
name = "Spoof package info",
16+
description = "Spoofs the package info of the app to fix various functions of the app.",
17+
) {
18+
compatibleWith("com.spotify.music")
19+
20+
execute {
21+
val getPackageInfoFingerprint = if (IS_SPOTIFY_LEGACY_APP_TARGET) {
22+
getPackageInfoLegacyFingerprint
23+
} else {
24+
getPackageInfoFingerprint
25+
}
26+
27+
getPackageInfoFingerprint.method.apply {
28+
val stringMatches = getPackageInfoFingerprint.stringMatches!!
29+
30+
// region Spoof signature.
31+
32+
val failedToGetSignaturesStringIndex = stringMatches.first().index
33+
34+
val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow(
35+
failedToGetSignaturesStringIndex,
36+
Opcode.MOVE_RESULT_OBJECT,
37+
)
38+
39+
val signatureRegister = getInstruction<OneRegisterInstruction>(concatSignaturesIndex).registerA
40+
val expectedSignature = "d6a6dced4a85f24204bf9505ccc1fce114cadb32"
41+
42+
replaceInstruction(concatSignaturesIndex, "const-string v$signatureRegister, \"$expectedSignature\"")
43+
44+
// endregion
45+
46+
// region Spoof installer name.
47+
48+
if (IS_SPOTIFY_LEGACY_APP_TARGET) {
49+
// Installer name is not used in the legacy app target.
50+
return@execute
51+
}
52+
53+
val expectedInstallerName = "com.android.vending"
54+
55+
val returnInstallerNameIndex = indexOfFirstInstructionOrThrow(
56+
stringMatches.last().index,
57+
Opcode.RETURN_OBJECT
58+
)
59+
60+
val installerNameRegister = getInstruction<OneRegisterInstruction>(
61+
returnInstallerNameIndex
62+
).registerA
63+
64+
addInstructionsAtControlFlowLabel(
65+
returnInstallerNameIndex,
66+
"const-string v$installerNameRegister, \"$expectedInstallerName\""
67+
)
68+
69+
// endregion
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
package app.revanced.patches.spotify.misc.fix
22

3-
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
4-
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
53
import app.revanced.patcher.patch.bytecodePatch
6-
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
7-
import com.android.tools.smali.dexlib2.Opcode
8-
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
94

5+
@Deprecated("Superseded by spoofPackageInfoPatch", ReplaceWith("spoofPackageInfoPatch"))
106
@Suppress("unused")
117
val spoofSignaturePatch = bytecodePatch(
12-
name = "Spoof signature",
13-
description = "Spoofs the signature of the app to fix various functions of the app.",
8+
description = "Spoofs the signature of the app fix various functions of the app.",
149
) {
1510
compatibleWith("com.spotify.music")
1611

17-
execute {
18-
getAppSignatureFingerprint.method.apply {
19-
val failedToGetSignaturesStringMatch = getAppSignatureFingerprint.stringMatches!!.first()
20-
21-
val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow(
22-
failedToGetSignaturesStringMatch.index,
23-
Opcode.MOVE_RESULT_OBJECT,
24-
)
25-
26-
val register = getInstruction<OneRegisterInstruction>(concatSignaturesIndex).registerA
27-
28-
val expectedSignature = "d6a6dced4a85f24204bf9505ccc1fce114cadb32"
29-
30-
replaceInstruction(concatSignaturesIndex, "const-string v$register, \"$expectedSignature\"")
31-
}
32-
}
12+
dependsOn(spoofPackageInfoPatch)
3313
}

0 commit comments

Comments
 (0)