Knowledge Base · general

STYLE GUIDE

generaltechnique notemetastyle-guide

Formatting and writing conventions for every writeup in this vault. A good writeup does three things: it locks in your own learning, it lets a teammate reproduce the solve command by command, and it teaches the next person who hits the same wall. Apply this guide to new notes so the collection stays consistent, searchable, and reproducible.

1. Frontmatter schema

Every writeup starts with YAML frontmatter:

---
title: 'Harbor Lights' # clean challenge name, no "— Writeup" suffix
ctf: 'SAF Pre-Qualifiers 2026' # event
category: cloud # see list below
difficulty: easy-medium # easy | easy-medium | medium | medium-hard | hard | unknown
status: solved # solved | partial | unsolved | reference
flag: 'safctf{REDACTED}' # masked; omit for unsolved / non-flag notes
date: 2026-03-14 # date solved (YYYY-MM-DD), when known
points: 300 # when known
author: 'handle' # who solved it, when a team wrote the vault
tools: [nmap, ffuf, awscli] # main tools used, lowercase
tags: [ctf, cloud, path-traversal]
---
  • category is the folder slug: web, active-directory, api, cloud, crypto, forensics, mobile, osint, pwn, reversing, malware, misc, steg, reference.
  • date, points, author, tools, and cve (e.g. cve: [CVE-2024-XXXXX]) are optional. Add them only when known; never guess.
  • Tags: always include ctf, the category slug, then technique tags (ssrf, jwt, dns-exfiltration, kerberoasting, …). Lowercase, hyphenated.
  • status meanings: solved = flag obtained by you; partial = progress but no flag (document how far you got and what you’d try next); unsolved = attempted only; reference = technique or tooling note, not a challenge.

2. Body structure

Every writeup follows this skeleton. Sections marked (optional) are dropped when not relevant; never leave empty headings or placeholder text.

# <Challenge Name>                  <-- exactly one H1, matching `title`

## References

Challenge Info callout

<aside class="callout callout-info">
<p><strong>Challenge Info</strong></p>
<p><strong>Event:</strong> SAF Pre-Qualifiers 2026</p>
<p><strong>Category:</strong> cloud</p>
<p><strong>Difficulty:</strong> easy-medium · <strong>Points:</strong> 300</p>
<p><strong>Target:</strong> <code>hxxp://harbor[.]example[.]test</code>      <-- defanged</p>
<p><strong>Flag:</strong> <code>safctf{REDACTED}</code></p>
</aside>

<aside class="callout callout-abstract">
<p><strong>Summary</strong></p>
<p>A path-traversal bug in the image proxy exposes an IAM role's credentials, which unlock a private S3 bucket containing the flag.</p>
</aside>

Structural rules

  • One H1 only. All sections use ##. Use ### for steps and sub-parts inside a section. Never use # for subsections.
  • Prefer callouts over bold labels: > [!tip], > [!warning], > [!note], > [!question], > [!todo], plus > [!success] (confirmed result), > [!failure] (dead end), > [!bug] (the vulnerability), > [!example] (alternate payload or variant).
  • Put a single --- rule between major sections only when it aids scanning.
  • Fenced code blocks must always be closed and always carry a language (bash, python, text, json, sql, powershell, http, yaml, mermaid, …).
  • Length: most writeups land at 1,500–3,000 words. Much longer usually means you are teaching foundations that belong in a Techniques/ note, or covering more than one challenge.
  • Write within 48 hours of the solve, while your notes and shell history are fresh. Save your shell history (history, script, or tmux logs) as raw material.

3. Step-by-step command format (the core of a good writeup)

Every action in Recon, Enumeration, and Exploitation is written as a step. A step has four parts: goal → command → output → interpretation.

### Step 3 — Probe the image proxy for path traversal

**Goal:** Check whether the `file` parameter is sanitised.

```bash
curl -s "$TARGET/img?file=../../../../etc/passwd" | head -n 5
```

```text
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
[...]
```

<aside class="callout callout-success">
<p><strong></strong></p>
<p>The server returned <code>/etc/passwd</code>, so <code>file</code> is concatenated into a filesystem path with no normalisation. This is the foothold.</p>
</aside>

Rules for commands

  1. Goal first. One sentence on why you are running this, before the command. “Run nmap” is not a goal; “find non-standard ports” is.

  2. Command and output in separate blocks. The command block is bash (or powershell, python, …) and contains only what the reader should paste: no $ prompt, so it copies cleanly. The output block is text.

  3. Use variables for targets and secrets. Declare them once in Prerequisites / Setup and reuse them:

    ```bash
    export TARGET="<challenge URL or IP>"   # real value is in the challenge, defanged in Challenge Info
    export DC_IP="<domain controller IP>"
    export TOKEN="<redacted>"
    ```
  4. Explain flags the first time you use them, e.g. -sC runs default scripts, -sV probes versions, -p- scans all 65,535 ports. After that, use freely.

  5. Show real output, trimmed. Keep the lines that matter and mark cuts with [...]. Do not paste 400 lines of scan output. Do not paste output that has been edited to look nicer.

  6. Interpret the output. After each output, say what it means and what you decided next. This is the reasoning layer and the part readers actually learn from.

  7. Number steps continuously within a section or across the whole writeup (Step 1 … Step N) so teammates can say “I’m stuck on step 6”.

  8. One idea per step. If a step needs more than one command, make sure they belong to one logical action (e.g. generate a payload, then send it). Otherwise split.

  9. Pipelines and multi-line commands use \ continuations and are formatted to be readable, with one flag group per line for long commands.

  10. Never skip a step that the reader cannot infer, such as installing a tool, starting a listener, editing /etc/hosts, or setting an env var. If it was needed, it is written down.

  11. Mark where you are: use > [!note] Shell: attacker or > [!note] Shell: target (www-data) when a writeup moves between machines or sessions, so readers know where each command runs.

  12. Record tool versions when behaviour depends on them: nmap 7.95, pwntools 4.13, Python 3.11, hashcat v6.2.6. Put them in Prerequisites / Setup.

Interactive and GUI work

  • Command-line first. When a step is done in a GUI (Burp, Ghidra, Wireshark), describe the exact clicks or menu path and give the equivalent CLI where one exists (tshark, analyzeHeadless).

  • For Burp or browser dev-tools steps, paste the raw HTTP request/response in an http block rather than a screenshot:

    ```http
    GET /img?file=../../../../etc/passwd HTTP/1.1
    Host: harbor[.]example[.]test
    ```

Listeners, shells, and multi-terminal work

Label each terminal so the reader can follow the interleaving:

**Terminal 1: listener**
**Terminal 2: trigger**

Showing exploit code

  • Paste the working version with comments on the non-obvious parts. Do not paste a version with three commented-out attempts and print("test123").
  • Explain key lines in the prose, or annotate with inline comments.
  • If the exploit is under ~60 lines, embed it. If longer, embed the core and attach the full file (see section 9).

Solve Script (when applicable)

For crypto, reversing, pwn, and any challenge that ends in a script, include one complete, runnable script that goes from the provided challenge data to printing the flag. It lives under ## Solve Script, includes imports, and prints a masked flag in the example output.

#!/usr/bin/env python3
# solve.py: recovers the flag from enc.bin using the leaked key
from pathlib import Path

key = bytes.fromhex("<leaked key>")
data = Path("enc.bin").read_bytes()
print(bytes(b ^ key[i % len(key)] for i, b in enumerate(data)).decode())

4. Writing the reasoning

The commands show what you did. These sections explain why it worked.

  • Overview (2–6 sentences): what the challenge presents, what files or endpoints you were given, what the goal is. Do not spoil the solution here beyond the Summary callout.
  • Recon: what you saw first, as raw input. Page source, file/strings output, scan results, given hints. Show the starting point before any analysis.
  • Enumeration: how you narrowed down the attack surface, what you noticed that mattered, and what you ruled out. State hypotheses (“the 4-second delay on a closing quote suggests blind SQLi”) rather than jumping straight to the payload.
  • Vulnerability Analysis: why the bug exists. Name the class of flaw (CWE where possible), the underlying primitive, and why it is exploitable here specifically. Use a > [!bug] callout for the root cause. If this section is thin, you do not yet understand the bug. Go back before publishing.
  • Exploitation: the numbered steps from section 3, building from foothold to flag.
  • Post-Exploitation / Privesc (optional): same step format, applied to lateral movement or escalation (root, admin, role assumption, domain admin).
  • Flag: the masked flag, plus how it was obtained or verified in one line.

Dead Ends

Real solves are not linear. Include the failed attempts that taught something or that another solver would likely try too:

<aside class="callout callout-failure">
<p><strong>Tried: SQL injection on <code>/login</code></strong></p>
<p>Sent <code>' OR 1=1--</code> and time-based payloads; no change in response or timing. The form uses a parameterised query. Moved on to the image proxy.</p>
</aside>

Leave out the 40 minutes you spent on a typo. Do not make every key press a dead end.

Honesty rules

  • Do not write “I quickly noticed” or “obviously”. Say what actually led you to it, including luck and hints.
  • If you needed a hint, a teammate’s idea, or someone else’s writeup, say so and credit them.
  • For partial or unsolved notes, write what you tried, where you got stuck, and what you would try next.

Lessons / Takeaways and Mitigations

  • Lessons: 3–5 bullets on techniques, heuristics, and tool tricks you want to remember. Include what you’d do faster next time.
  • Mitigations: how the bug would be fixed in real life (input validation, least privilege, IMDSv2, parameterised queries, …). One short paragraph or 2–4 bullets.

5. Category playbooks

Use these as a reminder of the kind of commands readers expect per category. They are starting points, not a script. Always explain the reasoning behind the ones you use.

web

curl -sik "$TARGET/"                                   # headers + body, ignore TLS errors
whatweb "$TARGET"                                      # fingerprint stack
ffuf -u "$TARGET/FUZZ" -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -mc all -fc 404
sqlmap -u "$TARGET/item?id=1" --batch --dbs            # only after you can explain why you suspect SQLi

Show the vulnerable request in an http block, then the payload, then the response that proves it.

active-directory

nmap -sC -sV -p- --min-rate 5000 -oA scans/full "$DC_IP"
netexec smb "$DC_IP" -u '' -p '' --shares
bloodhound-python -u user -p '<PASSWORD>' -d corp.local -ns "$DC_IP" -c All
impacket-GetUserSPNs corp.local/user:'<PASSWORD>' -dc-ip "$DC_IP" -request
hashcat -m 13100 hashes.txt /usr/share/wordlists/rockyou.txt
evil-winrm -i "$DC_IP" -u user -p '<PASSWORD>'

Include the BloodHound path as a mermaid diagram or a tight screenshot. Never paste real hashes; use <HASH>.

api

curl -s "$TARGET/api/v1/users/1" -H "Authorization: Bearer $TOKEN" | jq
curl -s -X PATCH "$TARGET/api/v1/users/2" -H "Authorization: Bearer $TOKEN" -d '{"role":"admin"}'
ffuf -u "$TARGET/api/v1/FUZZ" -w /usr/share/seclists/Discovery/Web-Content/api/api-endpoints.txt -mc 200,401,403

Show how you moved from your own object ID to someone else’s (BOLA/IDOR), or how a JWT claim was changed. Use $TOKEN, never a real token.

cloud

aws sts get-caller-identity --profile ctf
aws s3 ls "s3://<bucket>" --no-sign-request
aws iam list-attached-user-policies --user-name <USER> --profile ctf
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/

Show the identity at each step (get-caller-identity) so the reader can follow privilege changes. Credentials in output become <ACCESS_KEY_ID> / <SECRET> / <SESSION_TOKEN>.

crypto

from Crypto.Util.number import long_to_bytes, inverse
from math import gcd
# state n, e, c, then show the weakness (small e, shared factor, nonce reuse, …)

State the mathematical weakness in one or two sentences before the code. The script should print the plaintext flag, masked in the output shown.

forensics

file evidence.bin && sha256sum evidence.bin            # always hash first
strings -n 8 evidence.bin | less
exiftool evidence.jpg
binwalk -e firmware.bin
vol -f mem.raw windows.pslist
tshark -r cap.pcapng -Y "http.request" -T fields -e ip.src -e http.host -e http.request.uri

Note the hash of the evidence and the tool versions (Volatility 3 vs 2 give different output).

mobile

apktool d app.apk -o out/
jadx -d jadx_out app.apk
adb shell pm list packages | grep <name>
frida -U -f com.example.app -l hook.js

Show the decompiled function that matters and the hook or patch that bypasses it.

osint

OSINT has no shell, so write each pivot as a step: question → source → query → finding.

### Step 2: Pin the photo location

**Question:** Where was the photo taken?
**Source:** Reverse image search, then Street View.
**Finding:** Matching skyline from the north bank at 1.2833° S, 36.8167° E.
  • Defang every web source you visited that is live infrastructure (hxxps://…). Public reference sites (Wikipedia, Wayback) may stay live.
  • Record the search operators and dates (site:, filetype:, date ranges) exactly.
  • Blur or omit personal data about private people. Stay inside the challenge’s intended targets.

pwn

file ./chall && checksec --file=./chall
gdb -q ./chall            # then: pwndbg> cyclic 200 ; run ; cyclic -l <value>
ROPgadget --binary ./chall | grep "pop rdi"
python3 solve.py REMOTE

Show the protections (checksec output), the offset derivation, and the final pwntools script. State the libc/ld version when it matters.

reversing

file ./chall && strings -n 6 ./chall | head -n 40
ltrace ./chall            # library calls
strace -f ./chall         # syscalls
objdump -d -M intel ./chall | less

Show the key decompiled function, rename variables to what they mean, and explain the check or algorithm in prose before the solver.

malware

sha256sum sample.bin
capa sample.bin
floss sample.bin

Record hashes of every sample. Defang all IOCs (domains, IPs, URLs). Use hxxp://, [.], and [@] for emails.

misc / steg

file img.png && exiftool img.png
zsteg -a img.png
steghide extract -sf img.jpg -p ""
stegseek img.jpg /usr/share/wordlists/rockyou.txt
xxd img.png | head

Explain why you tried each technique (header oddity, file size mismatch, trailing bytes), not just that you tried it.

6. Screenshots, diagrams, and callouts

  • Commands and code are always text, never screenshots. Text is searchable, copy-pasteable, and accessible.

  • Use screenshots only when an image is the point: a rendered page, Burp/ZAP GUI state, Ghidra decompilation, a network graph. Crop tight, remove bookmarks and personal info, and redact secrets.

  • Save images as Attachments/<note_name>/NN_short_description.png and embed with !NN_short_description.png plus a caption sentence.

  • Use mermaid for attack chains and flows when the path has more than three hops:

    ```mermaid
    flowchart LR
      A[Path traversal] --> B[IMDS creds]
      B --> C[Assume role]
      C --> D[Private S3 bucket]
      D --> E[Flag]
    ```
  • Use a > [!question] callout for open questions you did not resolve, and > [!todo] for follow-ups you want to revisit.

  • Define unfamiliar terms in one sentence on first use, or link a Techniques/ note.

7. Safety rules (non-negotiable in this vault)

  • Mask every flag, even from finished events, in frontmatter, body, command output, screenshots, and scripts: keep the prefix, replace the body — safctf{REDACTED}, r00t{REDACTED}.
  • Defang every target in prose, callouts, and output: http:// → hxxp://, https:// → hxxps://, and every dot in a host/IP → [.] (e.g. 54[.]72[.]82[.]22, labs[.]perfectroot[.]io).
    • Documentation links (RFCs, vendor wikis, GitHub, CVE pages) may stay live.
    • In runnable command blocks, use variables ($TARGET, $DC_IP) instead of the real address. This keeps commands copy-pasteable and defanged. Set the variables in Prerequisites / Setup using a placeholder, not the live host.
    • Well-known non-challenge addresses (127.0.0.1, 169.254.169.254, RFC 1918 ranges you were given in a lab) may stay as written.
  • Never paste real credentials, tokens, or private keys. Use placeholders such as <PASSWORD>, <TOKEN>, <ACCESS_KEY_ID>, <HASH>, <PRIVATE_KEY>. Mask them in output blocks too.
  • Respect platform and event rules. Do not publish writeups for active HackTheBox machines, live competitions, or NDA-covered material (e.g. certification exam machines). Mark such notes status: partial and keep them private.
  • Malware and exploit code: only work on samples and targets that the challenge provides. Do not include working exploits against real third-party systems.

8. Linking

  • Link techniques at the bottom of each writeup under ## Techniques, e.g. - [SSRF](/knowledge/ssrf/).
  • Technique notes live in Techniques/ and link back under ## Related writeups.
  • Per-event index notes live in Indexes/; start browsing at Home.
  • Put outside sources under ## References: CVEs, vendor docs, original research, tool repos, and teammates’ notes. Credit prior art and verify links still resolve.

9. File names and attachments

  • Lowercase snake_case, matching the challenge (not necessarily the title).
  • One challenge = one note.
  • Supporting files live beside the note: Attachments/<note_name>/ for screenshots, solver scripts (solve.py), and small artefacts (pcap, payload.txt). Never commit the original challenge binaries if the event forbids redistribution.
  • Reference attachments with relative links, e.g. solve.py or !01_burp_request.png.

10. Pre-publish checklist

Before marking a note solved, confirm every box:

  • Frontmatter complete and valid (title, ctf, category, difficulty, status, flag, tags).
  • Exactly one H1, matching title; no empty or placeholder sections.
  • Info callout and Summary callout present.
  • Every step has a goal, a command, the real (trimmed) output, and an interpretation.
  • A reader can reproduce the solve from top to bottom without guessing at setup.
  • Vulnerability Analysis explains why the bug exists, not only how it was exploited.
  • Dead ends that taught something are included; unhelpful ones are cut.
  • Tool versions noted where behaviour depends on them.
  • Solve script runs end to end (if applicable) and prints a masked flag.
  • All flags masked; all targets, IOCs, and hosts defanged; no real secrets anywhere, including output blocks and screenshots.
  • Every code block closed, with a language tag.
  • Techniques linked; references credited; related technique notes updated.
  • Lessons and Mitigations written.
  • Length reasonable (roughly 1,500–3,000 words).

11. Common mistakes

Mistake Fix
Solution dump: payload and flag with no reasoning Add Enumeration and Vulnerability Analysis. Explain each step.
Commands with no output Show trimmed real output after each command.
Output with no explanation Add a sentence on what it means and what you did next.
Unexplained 40-line exploit Annotate, and walk through the key lines in prose.
Missing setup (listener, env var, /etc/hosts) Put it in Prerequisites / Setup or as its own step.
“I quickly found…” narrative Describe the real path, including confusion and hints.
Screenshot of a terminal Replace with bash + text blocks.
Live target or real flag in output Variable-ise the target, mask the flag, re-check output blocks.
Beginner note assuming expert knowledge Define terms on first use or link a Techniques/ note.
Stale links and tool versions Re-verify references and note versions.
Several partial snippets that must be stitched together Provide one complete solve script.

12. Full skeleton (copy for new notes)

---
title: '<Challenge Name>'
ctf: '<Event>'
category: web
difficulty: unknown
status: solved
flag: '<prefix>{REDACTED}'
date: YYYY-MM-DD
points:
tools: []
tags: [ctf, web]
---

# <Challenge Name>

<aside class="callout callout-info">
<p><strong>Challenge Info</strong></p>
<p><strong>Event:</strong> …</p>
<p><strong>Category:</strong> …</p>
<p><strong>Difficulty:</strong> … · <strong>Points:</strong> …</p>
<p><strong>Target:</strong> <code>hxxp://…</code></p>
<p><strong>Flag:</strong> <code><prefix>{REDACTED}</code></p>
</aside>

<aside class="callout callout-abstract">
<p><strong>Summary</strong></p>
<p><2–3 sentences: the bug or technique and the path to the flag.></p>
</aside>

## Overview

<What the challenge gives you and what the goal is.>

## Prerequisites / Setup

```bash
export TARGET="<challenge URL or IP>"
```

- Tools: `tool 1.2.3`, `tool 4.5.6`

## Recon

### Step 1 — <Goal>

**Goal:** …

```bash
<command>
```

```text
<trimmed output>
```

<What this tells us and what we do next.>

## Enumeration

### Step 2 — <Goal>

…

## Vulnerability Analysis

<aside class="callout callout-bug">
<p><strong>Root cause</strong></p>
<p><One or two sentences naming the flaw and the primitive.></p>
</aside>

<Why it is exploitable here.>

## Exploitation

### Step 3 — <Goal>

…

## Solve Script

```python
# solve.py
```

## Flag

```text
<prefix>{REDACTED}
```

## Dead Ends

<aside class="callout callout-failure">
<p><strong>Tried: <approach></strong></p>
<p><Why it failed and what it taught.></p>
</aside>

## Lessons / Takeaways

- …

## Mitigations

- …

## Techniques

- …

## References

- <Title>: https://…

13. Automation

The normalisation pass (strip preamble → unwrap outer fence → apply frontmatter → mask flags → defang → normalise headings) can be re-run for imported AI-generated notes. See the vault history for the migration commit.

Extend the pass with these checks so imported notes meet this guide:

  • Flag outputs masked inside all fenced blocks, not only the callout.
  • No http:// or https:// remaining outside the documentation-link allowlist (RFCs, vendor docs, GitHub, CVE pages).
  • Every fence closed and tagged with a language.
  • Exactly one H1; no # used below the title.
  • Steps present in Recon / Enumeration / Exploitation with command and output blocks.