← all posts

· 4 min read · by Eav Puthcambo

The web server that wasn't

A Go "httpd" from an infected host serves nothing but a shrug, while a hidden goroutine sniffs for a magic ping that unlocks an AES-encrypted secret.

"This file was found on an infected host. Can you figure out what it does?" httpd, Crackmes.one Reverse Engineering CTF 2026 (author: crudd)

You get a binary called httpd. You run it, point a browser at it, and it answers every request with:

Nothing to see here :{

It's lying, of course. This post walks through how a "web server" turned out to be a packet-sniffing backdoor that only wakes up when it receives one very specific ICMP echo request, and how I got the flag without ever sending that packet.

First look: a Go binary with its guard down

httpd: ELF 64-bit LSB executable, x86-64, FreeBSD 14.3, Go BuildID=…, with debug_info, not stripped

Go 1.17, not stripped, with DWARF debug info. For a reverser, that's a gift: function names are intact. Two things stood out immediately:

  1. It statically links github.com/google/gopacket and gopacket/pcap. Web servers don't usually need a packet-capture library.
  2. The program's own main.* package is tiny:
main.main      0x747dc0  size 453
main.handler   0x747fa0  size 222

The host I was on didn't have objdump or strings, so I did everything from Python with pyelftools + capstone, which honestly turned out cleaner for a Go binary anyway.

The decoy

main.handler is exactly what it claims to be, and nothing more:

cmp word ptr [rcx], 0x4547      ; 'GE'
cmp byte ptr [rcx+2], 0x54      ; 'T'
; GET  -> "Nothing to see here :{"
; else -> 405 "Method not allowed"

The interesting line was in main.main: after setting up the HTTP server, it calls runtime.newproc, which is how Go starts a goroutine. Following that closure pointer led to code at 0x748080, which is where the actual malware lives.

The real payload: a sniffer

The goroutine opens a live capture and filters for ICMP:

; pcap.OpenLive("re0", 1600, promisc=true, BlockForever)
call github.com/google/gopacket/pcap.OpenLive
; handle.SetBPFFilter("icmp")
call pcap.(*Handle).SetBPFFilter
call gopacket.(*PacketSource).Packets

Then it loops over every packet and checks raw frame offsets. Ethernet (14) + IP (20) + ICMP lines up like this:

Check Offset Value
ICMP type 0x22 8 (echo request)
IP total length 0x10 32
ICMP identifier 0x26 0x1337
ICMP payload 0x2a 0xe55fdec6

So the "knock" is a 32-byte ping with id 0x1337 and a 4-byte magic payload.

One gotcha worth calling out: those are little-endian reads on x86, so on the wire the id is 37 13 and the payload is c6 de 5f e5. If you craft the packet with scapy, you have to byte-swap.

The key comes from the packet itself

When a packet matches, the malware builds a 16-byte AES key from the packet's own header bytes:

key[0:2]   = BE(0xe55f ^ W)        # W = ICMP checksum word
key[2:6]   = IP flags/frag, TTL, proto
key[6:8]   = W
key[8:12]  = magic   (c6 de 5f e5)
key[12:14] = id      (37 13)
key[14:16] = BE(W ^ 0xdec6)

That key is used as both the key and the IV for AES-128-CBC, decrypting a 32-byte ciphertext that's baked into the code as four movabs immediates. The plaintext gets printed. That's the flag.

Why I didn't need the packet

Look at what's actually unknown in that key:

  • W, the ICMP checksum: 16 bits
  • flags/TTL/proto: for any realistic packet, proto is 1, flags are 0 or DF, TTL is one of a handful of defaults

Everything else is pinned by the trigger conditions. That's a search space of a few hundred thousand keys, which takes seconds. So I rebuilt the key derivation in Python and brute-forced it offline:

for frag in (0x0000, 0x4000):
    for ttl in (64, 128, 255, 63, 127):
        for W in range(0x10000):
            k  = build_key(W, frag >> 8, frag & 0xff, ttl)
            pt = AES.new(k, AES.MODE_CBC, iv=k).decrypt(CT)
            if pt[:4] == b"CMO{":
                print(hex(W), pt)

It hit on the very first realistic shape (DF set, TTL 64):

frag=4000 ttl=64 W=279a
key/iv = c2c5400040019a27c6de5fe53713f95c
FLAG   = CMO{fUn_w1th_m4g1c_p4ck3t5}

The plaintext ended in \x05\x05\x05\x05\x05, valid PKCS#7 padding, which is a nice confirmation that the AES-CBC reading was right.

As a final sanity check I used scapy to build the actual magic ping and confirmed that seq=1 produces exactly checksum 0x279a. So that's the packet the "attacker" would have sent.

📂 Full writeup with addresses, constants and the complete solve script: ctf-writeups/reverse/…/httpd

Thanks for reading! Questions or corrections? Ping me on GitHub.

Read more

all posts →