Leanpub Header

Skip to main content

Adversarial JavaScript

A full-stack penetration test built entirely in JavaScript — from first packet to final report.

Adversarial JavaScript
This book is 100% completeLast updated on 2026-11-19

Every chapter of this book advances a single, continuous engagement against one fictional target that lives entirely in your homelab: Vectrix Labs, a cloud-native SaaS company that sells a threat-intelligence platform to enterprise security teams. Vectrix runs the modern JavaScript stack end to end — a React front end, a Node.js/Express API layer, a GraphQL gateway, MongoDB for persistence, Redis for sessions, and a Kubernetes cluster that ties it all together. One target carries every phase of the pentest: the external edge, a web application thick with client-side logic, a real-time WebSocket feed, an AI-powered analyst chatbot, and the cloud infrastructure underneath.

You don't just run tools against Vectrix. You build the tools, in JavaScript, one phase at a time: your own recon harness, your own scanner, your own crawler, your own exploits, your own post-exploitation agents, and finally your own report generator. Each phase ends with a captured flag — `VECTRIX{...}` — and those flags become the evidence trail for the deliverable you assemble in the final chapter.

Minimum price

$10.99

$14.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Every chapter of this book advances a single, continuous engagement against one fictional target that lives entirely in your homelab: Vectrix Labs, a cloud-native SaaS company that sells a threat-intelligence platform to enterprise security teams. Vectrix runs the modern JavaScript stack end to end — a React front end, a Node.js/Express API layer, a GraphQL gateway, MongoDB for persistence, Redis for sessions, and a Kubernetes cluster that ties it all together. One target carries every phase of the pentest: the external edge, a web application thick with client-side logic, a real-time WebSocket feed, an AI-powered analyst chatbot, and the cloud infrastructure underneath.

You don't just run tools against Vectrix. You build the tools, in JavaScript, one phase at a time: your own recon harness, your own scanner, your own crawler, your own exploits, your own post-exploitation agents, and finally your own report generator. Each phase ends with a captured flag — `VECTRIX{...}` — 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 JavaScript and you have seen a pentest before. This book pushes past tutorial territory into the patterns that make offensive tooling fast and reliable: `fetch` and `undici` for HTTP, `async/await` for concurrency, Node.js streams and `child_process` for system interaction, `ws` for WebSocket manipulation, `puppeteer` for browser automation, and `crypto` for the primitives that show up everywhere in modern auth. If you have never written JavaScript beyond a "Hello World," 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 `VECTRIX{...}`. 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 JavaScript 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 JavaScript |

| --- | --- | --- |

| 0 | Rules of engagement | Workstation preflight check |

| 1 | Range build & inventory | `range_control.mjs` — Docker orchestrator + asset inventory |

| 2 | Passive recon / OSINT | Async DNS, certificate transparency, dossier builder |

| 3 | Active recon & scanning | Your own async port scanner + service fingerprinter |

| 4 | Web attack surface | Headless crawler, content discovery, parameter miner |

| 5 | Vulnerability discovery | A focused scanner (XSS / prototype pollution / SSRF) |

| 6 | Exploitation — the web foothold | NoSQL injection + JWT forgery; your first shell |

| 7 | Exploiting the AI layer | Prompt-injection fuzzer; RAG poisoning; tool-call abuse |

| 8 | Post-exploitation | Reverse shells, WebSocket C2, living-off-the-land |

| 9 | Privilege escalation | Container escape, service-account abuse, secrets in env |

| 10 | Cloud & lateral movement | Kubernetes pivoting, service-mesh abuse, SSRF to metadata |

| 11 | Actions on objectives | Data exfiltration over DNS and WebSocket covert channels |

| 12 | Reporting | Parse every flag + finding into a scored deliverable |

Bundle

Bundles that include this book

Author

About the Author

Andrew Ingram

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 series. 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 code.

Adversarial JavaScript is the fifth book in the Adversarial Series, following Python, Rust, Bash, and PowerShell. You can find him collecting badges on cybersecurity training platforms and, occasionally, losing arguments with his homelab's DNS.

Contents

Table of Contents

Adversarial JavaScript

  1. About This Book
  2. Who This Book Is For
  3. Conventions
  4. Roadmap
  5. About the Author

Chapter 0 — Rules of Engagement

  1. Briefing
  2. The one rule
  3. What you should already know
  4. Setting up the workstation
  5. Optional: an LLM copilot
  6. Build: the preflight check
  7. Capture
  8. Debrief

Chapter 1 — Range Build & Inventory

  1. Briefing
  2. Objective
  3. Concepts
  4. Build: the range
  5. Build: the range controller
  6. Capture
  7. Finding: secrets in container environment variables
  8. Debrief

Chapter 2 — Passive Recon / OSINT

  1. Briefing
  2. Objective
  3. Concepts
  4. Build: adding DNS to the range
  5. Build: the DNS recon tool
  6. Build: the certificate-transparency tool
  7. Build: the dossier builder
  8. Capture
  9. Findings
  10. Debrief

Chapter 3 — Active Recon & Scanning

  1. Briefing
  2. Objective
  3. Concepts
  4. Build: adding a hidden service to the range
  5. Build: the port scanner
  6. Build: the service fingerprinter
  7. Build: the scan report generator
  8. Capture
  9. Findings
  10. Debrief

Chapter 4 — Web Attack Surface

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build — the headless crawler
  6. Build — content discovery
  7. Build — GraphQL introspection
  8. Capture
  9. Debrief

Chapter 5 — Vulnerability Discovery

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build — XSS scanner
  6. Build — prototype pollution scanner
  7. Build — SSRF probe
  8. Build — vulnerability report generator
  9. Capture
  10. Debrief

Chapter 6 — Exploitation: The Web Foothold

  1. Briefing
  2. Objective
  3. The kill chain
  4. Concepts
  5. Range additions
  6. Build — NoSQL injection bypass
  7. Build — JWT attack toolkit
  8. Build — foothold: chaining it all together
  9. Capture
  10. Debrief

Chapter 7 — Exploiting the AI Layer

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build
  6. Capture
  7. Debrief

Chapter 8 — Post-Exploitation

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build
  6. Capture
  7. Debrief

Chapter 9 — Privilege Escalation

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build
  6. Capture
  7. Debrief

Chapter 10 — Cloud & Lateral Movement

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build
  6. Capture
  7. Debrief

Chapter 11 — Actions on Objectives

  1. Briefing
  2. Objective
  3. Concepts
  4. Range additions
  5. Build
  6. Capture
  7. Debrief

Chapter 12 — Reporting

  1. Briefing
  2. Objective
  3. Concepts
  4. Build
  5. Capture
  6. Debrief

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...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

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

Free Updates. DRM Free.

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

Write and Publish on Leanpub

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.

Learn more about writing on Leanpub