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|%sthat 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
| Check | Example | If wrong |
|---|---|---|
| Path and method | POST /cdn/v3/collect | 404, 405 |
| User-Agent | Updater/5.1 (x64; channel=stable) | 404 or decoy |
| Custom headers | X-Session: 16 hex digits | 404 |
| Body format | base64 of `host | user |
| Order | tasking only after a check-in | 404 |
| Cookies or tokens | a value from the check-in reply | 403 |
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
- Write down the implant's request from the capture, every header.
- Send it as is. If it works, change one thing at a time to learn what the server checks.
- If it does not, compare your request with the capture's byte by byte: the console's Request sent or
curl -vshows yours. - Decode every reply field that looks encoded, and follow it.
Walkthrough: in the browser
- Open the practice puzzle's workspace. In Pcap, filter
http.requestand Follow HTTP stream on the POST. That is the check-in, and the server's reply. - In Files, read
strings.txt: the user agent, the header name,%016llx(16 hex digits) and%s|%s|%s(three fields joined by|). - 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. - Build the check-in. Make your own body: in the Decoder,
To Base64onPC-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
- The reply's
nextis hex. From Hex in the decoder gives a path. GETthat path with the same User-Agent. Leave out the User-Agent once to see the decoy again.- The key is base64, reversed: in the decoder,
ReversethenFrom 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.