Learn · Tier 2 · Module 3 of 10

curl by hand

Write an HTTP request yourself: method, headers, body and query, and read what comes back.

The idea

curl sends one HTTP request and prints the answer. It is how an analyst talks to a server directly: replay an implant's check-in, poke at a panel, fetch a payload without a browser running it.

The parts of a request, and the flag for each

curl -i -X POST \
     -H 'User-Agent: Pebble/2.4' \
     -H 'X-Client-Id: 7f3a9c1e' \
     --data 'id=7&st=idle' \
     'https://c2.example.test/gate?v=2'
PartFlagNotes
URLthe argumentScheme, host, path, then ? and the query: name=value pairs joined by &.
Method-X POSTWithout it: GET, or POST when there is a body.
Header-H 'Name: value'Repeat for each header. A -H replaces the header curl would send itself, like User-Agent: curl/8.5.0. -H 'Accept:' removes one.
Body--data '...' or -dSets Content-Type: application/x-www-form-urlencoded unless you send your own. Several --data are joined with &.
Show headers-iThe status line and response headers, then the body.
Verbose-vAlso the request as sent, lines starting with >.

Quote anything with spaces, &, ?, ; or * in it. Single quotes are safest: the shell changes nothing inside them. A long command can be split with \ at the end of a line.

Reading the answer

HTTP/1.1 403 Forbidden
content-type: text/plain

Operators only: the X-Operator header is missing or wrong.

The first line is the status:

CodeMeansUsually
200OKIt worked.
301, 302MovedGo to the Location header. curl does not follow it unless asked.
400Bad requestA parameter or the body is malformed or missing.
401UnauthorizedCredentials missing or wrong.
403ForbiddenYou are not allowed: often a missing header or token.
404Not foundWrong path, or a server pretending there is nothing here.
405Method not allowedRight path, wrong method.
500Server errorYou broke something on the other side.

Then the response headers, a blank line, and the body. A C2 that wants to hide shows a 404 or a decoy page to anything that is not its implant, so an error is information: change one thing at a time and watch what changes.

A browser cannot do this

A web page can't set User-Agent, Host or Cookie on its own requests, and C2 servers often check those. curl can. The workspace's console sends your curl command as raw HTTP over its own connection to the instance, so those headers go through as written.

Walkthrough: in the browser

Showing the browser path.

The workspace's Console tab sends curl commands to your own instance. Sign in, open the practice puzzle's workspace and press Spin up instance.

With blocks

  1. Tick Block mode. The command starts as curl https://<your instance> and a box for the path.
  2. Type / in the path box and press Send. The Terminal output shows what curl would print; Request sent and Response received show every byte that went over the wire.
  3. Change the path to /notes. Press Add query parameter and type id=3. Watch the command under the blocks change: the parameter is added to the URL after ?.
  4. Send it and read the note. It names a path, a header and a form body.
  5. Change the path to the login path, Add method (-X) with POST, and send. Read the status and the message: it says what is missing.
  6. Add header (-H) with X-Operator: nightjar, send, and read the next message. Then Add body (--data) with the form the note gives.

Typed

  1. Untick Block mode. The command stays, as text. From here on, edit the text: add -i to see headers, change a value, send again. Ctrl+Enter sends.
  2. A flag the console does not support gets an error that names it: try -A. It says to use -H 'User-Agent: ...' instead.

The checkpoint asks you to type commands, without blocks.

Practice

Checkpoint

Answers from either path count.