Leanpub Header

Skip to main content

Adversarial SQL

A Penetration Tester's Guide to Database Exploitation

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

SQL is not just a query language. In the hands of a penetration tester, it is a weapon that can read files, execute operating system commands, pivot between servers, and exfiltrate entire databases through covert channels. Every enterprise runs on SQL databases, and nearly every web application speaks to one. When the application doesn't properly separate user input from SQL logic, the attacker controls the database — and often the host underneath it.

This book teaches database exploitation through one continuous engagement against **Lumen Dataworks**, a fictional financial data aggregation platform. You will deploy a realistic multi-database lab — PostgreSQL, Microsoft SQL Server, and MySQL behind vulnerable web applications — and systematically compromise it from SQL injection discovery through lateral movement, persistence, and exfiltration. Every tool you build works. Every payload you craft is real. Every technique maps to a finding you will document in a professional penetration test report.

This book assumes you are comfortable with basic SQL syntax (SELECT, INSERT, UPDATE, DELETE, JOIN) and have a working knowledge of web application testing. You do not need to be a DBA — the book teaches the internals that matter for exploitation as you encounter them.

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

SQL is not just a query language. In the hands of a penetration tester, it is a weapon that can read files, execute operating system commands, pivot between servers, and exfiltrate entire databases through covert channels. Every enterprise runs on SQL databases, and nearly every web application speaks to one. When the application doesn't properly separate user input from SQL logic, the attacker controls the database — and often the host underneath it.

This book teaches database exploitation through one continuous engagement against **Lumen Dataworks**, a fictional financial data aggregation platform. You will deploy a realistic multi-database lab — PostgreSQL, Microsoft SQL Server, and MySQL behind vulnerable web applications — and systematically compromise it from SQL injection discovery through lateral movement, persistence, and exfiltration. Every tool you build works. Every payload you craft is real. Every technique maps to a finding you will document in a professional penetration test report.

This book assumes you are comfortable with basic SQL syntax (SELECT, INSERT, UPDATE, DELETE, JOIN) and have a working knowledge of web application testing. You do not need to be a DBA — the book teaches the internals that matter for exploitation as you encounter them.

## The Engagement

**Client:** Lumen Dataworks

**Type:** Web Application Penetration Test — Database Focus

**Scope:** All database-backed web applications and exposed database services within the Lumen Dataworks lab environment

**Methodology:** Reconnaissance → Injection Discovery → Exploitation → Post-Exploitation → Lateral Movement → Persistence → Exfiltration → Reporting

## Conventions

Code blocks with `{lang="sql"}` contain SQL payloads — the core adversarial craft. Code blocks with `{lang="python"}` contain Python orchestration scripts that deliver those payloads. Code blocks with `{lang="bash"}` contain shell commands.

Flags follow the format `LUMEN{...}` and prove each objective was completed. Collect them all.

## Disclaimer

The techniques in this book are for authorized penetration testing and educational purposes only. Deploy the included lab environment and practice there. Never test against systems without explicit written authorization.

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 SQL is the seventh book in the Adversarial Series, following Python, Rust, Bash, PowerShell, Go, JavaScript, and now SQL. You can find him collecting badges on cybersecurity training platforms and, occasionally, losing arguments with his homelab's DNS.

Contents

Table of Contents

Chapter 0 — Preflight

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

Chapter 1 — Range Deployment

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

Chapter 2 — Reconnaissance

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

Chapter 3 — Injection Discovery

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

Chapter 4 — Classic Exploitation

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

Chapter 5 — Blind Injection

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

Chapter 6 — WAF Evasion & Filter Bypass

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

Chapter 7 — From SQLi to Shell

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

Chapter 8 — Post-Exploitation

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

Chapter 9 — Lateral Movement

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

Chapter 10 — Persistence

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

Chapter 11 — Data Exfiltration

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

Chapter 12 — Reporting

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

Adversarial SQL

  1. A Penetration Tester’s Guide to Database Exploitation
  2. About This Book
  3. The Engagement
  4. Conventions
  5. Disclaimer

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