Leanpub Header

Skip to main content

Adversarial Assembly

Bare-Metal Exploitation from Shellcode to Bootkit

Adversarial Assembly
This book is 100% completeLast updated on 2026-11-20

This book teaches x86-64 assembly language through the lens of offensive security. You will write shellcode by hand, exploit stack and heap vulnerabilities, build ROP chains that defeat modern mitigations, craft position-independent implants that resolve APIs at runtime, evade analysis environments, exploit kernel drivers, analyze firmware boot processes, and instrument binaries with inline hooks — all at the lowest level of abstraction the processor offers.

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

This book teaches x86-64 assembly language through the lens of offensive security. You will write shellcode by hand, exploit stack and heap vulnerabilities, build ROP chains that defeat modern mitigations, craft position-independent implants that resolve APIs at runtime, evade analysis environments, exploit kernel drivers, analyze firmware boot processes, and instrument binaries with inline hooks — all at the lowest level of abstraction the processor offers.

Every technique is demonstrated against Vectron Systems, a fictional defense-adjacent embedded systems firm, in one continuous authorized engagement. The lab runs on commodity hardware. The targets are vulnerable by design. The twenty CTF flags hidden across the engagement confirm you executed each phase correctly.

Assembly is not a convenience language. You will work harder for every capability than you would in Python or Nim. What you gain is total control — over every register, every byte on the stack, every instruction the processor decodes. When higher-level tools fail, when EDR hooks every API, when DEP and ASLR conspire against your payload — assembly is what remains.

Conventions

Code blocks are labelled by syntax:

- `{lang="asm"}` — NASM x86-64 assembly (Intel syntax)

- `{lang="python"}` — Python 3 helper scripts and exploit code

- `{lang="c"}` — Vulnerable target programs and kernel modules

- `{lang="bash"}` — Shell commands and build recipes

Findings follow the format `F01`, `F02`, etc., with CVSS 3.1 base scores.

CTF flags use the format `VECTRON{...}` and appear at key milestones.

Registers are written in lowercase (`rax`, `rsp`, `rdi`) following NASM convention.

Addresses and byte sequences are in hexadecimal (`0x41414141`, `\x31\xc0`).

Disclaimer

All techniques in this book are demonstrated within an isolated lab environment against intentionally vulnerable targets. The fictional engagement with Vectron Systems operates under explicit rules of engagement. These techniques are presented for authorized penetration testing, red team operations, and CTF competitions. Unauthorized use against systems you do not own or have explicit written permission to test is illegal and unethical.

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

Adversarial Assembly is his ninth book. You can find him collecting badges on cybersecurity training platforms and, occasionally, losing arguments with his homelab's DNS.

Contents

Table of Contents

Adversarial Assembly

  1. Bare-Metal Exploitation from Shellcode to Bootkit
  2. The Adversarial Series
  3. About This Book
  4. Conventions
  5. Disclaimer

Chapter 0: Engagement Brief — Why Assembly

  1. The Client
  2. Why Assembly
  3. Scope and Rules of Engagement
  4. Network Architecture
  5. Security Controls in Place
  6. Kill Chain Overview
  7. Toolkit Overview
  8. What You Will Need

Chapter 1: Range Deployment

  1. 1.1 Attacker Machine Setup
  2. 1.2 Building Vulnerable Targets
  3. 1.3 Docker Lab Environment
  4. 1.4 GDB Configuration
  5. 1.5 Windows Cross-Compilation
  6. 1.6 QEMU Setup for Kernel Chapters
  7. 1.7 Lab Validation
  8. Summary

Chapter 2: x86-64 Assembly for Red Teamers

  1. 2.1 Registers
  2. 2.2 Essential Instructions
  3. 2.3 System Calls — Linux
  4. 2.4 Calling Conventions
  5. 2.5 Stack Frame Anatomy
  6. 2.6 Position-Independent Coding Techniques
  7. 2.7 Common Patterns Reference
  8. 2.8 Assembly-Level Reverse Shell
  9. Summary

Chapter 3: Shellcode Development

  1. 3.1 Linux Shellcode: execve /bin/sh
  2. 3.2 Linux Shellcode: Reverse TCP Shell
  3. 3.3 XOR Encoder
  4. 3.4 Windows Shellcode: WinExec
  5. 3.5 Shellcode Test Harness
  6. 3.6 Findings
  7. Summary

Chapter 4: Stack Exploitation

  1. 4.1 Anatomy of a Stack Overflow
  2. 4.2 Finding the Offset
  3. 4.3 Return Address Hijack — Redirect to secret_function
  4. 4.4 NOP Sled + Shellcode Injection
  5. 4.5 Stack Canary Bypass
  6. 4.6 Structured Exception Handler (SEH) Overflow (Windows)
  7. 4.7 The vectron-stack Tool
  8. 4.8 Findings
  9. Summary

Chapter 5: Return-Oriented Programming

  1. 5.1 Why ROP Works
  2. 5.2 Gadget Hunting
  3. 5.3 ROP Chain: mprotect to Enable Shellcode Execution
  4. 5.4 ROP Chain: execve via Syscall
  5. 5.5 Sigreturn-Oriented Programming (SROP) Introduction
  6. 5.6 The vectron-rop Tool
  7. 5.7 Findings
  8. Summary

Chapter 6: Heap Exploitation

  1. 6.1 ptmalloc2 Internals
  2. 6.2 Use-After-Free Exploitation
  3. 6.3 Double-Free Attack
  4. 6.4 Heap Spray
  5. 6.5 Assembly-Level Heap Manipulation
  6. 6.6 The vectron-heap Tool
  7. 6.7 Findings
  8. Summary

Chapter 7: Position-Independent Code

  1. 7.1 The Windows Process Environment Block
  2. 7.2 PE Export Table Parsing
  3. 7.3 API Hashing
  4. 7.4 PIC Reverse Shell for Windows
  5. 7.5 Reflective DLL Loading Concept
  6. 7.6 The vectron-pic Tool
  7. 7.7 Findings
  8. Summary

Chapter 8: Anti-Analysis & Evasion

  1. 8.1 Debugger Detection
  2. 8.2 Anti-VM Detection
  3. 8.3 Evasion Techniques
  4. 8.4 The vectron-cloak Tool
  5. 8.5 Findings
  6. Summary

Chapter 9: Kernel-Mode Exploitation

  1. 9.1 Ring 0 vs Ring 3
  2. 9.2 Vulnerable Driver — IOCTL Interface
  3. 9.3 Kernel Stack Overflow Exploitation
  4. 9.4 Token Stealing in Assembly
  5. 9.5 Driver Signature Enforcement Bypass
  6. 9.6 The vectron-kern Tool
  7. 9.7 Findings
  8. Summary

Chapter 10: Firmware & Bootloaders

  1. 10.1 Boot Process Architecture
  2. 10.2 MBR Analysis
  3. 10.3 UEFI Firmware Extraction and Analysis
  4. 10.4 Bootkit Concepts
  5. 10.5 The vectron-boot Tool
  6. 10.6 Findings
  7. Summary

Chapter 11: Binary Patching & Instrumentation

  1. 11.1 Inline Hooking
  2. 11.2 IAT Hooking
  3. 11.3 PE Binary Patching
  4. 11.4 Dynamic Binary Instrumentation with Frida
  5. 11.5 The vectron-hook and vectron-patch Tools
  6. 11.6 Findings
  7. Summary

Chapter 12: Reporting

  1. 12.1 Executive Summary
  2. 12.2 Severity Distribution
  3. 12.3 Findings by Chapter
  4. 12.4 Complete Findings Register
  5. 12.5 Attack Chain Narrative
  6. 12.6 CTF Flag Register
  7. 12.7 Toolkit Summary
  8. 12.8 Remediation Roadmap
  9. 12.9 Report Generation Script
  10. Summary

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