TLS: full chain
Room: TLS full chain. A perimeter sensor recorded TLS traffic that passed from the internal network to the vpn-gw.corp.example gateway. Someone downloaded the gateway firmware. At the moment you have the gateway's morning backup, but the private key there is not in ordinary PEM form. The question: what is the current escrow token inside the firmware?
breach.zip: README_breach.txt, traffic.pcap (several TLS sessions, different certificates), backup/etc/gw/tls.conf, backup/etc/gw/server_old.pem, backup/var/crash/core.1432.hexdump (a kernel dump, in hexdump -C form).
Task 1 (traffic). Separate the sessions in the pcap: what are the SNI/certificate name (CN) and the negotiated cipher suite of each? Only the RSA modulus n from the vpn-gw.corp.example certificate is needed (the certificate is in the Certificate handshake message, DER).
Task 2 (key). In tls.conf the key is "split": p = key_shard_a XOR mask, while mask is in the kernel dump with the TLSKEYMASK marker (marker + NUL + u16 length + bytes). There are also decoy masks in the dump: the correct one is determined by n mod p = 0. Then q = n / p, e = 65537, d. server_old.pem is the key of another (old) certificate; do not be fooled by it.
Task 3 (TLS 1.2). Cipher suite TLS_RSA_WITH_AES_128_CBC_SHA. Decrypt the encrypted pre-master (RSA PKCS#1 v1.5, type 2) in ClientKeyExchange, then follow RFC 5246: master = PRF(pms, "master secret", client_random + server_random)[:48], key_block = PRF(master, "key expansion", server_random + client_random); the PRF is P_SHA256. The key_block order for a CBC suite: client MAC (20), server MAC (20), client key (16), server key (16) (in TLS 1.2 the IV is not derived separately — each record has an explicit IV).
Task 4 (records). Records after ChangeCipherSpec: IV(16) | AES-CBC(ochiq matn | HMAC-SHA1 | to'ldirish). MAC = HMAC-SHA1(mac_key, seq(8, BE) | type | version(0303) | length | plaintext); in each direction seq starts from 0 after ChangeCipherSpec. Separate the HTTP responses in all sessions; find the session in which the firmware was downloaded (the response has a X-Device-Serial header).
Task 5 (firmware). Format CSFW: "CSFW" | versiya(u8) | bo'limlar soni(u8) | 2 bayt | umumiy uzunlik(u32), then 20 bytes for each section: nom(8, NUL bilan to'ldirilgan) | offset(u32) | uzunlik(u32) | flags(u32) (all big-endian; the offset is from the start of the file). flags: 1 = zlib, 2 = XOR (the key is the ASCII value of X-Device-Serial, repeated). Storage order: XOR(zlib(text)). The escrow_token in the cfg section (the current one; not _old) is the flag.
Flag format: BAYROQ{TLS_TOLIQ_ZANJIR_xxxxxxxxxxxxxxxx} (the last 16 characters are lowercase hex). Tokens in this format also appear in other sessions — only the one in the correct chain is correct.