Learn · Tier 4 · Module 9 of 10

Answering the door

Live puzzles: C2 servers that only answer a correct check-in. Replicate the implant from a capture and its strings.

The idea

A live puzzle gives you a server of your own: a rebuilt C2. Like a real one, it does not help strangers. It answers the implant, and only the implant. Anything else gets a 404, an empty page, or a decoy: a convincing but useless answer, like a CDN error page or a parked domain.

So the job is to be the implant: send exactly what it sends, in the order it sends it.

Where the knock comes from

  • A capture of the implant talking: the method, path, headers and body of each request, and what came back.
  • The sample's strings: the user agent, paths, header names, format strings like %s|%s|%s that say how the body is built.
  • The sample's code: how it encodes or encrypts the body, and how it reads the reply.

What servers check

CheckExampleIf wrong
Path and methodPOST /cdn/v3/collect404, 405
User-AgentUpdater/5.1 (x64; channel=stable)404 or decoy
Custom headersX-Session: 16 hex digits404
Body formatbase64 of `hostuser
Ordertasking only after a check-in404
Cookies or tokensa value from the check-in reply403

The check is often a pattern, not an exact value: the server checks that X-Session is 16 hex digits, not which ones. Your own made-up machine name works if it has the right shape.

Following the server

Replies tell the implant what to do next, often encoded:

{"ok":1,"next":"2f63646e2f76332f6a2f3963316538326164","wait":120}

next is hex: /cdn/v3/j/9c1e82ad. A capture shows the path the sandbox got. Your instance gives its own, so read the reply you got, not the one in the capture.

Work method

  1. Write down the implant's request from the capture, every header.
  2. Send it as is. If it works, change one thing at a time to learn what the server checks.
  3. If it does not, compare your request with the capture's byte by byte: the console's Request sent or curl -v shows yours.
  4. Decode every reply field that looks encoded, and follow it.

Walkthrough: in the browser

Showing the browser path.
  1. Open the practice puzzle's workspace. In Pcap, filter http.request and Follow HTTP stream on the POST. That is the check-in, and the server's reply.
  2. In Files, read strings.txt: the user agent, the header name, %016llx (16 hex digits) and %s|%s|%s (three fields joined by |).
  3. Spin up the instance. In the Console, first send a plain curl -i https://<instance>/cdn/v3/collect: the CDN's 404. That is the decoy.
  4. Build the check-in. Make your own body: in the Decoder, To Base64 on PC-01|you|Windows 10. Then:
curl -i -X POST -H 'User-Agent: Updater/5.1 (x64; channel=stable)' \
     -H 'X-Session: 0123456789abcdef' -H 'Content-Type: text/plain' \
     --data '<your base64>' https://<instance>/cdn/v3/collect
  1. The reply's next is hex. From Hex in the decoder gives a path.
  2. GET that path with the same User-Agent. Leave out the User-Agent once to see the decoy again.
  3. The key is base64, reversed: in the decoder, Reverse then From Base64.

The same in the Notebook, which keeps values between steps:

from necropsy import request
import base64
ua = {"User-Agent": "Updater/5.1 (x64; channel=stable)"}
body = base64.b64encode(b"PC-01|you|Windows 10").decode()
r = await request("POST", "/cdn/v3/collect", headers={**ua, "X-Session": "0123456789abcdef"}, data=body)
path = bytes.fromhex(r.json()["next"]).decode()
t = (await request("GET", path, headers=ua)).json()
print(base64.b64decode(t["v"][::-1]).decode())

Practice

More at this level

Checkpoint

Answers from either path count.