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...
An advanced, hands-on pentest you run against your own lab — in Python.
One target. Thirteen chapters. Every tool built from scratch.
Helix Dynamics looks like any other small fintech — a web app, a Postgres backend, an Active Directory estate, and an AI assistant bolted on for support. It also happens to be running in your homelab, and it’s yours to break.
Adversarial Python walks you through a complete, realistic engagement against Helix — recon, exploitation, privilege escalation, lateral movement, and reporting — but instead of just running someone else’s tools, you write your own. By the final chapter you’ll have built a scanner, a crawler, a prompt-injection fuzzer, an AD attack toolkit, and a report generator, all in Python, all battle-tested against a live (and entirely legal) target.
18 flags. 22 findings. Zero shortcuts.
Minimum price
$10.99
$14.99
About the Book
## 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 |
Bundles that include this book

2 Books
About the Author
**Andrew Ingram** is a cybersecurity professional with years of experience in banking and financial services security. His career has spanned threat analysis, security operations, phishing simulation, and security awareness — the kind of work where you see real attacks hit real infrastructure every day and have to decide, fast, what to do about them.
That day-job exposure to adversary tradecraft is what drives this book. Andrew built every tool in these pages because he wanted to understand exactly what the frameworks were doing under the hood — and because the best way to defend a network is to know how it breaks. When he is not dissecting BEC campaigns or writing detection rules at work, he is standing up lab ranges, chasing flags, and turning offensive techniques into clean, reusable Python.
*Adversarial Python* is his second book. You can find him collecting badges on cybersecurity training platforms and, occasionally, losing arguments with his homelab's DNS.
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.