Challenges
Onion network: 3-layer encryption
Xonalar
Impossible
Network forensics, memory analysis and multi-layer cryptanalysis
Solves: 5
Onion network: 3-layer encryption
Author: CyberSamSU
Points
350
The cybercrime unit captured the traffic sent from a suspicious internal client to the v3vault77x.onion.invalid hidden service through a 3-stage (3-hop) onion routing chain, and a memory image of the first node (Guard) process: darknet_case.zip.
The archive contains README.txt, relay1.mem (a 128 KB memory image) and circuit.pcap (the ONC3 cell protocol on TCP/9001 and decoy traffic).
Protocol structure (Onion Cell Protocol v3)
- Outer cell (
ONC3):magic(4B)="ONC3" | circuit_id(4B u32 BE) | cmd(1B) | payload_len(2B u16 BE) | payload.cmd=0x01(CREATE),0x03(RELAY_DATA),0x04(PADDING). - Layer 1 (Guard / Hop 1): the
RELAY_DATApayload =nonce1(8B) || AES-128-CTR(K1, nonce1 || 0x00^8, L1_plain). TheK1key is stored inrelay1.memas a 176-byte expanded AES-128 key schedule. - Layer 2 (Middle / Hop 2): The decrypted
L1_plainbegins with"ON2\x01" + subcmd(1B):0x10(DH_INIT:len_p(2B BE)|p | len_g(2B BE)|g | len_A(2B BE)|A),0x11(DH_RESP:len_B(2B BE)|B),0x20(RELAY_L2:nonce2(8B) || AES-128-CTR(K2, nonce2 || 0x00^8, L2_plain)). Key:K2 = SHA256(S_16B_BE || "hop2-ctr")[:16], whereS = B^a mod p. - Layer 3 (Hidden Service / Hop 3): The decrypted
L2_plainbegins with"ON3\x01" + subcmd(1B):0x2F(route state),0x30(RELAY_L3:nonce3(8B) || AES-128-CTR(K3, nonce3 || 0x00^8, L3_plain)). The known plaintext of the handshake cell:ONION-HS/3.0 PROBE host=v3vault77x.onion.invalid proto=v3 ack=SYN-OK banner="SamSU Onion Rendezvous v3.0 - integrity check active before vault transfer.".
Chain of tasks
- Task 1 (Memory forensics): In
relay1.mem, find the 176-byte key schedule that satisfies the AES-128 key expansion rule. Be careful: the 1-hoptest-echochain gives a fake flag; only the key that decrypts theON2\x01layer and its chain are genuine. - Task 2 (Pohlig-Hellman DH): for the 128-bit
pinDH_INITandDH_RESP,p - 1is a smooth number. Find the secret exponent with the Pohlig-Hellman + BSGS algorithm, computeK2and decrypt layer 2. - Task 3 (CTR nonce reuse): among the
RELAY_L3cells, find the repeatednonce3pair, recover the keystream through the knownPROBEtext and decrypt theSECRETmessage. - Task 4 (Flag): get the
BAYROQ{PIYOZ_TARMOQ_<16hex>}flag sent byv3vault77x.onion.invalid(the last 16 characters are lowercase hex).
Attached files
darknet_case.zip
Log in to download
Theory: learn the topic
To submit a flag, log in.