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:
2026-10-10 20:04:59 +00:00
co-authored by Claude Opus 5.5
parent ca86c510b7
commit 801dfa39ab
14 changed files with 754 additions and 16 deletions
@@ -4,6 +4,11 @@ What the client has to send so that a server shows our `client_myteamspeak_id`,
official client does when a bookmark has "Enable myTeamSpeak features" on. Observed with TS3 3.6.2
signed in to the throwaway account against the test server, 2026-10-10.
**RE status:** both missing inputs are now recovered and checked offline. The private scalar
unwrap matches the captured account public key; the challenge derivation was exercised in the
actual desktop machine code under Unicorn. Application integration is implemented (see below)
and verified live against server.lixko.eu (2026-10-10). Reproduction programs are linked below.
## The switch
Connect dialog and bookmarks: **"Enable myTeamSpeak features"**, on by default. It is
@@ -24,19 +29,201 @@ for signing in or out while connected. It was not hit during a normal connect.
| `userPubKey` | base64, 32 bytes (Ed25519 public key) | known: login `myts_id_data.user_public_key (1)` |
| `pubSign` | base64, 64 bytes | known: first 64 bytes of login `myts_id_data.public_signature (5)` |
| `pubSignCert` | base64, 112 bytes (certificate naming "TeamSpeak Systems GmbH") | known: remaining 112 bytes of `public_signature (5)` |
| `authSign` | base64, 64 bytes | **unknown, still to find** |
| `authSign` | base64, 64 bytes | raw-scalar Ed25519 over `SHA256(30 08 00 00 00 00 || sharedIV) || "MyTeamSpeakID"` |
`acTime` example: creation time `1790376353` = `0x6AB6F9A1`; as big-endian u64
`a1f9b66a00000000` = `11671560475690139648`.
## Still to find: `authSign`
## `authSign` — reverse-engineered (static, 2026-10-10)
- It is made fresh for each connection. It is not part of the login reply, and replaying an old
one is not expected to work.
- Without valid data the server refuses the ID: `clientupdate client_myteamspeak_id=<anything>`
gives "invalid parameter".
- To find: what `authSign` covers and how the client produces it, using only what our existing
sign-in (`MyTeamSpeakLogin`) already holds.
`authSign` is an **Ed25519 signature** (64 bytes = `R||S`, base64) by the account's user key over a
per-connection message. It is made fresh per connection because the message embeds a
connection-derived challenge, so replaying an old one does not work.
### Where it is built
All six `clientinit`/`updatemytsid` parameters are assembled by one function (call it
`buildMytsidParams`) in the Android `libteamspeak_client.so` (x86-64) at **vaddr 0x813b40**, called
from 3 sites (0x81bda4, 0x81e677, 0x84f2c8 — the clientinit and updatemytsid paths). The desktop
`ts3client_linux_amd64` carries the same code (same strings + SHA-512 K-table). Its args:
- `arg0` (rdi) = the **user keypair** object. Two 32-byte `std::string` members:
`+0x20` = public key `A`, `+0x38` = **raw secret scalar `a`**. In the callers this object is at
`[conn+0x218]`.
- `arg1` (rsi) = the command/parameter map (values inserted via the helper at 0x8b1870).
- `arg2` (rdx) = a reference to a **shared pointer to the connection crypto object**, obtained
through the manager's `vtable+0x70`. It is **not a string**. The builder obtains packet-key
material from this object to construct `C`; see the corrected desktop trace below.
`myTeamspeakId`, `acTime`, `userPubKey`, `pubSign`, `pubSignCert` are just base64 of fields of the
`MyTeamSpeakIdData` struct (offsets 0, +0x18, +0x20, +0x50, +0x68). `authSign` is the odd one out:
its value is `base64(sig)` where `sig` is produced by the signer at **0x94a2a0** over the message
`M = C || "MyTeamSpeakID"` (the literal is appended to the challenge before signing).
### The signer (0x94a2a0) — deterministic Ed25519 over SHA-512
Reconstructed (hash factory 0x9430e0 with selector `1` = SHA-512; `R=r·B` via 0x94ee80;
reduce mod L via 0x94a7b0; `S=r+k·a` via 0x94b310):
```
r = SHA512(a || M) mod L # deterministic nonce, seeded by the raw scalar a
R = r · B # 32-byte encoded point -> sig[0:32]
k = SHA512(R || A || M) mod L
S = (r + k · a) mod L # -> sig[32:64]
authSign = base64(R || S)
```
Because `R = r·B` and `A = a·B`, this is a **standard, stock-verifiable Ed25519 signature over `M`
under public key `A`** — the server almost certainly just runs `ed25519_verify(authSign, M, A)`.
The signature equation is standard Ed25519, although nonce derivation and secret-key format differ
from RFC 8032. A standard verifier accepts this construction. We can reproduce the exact nonce
using the existing ref10 arithmetic; there is no need to rely on untested alternative nonces.
**Correction:** Bouncy Castle's public low-level signing overloads also take a seed. Passing `a`
as that seed hashes and clamps it again and gives the wrong key. Its raw-scalar signing internals
are private; stock TweetNaCl's signing entry point is seed-based too.
## Dynamic capture — scheme CONFIRMED live (2026-10-10)
Ran the official TS3 3.6.2 client under Xvfb (`GLIBC_TUNABLES=glibc.pthread.rseq=0` to stop a
`mutex lock failed` crash on new glibc; the xcb/libpci lib shim set from the prior harness), signed
in to the throwaway myTeamSpeak account, and connected to `server.lixko.eu:9987` with "Enable
myTeamSpeak features" on. gdb attached as root (yama scope=1 → `sudo gdb`), breakpoint at the signer.
**The server accepted the real `authSign` ("Connection established")**, so the model below is the live
protocol, not a guess.
Desktop addresses (PIE; add the load bias): signer **0x1196800** (= Android 0x94a2a0),
`buildMytsidParams` **0x1018580**, its clientinit caller **0x1020c3b**. At the signer: `rcx`=`A`,
`r8`=`a`, `rsi`/`rdx`=`M`, `rdi`=out(`R||S`).
### Ground truth (throwaway account)
```
a (secret scalar) = e02e4e5f22623f82389e469e56290ac046c13f7ecc6fde99d17360d1f4bfd67a
A (public key) = 4ffcab6e0aeefbcbc0b4bbbe25b7e36c171016f73a65c3a71dd4bb5a9f5dab8e
M = C || "MyTeamSpeakID" (C = 32 bytes, then the 13-byte ASCII literal; rdx = 45)
```
Verified offline (pure-Python Ed25519 + `cryptography`): **`A == a·B`** (so `a` is the raw Ed25519
scalar, `A` the public key), and the deterministic scheme above produces a signature that **passes
stock `Ed25519PublicKey(A).verify(sig, M)`**. This confirms compatibility with stock Ed25519
verification, not the server's exact implementation. `A` is the `userPubKey`/`user_public_key`
param (it is NOT the 31-byte body of the `myTeamspeakId`).
### `C` recovered: packet key + nonce for type 8, server direction, generation 0
For the captured AES-128/SHA-256 connection mode:
```
sharedIV = SHA512(encoded_Ed25519_DH_point) XOR (alpha[10] || beta[54])
C = SHA256(hex("30 08 00 00 00 00") || sharedIV)
M = C || ASCII("MyTeamSpeakID") # exactly 45 bytes, no NUL terminator
```
`sharedIV` is precisely ts3j's `SecureChannelParameters.ivStruct` / the value passed into
`PacketTransformation`. It is not the raw shared secret. `30` is the server-direction tag,
`08` is packet type 8, and the four zeros are the big-endian generation counter. Packet ID is
also zero, so the usual XOR of the first two key bytes changes nothing. Equivalently, obtain
`key || nonce` from `PacketTransformation.computeParameters` with a SERVER header of type 8,
generation 0 and packet ID 0. Do not use the CLIENT direction merely because we are the client.
Corrected desktop trace (all addresses are PIE-relative):
| Address | Evidence |
|---|---|
| `0x1020c05` | manager virtual call returns a shared pointer at `rsp+0x88` |
| `0x105a270` → `0x105ed30` | selects enum key 1 in map at manager `+0x110`; returns two pointers and increments reference count, **not a std::string** |
| `0x1018a57`–`0x1018a6f` | dereferences that shared pointer; calls `0xff4770(out, crypto, 0, 0, 8, 0)` |
| `0xff496d`–`0xff4a89` | builds direction/type/generation prefix `30 08 00 00 00 00` |
| `0xff4a92`–`0xff4b77` | appends bytes from crypto `+0x1b8`, 64 bytes for handshake mode 2/3, otherwise 20 |
| `0xff4ba9` | calls LibTomCrypt `hash_memory` with the configured hash selector |
| `0xfef971`–`0xfef97d` | cipher mode 0 selects the literal `sha256`; mode 1 selects `sha512` at `0xfef953` |
| `0xff4ed8`–`0xff4ee9` | XORs packet ID into the key's first two bytes (zero here) |
| `0x1018acc`–`0x1018bcb` | copies and concatenates key and nonce (16+16 bytes in mode 0; 32+32 in mode 1) |
| `0x1018ce3`–`0x1018cfb` | appends the 13-byte literal before signing |
The sharedIV buffer is XORed with the handshake secret at `0xff2a08` (64 bytes) through
`0x129b9d0`, an in-place XOR helper. The same buffer feeds ordinary packet key derivation.
This explains why searching the manager's inline memory for plain SHA-256 preimages failed:
the buffer is in a different object and the hash has a six-byte prefix.
The previous captures of different `C` values remain useful, but `C.bin`/`C_obj.bin` from the
old string-decoding harness are not reliable challenge dumps: those interpreted a shared pointer
as a libc++ string. The signer message captures (`msg*.bin`) are the reliable `C || literal` bytes.
The native code also supports a SHA-512, 32-byte key + 32-byte nonce mode; its binder would be
64 bytes and message 77 bytes. The observed session and current ts3j packet cipher use mode 0.
Do not generalize the 32-byte challenge to every possible negotiated cipher mode.
### Scalar unwrap recovered and verified
```
accountKey = PBKDF2_HMAC_SHA512(password, lower(email)+"ts3Encryption"+password, 10000, 32)
itemKey = MyTsCrypto.unwrapItemKey(accountKey, LoginSession.key)
a = MyTsCrypto.decryptItem(encrypted_user_private_key, itemKey)
assert len(a) == 32
assert encode(a * B) == user_public_key
```
The 112-byte blob is the existing item frame: `IV[16] || ciphertext[32] || SHA512(a)[64]`,
AES-256-CTR with little-endian counter increments. No additional KDF or scalar clamping occurs
after decryption. The captured blob passes the digest check and produces **exactly** the live
scalar above. Deriving a public key from that value as a Bouncy Castle seed produces a different
public key, independently confirming the distinction.
### Library choice and reproducible checks
Use existing JCA `MyTsCrypto` for key unwrap and existing ts3j ref10 primitives for signing:
`ScalarOperations.sc_reduce`, `GroupOperations.ge_scalarmult_base`,
`GroupOperations.ge_p3_tobytes`, and `ScalarOperations.sc_muladd`. The thin signing adapter is
in [MyTsAuthCheck.java](MyTsAuthCheck.java); it implements the formula above without new curve
arithmetic. `Punisher.NaCl.Ed25519.Sign` itself is also seed-based despite its parameter being
called `expandedPrivateKey`, so do not call it with `a || A`.
Bouncy Castle 1.86 can verify these signatures directly. Its public signer cannot sign from the
raw scalar; [upstream Ed25519 source](https://github.com/bcgit/bc-java/blob/main/core/src/main/java/org/bouncycastle/math/ec/rfc8032/Ed25519.java)
keeps the scalar-based `implSign` and base-point helpers private. Reflection into these internals
is unnecessary. This is plain Ed25519 verification, not Ed25519ph or Ed25519ctx; the literal is
part of the message, not an RFC 8032 context parameter.
From the workspace root, with ts3j compiled and BC 1.86 in the local Maven cache:
```sh
python3 ts3-client/docs/myteamspeak/check_native_challenge.py TeamSpeak3-Client-linux_amd64/ts3client_linux_amd64
mkdir -p /tmp/myts-auth-check
auth_cp="ts3j/target/classes:$HOME/.m2/repository/org/bouncycastle/bcprov-jdk18on/1.86/bcprov-jdk18on-1.86.jar"
javac -cp "$auth_cp" -d /tmp/myts-auth-check ts3-client/core/src/main/java/eu/lixko/ts3j/client/myts/MyTsCrypto.java ts3-client/docs/myteamspeak/MyTsAuthCheck.java
java -cp "/tmp/myts-auth-check:$auth_cp" eu.lixko.ts3j.client.myts.MyTsAuthCheck
```
The Python check requires Unicorn and executes the actual native packet-key routine with synthetic
sharedIV `00 01 … 3f`, stopping at the hash call. It asserts the exact hash input and checks the
native hash-name literals. Expected challenge:
`d178cabdc4faa5bb033b175d2f691564975d38b48994ab8eaf93ee88f1bb73f8`.
The Java check verifies the captured private-key unwrap/public-key relation, rejects the seed
interpretation, signs the synthetic challenge using existing arithmetic, verifies with stock BC,
and confirms that changing the challenge invalidates the signature. All checks passed.
**Live check (2026-10-10, server.lixko.eu, throwaway account):** our `clientinit` with the six
parameters makes the server report `client_myteamspeak_id`; without them it is absent; an
`updatemytsid` with empty values clears it and a freshly signed one sets it again, also on a
connection that started without it. A `clientinit` with one bit of `authSign` flipped still
connects but the server silently drops the ID, so the signature is checked.
Production integration now lives in `MyTeamSpeakIdentity`, `MyTeamSpeakLogin.serverIdentity`,
and ts3j's `addMyTeamSpeakParameters`. Desktop and Android provide the signed-in account to
the connection, honor the bookmark switch, and send `updatemytsid` on account changes.
The scalar is cached only in memory and wiped on sign-out/account replacement. The Connect
dialog also offers the feature switch. Automated tests cover the parser, signature, connection
binding, saved sign-in, and revocation.
### Capture harness notes (reusable)
- Official client: `GLIBC_TUNABLES=glibc.pthread.rseq=0`, `LD_LIBRARY_PATH` += the xcb/libpci shim
dir, `HOME`=throwaway profile, under Xvfb. License + "stay logged in" persist in `settings.db`, so
only the first run needs the EULA/login clicks.
- Do **not** `kill -9` gdb while it holds the inferior stopped — it crashes the client. Make the gdb
script `detach` + `quit` itself after the capture, or `kill -INT`.
- `std::string` (libc++): flag byte at +0; long if `flag&1` → size at +8, data ptr at +16; else short
→ size `flag>>1`, data at +1.
## Verification once it is known