Most offensive-security books hand you a framework and a flag. This one hands you `cargo new` and a target.
**Apex Foundry** is a precision-manufacturing company that builds industrial control interfaces, runs a customer-facing web application backed by Postgres, operates an Active Directory domain for its corporate workforce, and recently bolted an AI assistant onto its support portal. It also happens to be running entirely inside your homelab — Docker containers, a virtual AD forest, and a vulnerable web stack you control end to end.
Your job is to break it. Your constraint is that every tool you use must be one you wrote yourself, in Rust.
Over thirteen chapters you will work through a single, continuous penetration test — from passive reconnaissance through data exfiltration and final reporting. Each chapter adds a link to the attack chain: you will build async port scanners, web crawlers, exploit frameworks, a prompt-injection fuzzer, an encrypted implant, Kerberoasting tooling, a covert DNS exfiltration channel, and a report generator that pulls every finding into a finished deliverable. Every tool compiles to a single, dependency-free binary you can drop on a target without a runtime.
Along the way you will capture **twenty flags** (format: `APEX{...}`) and document **twenty-two findings**, building a portfolio that doubles as a real-world pentest report.
### Why Rust?
Python dominates offensive tooling for good reason — it is fast to write, easy to read, and ubiquitous on target machines. But Rust offers something Python cannot:
- **No runtime dependency.** A Rust binary is a single static executable. No interpreter to install, no virtualenv to configure, no `pip install` on a compromised host.
- **Memory safety without garbage collection.** Implants that manage their own memory without a GC pause are harder to fingerprint and more reliable under constrained resources.
- **Performance.** An async port scanner built on Tokio saturates a gigabit link. A fuzzer built on Rust's zero-cost abstractions runs at native speed.
- **Cross-compilation.** `cargo build --target x86_64-unknown-linux-musl` produces a fully static Linux binary from macOS or Windows. `cargo build --target x86_64-pc-windows-gnu` produces a Windows `.exe` from Linux.
- **Growing real-world adoption.** Red teams and malware authors alike are moving to Rust. Understanding Rust-based tooling is no longer optional for defenders — and building it is the fastest way to understand it.
This book does not replace your Python toolkit. It extends it with a language that excels where Python struggles: on-target execution, raw performance, and operational security.
## Who This Book Is For
You should be comfortable with:
- **Rust fundamentals.** You know `struct`, `enum`, `impl`, `trait`, ownership, borrowing, and lifetimes. You have written at least a few programs with `cargo`. This book will not teach the language — it will teach you what to build with it.
- **Networking basics.** TCP/IP, DNS, HTTP, and TLS at a conceptual level. You know what a SYN packet is and what a `301` means.
- **Linux command-line work.** Shell navigation, process management, file permissions. You will live in a terminal.
- **Docker.** You can pull images, run containers, and read a `docker-compose.yml`. The entire lab runs in containers.
Prior penetration-testing experience helps but is not required. Each chapter explains the *why* before the *how*.
## Conventions Used in This Book
Each chapter follows a consistent structure:
| Section | Purpose |
| --- | --- |
| **Briefing** | Sets the operational context — where you are in the engagement and what intelligence you have so far. |
| **Objective** | States the chapter's concrete goal: what you will build and what flag(s) you will capture. |
| **Concepts** | Explains the underlying vulnerability class, protocol, or technique before you write a line of code. |
| **Build** | Walks through the tool's design and implementation in Rust, crate by crate, function by function. |
| **Capture** | Runs the finished tool against the lab range and captures one or more flags. |
| **Debrief** | Reviews what the tool revealed, documents findings, and previews the next chapter's attack vector. |
Code blocks use Markua's language-annotated fences:
{lang="rust"}
```
fn main() {
println!("You are reading a Rust code block.");
}
```
Shell commands appear as:
{lang="bash"}
```
cargo build --release --target x86_64-unknown-linux-musl
```
Flags appear inline when captured and follow the format `APEX{lower_case_l33t}`.
## Engagement Roadmap
| Ch. | Title | Tool Built | Flags |
| --- | --- | --- | --- |
| 0 | Rules of Engagement | Workstation preflight checker | 1 |
| 1 | Building the Range | Range orchestrator (`apex-range`) | 1 |
| 2 | Passive Reconnaissance | DNS enumerator and OSINT dossier builder | 1 |
| 3 | Active Reconnaissance & Scanning | Async TCP scanner and service fingerprinter | 1 |
| 4 | Mapping the Web Attack Surface | Web crawler, content discovery, parameter miner | 3 |
| 5 | Vulnerability Discovery | IDOR/SSRF scanner with triage engine | 2 |
| 6 | Exploitation: The Web Foothold | SQL-injection extractor and foothold shell | 2 |
| 7 | Exploiting the AI Layer | Prompt-injection fuzzer and agent-abuse toolkit | 3 |
| 8 | Post-Exploitation | Encrypted reverse-shell implant and async tasker | 1 |
| 9 | Privilege Escalation | Linux enumerator, SUID exploit, container escape | 2 |
| 10 | Active Directory & Lateral Movement | Kerberoasting client, SMB lateral-movement tool | 2 |
| 11 | Actions on Objectives | Data hunter and DNS exfiltration channel | 1 |
| 12 | Reporting | Findings database, CVSS scorer, report generator | — |
| | | **Total** | **20** |