Most offensive-security books hand you a framework and a flag. This one hands you a terminal prompt 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 Bash.
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 port scanners with `/dev/tcp`, web crawlers with `curl`, SQL-injection extractors with pipes and string manipulation, a prompt-injection fuzzer with `jq`, a cron-persisted reverse-shell implant, Kerberoasting wrappers, a covert DNS exfiltration channel with `dig`, and a report generator that pulls every finding into a finished deliverable. Every tool is a script you can paste into any Linux terminal with zero dependencies beyond a standard installation.
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 Bash?
Python dominates offensive tooling for good reason — it is powerful, readable, and everywhere. Rust compiles to fast, dependency-free binaries. But Bash offers something neither can:
- It is already on the target. Every Linux host, every container, every cloud instance ships with a POSIX shell. There is nothing to install, nothing to upload, nothing to compile. Your tool *is* the terminal.
- No forensic footprint. A Bash script leaves no binary on disk, no interpreter to flag, no package manager log. When you pipe commands through a reverse shell, the tool exists only in memory and in process lists.
- Living off the land. `curl`, `dig`, `awk`, `grep`, `find`, `openssl`, `base64`, `xxd`, `sqlite3` — standard utilities that defenders expect to see in log files. Using them for offense is indistinguishable from normal administration.
- Instant iteration. No compile step, no dependency resolution, no virtual environment. Edit, run, observe. The feedback loop is measured in keystrokes.
- Universal skill transfer. Every sysadmin writes Bash. Learning to weaponize it teaches you to defend against the same techniques — because the attacker at the keyboard looks exactly like the admin.
This book does not replace your Python toolkit or your compiled Rust binaries. It extends your capabilities into the space where those tools cannot go — the compromised host where you have a shell and nothing else.
Who This Book Is For
You should be comfortable with:
- Bash fundamentals. You know variables, loops, conditionals, functions, pipes, and redirection. You have written at least a few scripts that automate real tasks. This book will not teach the shell — 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, `cron`. 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 Bash, utility by utility, 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="bash"}
```
#!/usr/bin/env bash
echo "You are reading a Bash code block."
```
Shell output appears as:
{lang="text"}
```
[+] Target: apex-web.foundry.local
[+] Open ports: 22, 80, 443, 5432
```
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.sh`) | 1 |
| 2 | Passive Reconnaissance | DNS enumerator and OSINT dossier builder | 1 |
| 3 | Active Reconnaissance & Scanning | Bash 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 | Cron-persisted reverse-shell implant and task runner | 1 |
| 9 | Privilege Escalation | Linux enumerator, SUID exploit, container escape | 2 |
| 10 | Active Directory & Lateral Movement | Kerberoasting wrapper, SSH 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 |