Usama Arshad. Résumé

Challenge 10 of 15 Reversing Full writeup

BlackHat MEA 2026 · Qualifiers

free-agentic-tool.

A “free” AI agent CLI, its session debug bundle, and a packet capture of the traffic it produced.

Reversing· 4 November 2026

TL;DR

The distributed binary is a dropper. Its real payload is a reflectively-loaded second Go executable that speaks gRPC to a C2, and that stage derives its X25519 private key from <code>sha256(USERNAME + "_" + COMPUTERNAME)</code> instead of generating one, so the whole captured session decrypts from the pcap alone.

Captured

01Recon

Three artifacts ship together:

snippet
free-agent.exe                   ~11 MB Go PE32+
free-agent_session_debug.zip     15 encrypted "diagnostics" entries
traffic.pcapng                   gRPC to 192.168.137.1:50051, service /free.model/*

free-agent.exe is Go with an intact pclntab, so app symbols (fagent/internal/...) survive. The load- bearing tooling detail: Ghidra headless must be given -processor x86:LE:64:default -cspec golang. With the golang compiler spec the decompilation is near-source quality and Ghidra recovers each function's real file:line from pclntab; with the default windows cspec every Go register-ABI argument decompiles as unaff_RBX / extraout_RAX noise. Applying the 4,801 recovered symbols created 1,557 functions and renamed 3,244.

Scanning every e8 rel32 in.text for crypto/aes.NewCipher gives exactly one application call site, in diagnostics.writeFieldFiles @ 0x4ede60:

snippet
4edebd: lea rax,[rip+0x3836bc]   # 0x871580
4edec4: mov ebx,0x20             ; AES-256
4edecc: call 0x4d5300            <crypto/aes.NewCipher>

The key is a plain static array, not derived, VA 0x871580, file offset 0x46f180:

6e1ac4f78b33905ed20f77a94cb821e63d9512da607ecf1b48a3590ce42db673

Only two instructions in the whole binary reference 0x871580, and nothing writes it. diagnostics.sealValue @ 0x4edbc0 confirms the container format: iv(16 from crypto/rand) then AES-256-CBC(key, iv, PKCS#7(value)).

All 15 zip entries decrypt with valid padding, and none contains the flag. user_input.txt is just /help. The real yield is the victim identity: user lightlight on DESKTOP-DD6SS6U. The stage-1 binary contains no gRPC code at all, so it cannot be what produced the capture.

02The bug

Two bugs, one hiding the other.

  1. free-agent.exe is a dropper, and its loader is disguised as archive/zip. The binary's archive/zip package contains seven functions that do not exist in the Go standard library, all claiming source archive/ zip/writer.go:666+:
snippet
initDeflate@0x6406e0   readStream@0x6407a0    inflateBlock@0x6409c0
parseLocalHeader       flushStream@0x641760   rebaseOffsets   resolveTable

Together they are a reflective PE loader, triggered by a planted sync.Once in (*Writer).compressor. The UI meanwhile prints a fake HTTP 401 as cover.

initDeflate decompiles to readStream(payload, &DAT_00871580, 0x20), the diagnostics AES key is reused as the loader's XOR key. The payload is a []byte at global 0xf6f610 pointing at 0x8a1d40 (file offset 0x49f940), 0x6cc5ad bytes, magic FALZ\x01:

snippet
require buf[0:4] == "FALZ" and buf[4] == 1
n     = BE32(buf[6:10])
inner = LZSS_inflate(buf[10:10+n])            # outLen = BE32(src[0:4])
out[i] = (inner[i] ^ key[(7*i + 3) % 32]) - key[i % 32]

That yields a 9,649,152-byte PE32+ (Go 1.20.5, 10,876 functions) which does contain real gRPC and protobuf. flushStream maps it with VirtualAlloc(base, SizeOfImage, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE), applies relocations and imports, then jumps to its entry point. Every DLL and procedure name is built byte-by-byte via makeslice + slicebytetostring in archive/zip.init, so none of them appear as strings.

  1. Stage 2 never generates a key pair. In stage 2, main.OOGOOOGOGOOOGGOOO @ 0x8617a0 does:
snippet
u := getenvOr("USERNAME", "?")
h := getenvOr("COMPUTERNAME", "")
if h == "" { h, _ = os.Hostname() }
return sha256(u + "_" + h)

and feeds that straight into crypto/ecdh.(*x25519Curve).NewPrivateKey. GenerateKey is never called. The private key is a deterministic function of two values that are printed in the capture's own handshake, which is the "unlimited tokens" joke and the actual vulnerability.

03Exploitation

  1. Unpack stage 2. Carve the FALZ blob, LZSS-inflate, unmask with the stage-1 AES key, and write out falz_decoded.bin, the gRPC-speaking stage-2 PE.
  2. Locate the crypto in stage 2. Its protobuf lives in package gogogooogogogo/gogoogogoo with type and method names made only of the letters G and O; main.* (0x849e20–0x86df0f) is obfuscated with control-flow flattening and MBA arithmetic (the dispatcher uses the murmur3 finalizer constants 0xff51afd7ed558ccd and 0x94d049bb133111eb). Ghidra headless with the golang cspec still decompiles it.
  3. Recover the private key from the pcap. The Init message carries agent@DESKTOP-DD6SS6U, and the diagnostics bundle gave the username:
snippet
priv = sha256("lightlight_DESKTOP-DD6SS6U")
     = a68c071a078d0011ae5ea9698d2a561d57ddb124f11fd2ff34ab7d1076c140a6
pub = X25519(priv) = fcce28708604b98004450d32ea2ab2ffb9e4dc1961cc7257af2f80c8c8b1fa76

which is an exact match for Init field 2 in the capture. The derivation is confirmed.

  1. Derive the session key. main.GOOGOOGOOOOGGOO @ 0x8660c0 computes
snippet
key = sha256( sha256(sessionID XOR T8) || sha256(X25519(priv, serverPub)) )

where main.GGGOOGGGGOOGGOO @ 0x864fe0 is just out[i] = in[i] ^ T[i % 8] with T = 8c f1 a7 13 9e 02 d6 7f at VA 0x00ccc708. (The transform was also confirmed by emulating that single function under Unicorn, stubbing makeslice / growslice.) With sessionID = "f3bbb50728251459":

snippet
shared = 14488f97ebdc8e8bad1e48057af735b86dbecbea2c6e7105eb7c38145d1e3072
session = 7c29d2dc03567d188b844a11d08d5c82707bb052ea012e0729658948fc832b93
  1. Decrypt the C2 transcript. AES-256-GCM, 12-byte nonce carried in each message, no AAD (empty AAD verifies; using the sessionID as AAD fails). The recovered session reads whoami → dir D:\ → dir D:\BlackHat → exfiltration of a 73-byte flag.txt.

Key code def unfalz(buf, key): assert buf[0:4] == b"FALZ" and buf[4] == 1 n = int.from_bytes(buf[6:10], "big") inner = lzss_inflate(buf[10:10+n]) # outLen = BE32(src[0:4]) return bytes(((inner[i] ^ key[(7*i + 3) % 32]) - key[i % 32]) & 0xFF for i in range(len(inner)))

snippet
priv    = hashlib.sha256(b"lightlight_DESKTOP-DD6SS6U").digest()
shared = x25519(priv, server_pub)
T8      = bytes.fromhex("8cf1a7139e02d67f")
sid_x   = bytes(c ^ T8[i % 8] for i, c in enumerate(session_id))
session = hashlib.sha256(sha256(sid_x) + sha256(shared)).digest()
plain   = AESGCM(session).decrypt(nonce, ct, None)      # no AAD

04Dead ends

  • Ghidra without -cspec golang is unusable here. Every Go register-ABI argument decompiles as unaff_RBX / extraout_RAX. The spec id is golang in Ghidra/Processors/x86/data/languages/x86-64- golang.cspec.
  • The stage-1 AES key is not derived. Time was spent looking for a Getenv / sha256 / hkdf derivation near the NewCipher call. There is none, it is a static array, and the same 32 bytes are reused as the dropper's XOR key.
  • Decrypting the debug bundle is a dead end for the flag. All 15 entries decrypt cleanly and none contains it; their value is the victim identity that the key derivation needs.
  • The hostname in the task brief had a typo (DESKTOP-DD6SS6EU). The capture's Init says agent@DESKTOP-DD6SS6U (21 bytes, 0x15), and only the correct spelling makes the key derivation reproduce the observed public key.
  • report.tryUpload POSTs to http://not-malicious-website.ctf/upload, a decoy that never appears in the capture.
  • AAD matters: GCM verifies with empty AAD; passing the sessionID as AAD fails every frame.