Malware

Following the beacon: decoding a custom C2 protocol from a packet capture

No source, no sample, just an hour of pcap. Spotting the heartbeat, aligning the framing, and writing a decoder good enough to read the operator's commands.

On this page

Summary

A single host sent a short TCP message every 60 seconds, give or take a few seconds of jitter. The messages were not TLS and not HTTP, and they were not random either. Treating the capture as a protocol-reversing exercise recovered the framing, the command set and a trivial obfuscation layer.

Background

Beaconing is the easiest malware behaviour to find and one of the harder ones to read. Fixed-interval traffic stands out on a timeline, but the payload is usually wrapped in a format nobody has documented.

Method

I plotted packet times to confirm the interval, grouped payloads by length, and compared the first bytes of each group. A length prefix and a one-byte command code fell out within minutes, and a repeating four-byte XOR key followed from a known plaintext.

Findings

The decoded stream shows a check-in, a task request and a result upload. Command codes map to file listing, upload and shell execution.

Takeaways

Alert on the interval and jitter rather than on the payload. For researchers: always look for known plaintext, since protocol headers are rarely random.