The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...

## Briefing
Your workstation is cleared. The next step in any engagement is understanding the target environment — and in a homelab engagement, that means building it first.
Apex Foundry's infrastructure is simulated by a Docker Compose stack: a web application (Rust/Actix-Web), a Postgres database, an internal API gateway, a Redis cache, a mail server, and a DNS server seeded with records that mirror a real corporate domain. Later chapters will add an AI assistant container and a Samba-based Active Directory domain controller.
You will not manage this range by hand. You will build a Rust tool that orchestrates the entire lifecycle — standing containers up, checking their health, inventorying exposed services, and tearing the range down cleanly.
## Objective
Build a **range orchestrator** (`apex-range`) that wraps the Docker API, manages the lab lifecycle, and inventories every running service. Capture the flag hidden in a Docker label on one of the range containers.
**Flag:** `APEX{1nv3nt0ry_b3f0r3_3xpl01ts}`
Bought separately
$41.97
$29.00
About the Bundle
This bundle includes 3 books written by Andrew Ingram, a cyber security specialist with years of experience in the industry protecting Financial institutions and Banks.
Books included are:
Dolphin In The Lab - Red team labs based around the Flipper Zero device.
Adversarial Python - Red team labs using the Python programming language.
Adversarial Rust - Red team labs using the Rust programming language.
And coming soon:
Adversarial Bash - Red team labs using the Bash scripting language.
About the Books
## About This Book
Every chapter of this book advances a single, continuous engagement against one fictional target that lives entirely in your homelab: **Helix Dynamics**, a small AI-native fintech. One target carries every phase of the pentest — external edge, a web app and JSON API, a Postgres backend, an Active Directory estate, and an internal LLM assistant that eventually becomes a target in its own right.
You don't just run tools against Helix. You **build** the tools, in Python, one phase at a time: your own range orchestrator, your own scanner, your own crawler, your own exploits, your own post-exploitation tasking, and finally your own report generator. Each phase ends with a captured flag — `HELIX{...}` — and those flags become the evidence trail for the deliverable you assemble in the final chapter.
Nothing in this book touches a system you do not own. The entire range is yours: stood up locally with one command, attacked, and torn down when you are done.
## Who This Book Is For
You already write Python and you have seen a pentest before. This book pushes past tutorial territory into the idioms that make offensive tooling fast and maintainable: `asyncio` for concurrency, `dataclasses` and type hints for structured results, `httpx`, `impacket`, subprocess orchestration, and clean packaging. If you have never written Python, start elsewhere and come back. If you want to understand what your tools actually do — and build better ones — you are in the right place.
## Conventions
**Flags.** Each chapter plants at least one flag in the range, in the format `HELIX{...}`. You capture it by running the tool you just built, not by reading it out of a config file. Flags are cumulative; keep them.
**The chapter rhythm.** Every chapter follows the same beat:
| Beat | What it is |
| --- | --- |
| Briefing | The story moves one step forward in the engagement |
| Objective | The concrete goal and the flag to capture |
| Concepts | The Python ideas the chapter introduces |
| Build | Complete, working tooling you type and run |
| Capture | Running your tool against the range to take the flag |
| Debrief | The blue-team view: what this looks like to a defender |
Some chapters add an **AI Corner** — an optional sidebar that uses or attacks an LLM. It is never required to finish a chapter.
**Lab safety.** The range is self-contained and offline-capable. Treat every technique here as lab-only. The same code pointed at infrastructure you are not authorized to test is a crime; authorization is the only thing separating this book from one.
## Roadmap
| Ch | Phase | What you build in Python |
| --- | --- | --- |
| 0 | Rules of engagement | Workstation preflight check |
| 1 | Range build & inventory | `range_control.py` — orchestrator + asset inventory |
| 2 | Passive recon / OSINT | Async DNS, cert-transparency, and a dossier builder |
| 3 | Active recon & scanning | Your own async port scanner + service fingerprinter |
| 4 | Web attack surface | Crawler, content discovery, and parameter miner |
| 5 | Vulnerability discovery | A focused scanner (SQLi / SSRF / IDOR) with triage |
| 6 | Exploitation — the web foothold | Working PoCs; your first shell on Helix |
| 7 | Exploiting the AI layer | Prompt-injection fuzzer; RAG and agent abuse |
| 8 | Post-exploitation | Python reverse shells, tasking, living-off-the-land |
| 9 | Privilege escalation | Linux privesc enumeration, SUID abuse, Docker escape |
| 10 | Active Directory & lateral movement | `impacket`: Kerberoasting, AS-REP, pass-the-hash |
| 11 | Actions on objectives | Data hunting and a covert exfil channel |
| 12 | Reporting | Parse every flag + finding into a scored deliverable |
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** |
The Flipper Zero became famous by looking like a magic key. It isn't one — it's the best pocket-sized way to truly understand the radios, cards, and buses that run the physical world. Dolphin in the Lab turns that curiosity into real, defensible skill.
Across fourteen hands-on chapters, you'll build a safe homelab and work every interface the Flipper touches — capturing and replaying Sub-GHz signals, cloning legacy access cards, reading hardware debug ports and dumping firmware, injecting keystrokes, standing up Wi-Fi recon, and writing your own Flipper testing apps in Python and C. Every offensive chapter ends with its defensive mirror: how to detect the attack, and how to shut it down. You'll finish by scoring findings with CVSS and chaining everything into a full capstone assessment with a professional report.
What you'll learn
Who it's for
Aspiring and early-career penetration testers, red and blue teamers, and serious hobbyists who are comfortable at a Linux command line. No prior RF or hardware experience required — the book builds that.
Lab-safe by design. Every technique is built for hardware you own, inside a lab you control — in scope, in-band, and within the law.
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.