Skip to content

Commit 234f7f4

Browse files
committed
feat: update constants to 123301039
1 parent d0f290e commit 234f7f4

File tree

6 files changed

+45
-30
lines changed

6 files changed

+45
-30
lines changed

spotify_dl_cli/http_client/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
USER_AGENT = "Spotify/123200997 Win32/Windows 10 (10.0.19044; x86[native:x64])"
1+
USER_AGENT = "Spotify/123301039 Win32/Windows 10 (10.0.19044; x86[native:x64])"
22
APP_PLATFORM = "Win32"
3-
SPOTIFY_APP_VERSION = "123200997"
3+
SPOTIFY_APP_VERSION = "123301039"
44

55
BASE_HEADERS = {
66
"user-agent": USER_AGENT,

spotify_dl_cli/playplay_emulator/constants.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
# RVA addresses
22
class ADDR:
33
# 55 8B EC B8 3C 10 00 00 E8 ?? ?? ?? ?? A1 ?? ?? ?? ?? ?? ?? ?? ?? FC 8B 45 0C 53 8B 5D 10 56 8B 75 08 57 89 85 F4 EF FF FF E8 ?? ?? ?? ?? 8B 15 ?? ?? ?? ?? 8B C8 C1 E1 0E BF F0 09 01 00 2B F9 89 85 E4 EF FF FF 6A 10 56 89 95 F8 EF FF FF 8D 04 17 89 BD FC EF FF FF 50 E8 ?? ?? ?? ?? 8B 85 F8 EF FF FF 83 EF 18 89 BD 00 F0 FF FF 83 EF 10
4-
DERIVE_KEY = 0x0084E86A
4+
DERIVE_KEY = 0x0086650A
55

66
# 55 8B EC 53 56 57 E9 ?? ?? ?? ??
7-
INIT_WITH_KEY = 0x00722094
7+
INIT_WITH_KEY = 0x005779BE
88

99
# 88 51 0E 66 85 DB 0F 85 ?? ?? ?? ?? E9 ?? ?? ?? ??
10-
GEN_KEYSTREAM = 0x0072124B
10+
GEN_KEYSTREAM = 0x00576B97
1111

12-
PLAYPLAY_TOKEN = 0x011BFB20
12+
# B8 ?? ?? ?? ?? C3 6A ?? 58 C3
13+
PLAYPLAY_TOKEN = 0x0121C164
14+
15+
16+
class PLAYPLAY_VM:
17+
ADDR_G_WORKSPACE_POOL = 0x01C29918
18+
WORKSPACE_POOL_SIZE = 68096 # 0x10A00
19+
WORKSPACE_CONST_OFFSET = 1024
20+
WORKSPACE_CONST_SIZE = 1536 # 0x600
21+
22+
CONST_TABLE_VA_START = 0x0121C378
23+
CONST_TABLE_VA_END = CONST_TABLE_VA_START + WORKSPACE_CONST_SIZE
1324

1425

1526
class STACK:
@@ -30,4 +41,13 @@ class SIZES:
3041
KEYSTREAM = 16
3142

3243

44+
class STUB_ADDRS:
45+
SECURITY_CHECK_COOKIE = 0x004645F5
46+
THUNK_JMP_RET = 0x01074707
47+
MTX_UNLOCK = 0x0105FC31
48+
CND_SIGNAL = 0x01061224
49+
CND_WAIT = 0x0106130B
50+
UNIQUE_LOCK_CTOR = 0x004EC3F3
51+
52+
3353
MAGIC_RET = 0xDEADBEEF

spotify_dl_cli/playplay_emulator/emulator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ def getDerivedKey(
6565
uc, stack_utils = self._create_uc()
6666
esp = stack_utils.init_stack()
6767

68-
playplay_key_pool_ptr = stack_utils.next_heap(
69-
key_derivation_vm.VM_WORKSPACE_POOL_SIZE
70-
)
68+
playplay_key_pool_ptr = stack_utils.next_heap(PLAYPLAY_VM.WORKSPACE_POOL_SIZE)
7169

7270
key_derivation_vm.init_playplay_vm_workspace(uc, self.pe, playplay_key_pool_ptr)
7371

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import pefile
22
from unicorn.unicorn import Uc
3-
from spotify_dl_cli.playplay_emulator.helpers import pack_u32
4-
5-
ADDR_G_PLAYPLAY_VM_WORKSPACE_POOL = 0x01BC3DE8
6-
VM_WORKSPACE_POOL_SIZE = 68096 # 0x10A00
7-
VM_WORKSPACE_CONST_OFFSET = 1024
8-
VM_WORKSPACE_CONST_SIZE = 1536 # 0x600
9-
10-
CONST_TABLE_VA_START = 0x011BFD18
11-
CONST_TABLE_VA_END = CONST_TABLE_VA_START + VM_WORKSPACE_CONST_SIZE
3+
from .helpers import pack_u32
4+
from .constants import PLAYPLAY_VM as VM
125

136

147
def init_playplay_vm_workspace(uc: Uc, pe: pefile.PE, vm_pool_ptr: int) -> None:
15-
uc.mem_write(ADDR_G_PLAYPLAY_VM_WORKSPACE_POOL, pack_u32(vm_pool_ptr))
16-
uc.mem_write(vm_pool_ptr, b"\x00" * VM_WORKSPACE_POOL_SIZE)
17-
rva_start = CONST_TABLE_VA_START - pe.OPTIONAL_HEADER.ImageBase # type: ignore
8+
uc.mem_write(VM.ADDR_G_WORKSPACE_POOL, pack_u32(vm_pool_ptr))
9+
uc.mem_write(vm_pool_ptr, b"\x00" * VM.WORKSPACE_POOL_SIZE)
10+
rva_start = VM.CONST_TABLE_VA_START - pe.OPTIONAL_HEADER.ImageBase # type: ignore
1811

19-
const_table = pe.get_data(rva_start, CONST_TABLE_VA_END - CONST_TABLE_VA_START)
20-
assert len(const_table) == VM_WORKSPACE_CONST_SIZE
12+
const_table = pe.get_data(
13+
rva_start, VM.CONST_TABLE_VA_END - VM.CONST_TABLE_VA_START
14+
)
15+
assert len(const_table) == VM.WORKSPACE_CONST_SIZE
2116

22-
uc.mem_write(vm_pool_ptr + VM_WORKSPACE_CONST_OFFSET, const_table)
17+
uc.mem_write(vm_pool_ptr + VM.WORKSPACE_CONST_OFFSET, const_table)

spotify_dl_cli/playplay_emulator/patch_binary.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Callable
22

3+
from .constants import STUB_ADDRS
4+
35
STUB_RET = bytes([0xC3])
46

57

@@ -49,12 +51,12 @@ def patch_unique_lock_ctor(image: bytearray, image_base: int, va: int) -> None:
4951
PatchFn = Callable[[bytearray, int, int], None]
5052

5153
PATCHES: tuple[tuple[int, PatchFn], ...] = (
52-
(0x00463D65, patch_ret), # __security_check_cookie
53-
(0x0101F0F7, patch_ret), # thunk jmp -> ret
54-
(0x0100A615, patch_ret_zero), # __Mtx_unlock
55-
(0x0100BBC6, patch_ret_zero), # __Cnd_signal
56-
(0x0100BCAD, patch_ret_zero), # __Cnd_wait
57-
(0x004EA2A6, patch_unique_lock_ctor), # unique_lock ctor
54+
(STUB_ADDRS.SECURITY_CHECK_COOKIE, patch_ret), # __security_check_cookie
55+
(STUB_ADDRS.THUNK_JMP_RET, patch_ret), # thunk jmp -> ret
56+
(STUB_ADDRS.MTX_UNLOCK, patch_ret_zero), # __Mtx_unlock
57+
(STUB_ADDRS.CND_SIGNAL, patch_ret_zero), # __Cnd_signal
58+
(STUB_ADDRS.CND_WAIT, patch_ret_zero), # __Cnd_wait
59+
(STUB_ADDRS.UNIQUE_LOCK_CTOR, patch_unique_lock_ctor), # unique_lock ctor
5860
)
5961

6062

409 KB
Binary file not shown.

0 commit comments

Comments
 (0)