myTeamSpeak: announce the account ID to servers
Signs clientinit with the account's Ed25519 key over the connection challenge, honours the per-bookmark switch, sends updatemytsid on sign-in/out, and connects without the ID when myTeamSpeak is unreachable. Verified live against server.lixko.eu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Offline check of TS3 3.6.2's authSign challenge derivation (requires unicorn).
|
||||
|
||||
Run with the path to ts3client_linux_amd64. No account or network is used.
|
||||
Emulates the actual packet-key derivation up to its hash call, replacing only
|
||||
allocation, copying, freeing, and mutex functions. Addresses are version-specific.
|
||||
"""
|
||||
import hashlib
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from unicorn import Uc, UC_ARCH_X86, UC_MODE_64, UC_HOOK_CODE
|
||||
from unicorn.x86_const import (
|
||||
UC_X86_REG_RAX, UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX,
|
||||
UC_X86_REG_RCX, UC_X86_REG_R8, UC_X86_REG_R9, UC_X86_REG_RSP,
|
||||
UC_X86_REG_RIP,
|
||||
)
|
||||
|
||||
|
||||
def main(path):
|
||||
with open(path, "rb") as binary:
|
||||
data = binary.read()
|
||||
assert data[:6] == b"\x7fELF\x02\x01", "Expected little-endian ELF64"
|
||||
phoff = struct.unpack_from("<Q", data, 32)[0]
|
||||
phsize, phnum = struct.unpack_from("<HH", data, 54)
|
||||
uc = Uc(UC_ARCH_X86, UC_MODE_64)
|
||||
uc.mem_map(0, 0x2100000)
|
||||
for i in range(phnum):
|
||||
kind, _, offset, addr, _, size, _, _ = struct.unpack_from(
|
||||
"<IIQQQQQQ", data, phoff + i * phsize)
|
||||
if kind == 1 and size:
|
||||
uc.mem_write(addr, data[offset:offset + size])
|
||||
for addr, expected in [(0x2e2211, b"sha256"), (0x2b2164, b"sha512")]:
|
||||
assert bytes(uc.mem_read(addr, len(expected))) == expected
|
||||
uc.mem_map(0x4000000, 0x1000000)
|
||||
obj, shared, out, stack = 0x4000000, 0x4001000, 0x4002000, 0x4fff000
|
||||
shared_iv = bytes(range(64))
|
||||
uc.mem_write(shared, shared_iv)
|
||||
uc.mem_write(obj + 0x1b8, struct.pack("<Q", shared))
|
||||
uc.mem_write(obj + 0x1c0, struct.pack("<I", 2)) # 64-byte sharedIV
|
||||
uc.mem_write(obj + 0x1e8, struct.pack("<II", 0, 123)) # AES128 / sentinel hash index
|
||||
uc.mem_write(obj + 0x209, b"\x01")
|
||||
uc.mem_write(obj + 0x310, struct.pack("<Q", 0x4003000)) # empty key cache
|
||||
uc.mem_write(stack, struct.pack("<Q", 0x10000))
|
||||
for reg, val in [(UC_X86_REG_RDI, out), (UC_X86_REG_RSI, obj),
|
||||
(UC_X86_REG_RDX, 0), (UC_X86_REG_RCX, 0),
|
||||
(UC_X86_REG_R8, 8), (UC_X86_REG_R9, 0),
|
||||
(UC_X86_REG_RSP, stack)]:
|
||||
uc.reg_write(reg, val)
|
||||
heap = 0x4010000
|
||||
captured = []
|
||||
|
||||
def hook(machine, address, size, user):
|
||||
nonlocal heap
|
||||
def ret(value=0):
|
||||
sp = machine.reg_read(UC_X86_REG_RSP)
|
||||
target = struct.unpack("<Q", machine.mem_read(sp, 8))[0]
|
||||
machine.reg_write(UC_X86_REG_RSP, sp + 8)
|
||||
machine.reg_write(UC_X86_REG_RAX, value)
|
||||
machine.reg_write(UC_X86_REG_RIP, target)
|
||||
if address in (0x1ae27a0, 0x1ae3f80): # operator new / new[]
|
||||
ptr = heap
|
||||
heap += (machine.reg_read(UC_X86_REG_RDI) + 31) & ~15
|
||||
ret(ptr)
|
||||
elif address in (0x1ae23a0, 0x1aeb290): # delete / mutex lock
|
||||
ret()
|
||||
elif address == 0x1ae3450: # memmove
|
||||
dst, src, n = [machine.reg_read(r) for r in
|
||||
(UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX)]
|
||||
if n:
|
||||
machine.mem_write(dst, bytes(machine.mem_read(src, n)))
|
||||
ret(dst)
|
||||
elif address == 0x11ec190: # LibTomCrypt hash_memory
|
||||
assert machine.reg_read(UC_X86_REG_RDI) == 123
|
||||
ptr, n = [machine.reg_read(r) for r in (UC_X86_REG_RSI, UC_X86_REG_RDX)]
|
||||
captured.append(bytes(machine.mem_read(ptr, n)))
|
||||
machine.emu_stop()
|
||||
elif address >= 0x1ae0000:
|
||||
raise AssertionError(f"Unexpected external call: {address:x}")
|
||||
|
||||
uc.hook_add(UC_HOOK_CODE, hook)
|
||||
uc.emu_start(0xff4770, 0x10000, count=100000)
|
||||
assert captured == [bytes.fromhex("300800000000") + shared_iv], captured
|
||||
print("Native hash input matches 30 08 00 00 00 00 || sharedIV")
|
||||
print("Synthetic C:", hashlib.sha256(captured[0]).hexdigest())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1])
|
||||
Reference in New Issue
Block a user