Leanpub Header

Skip to main content

Adversarial C

Embedded Exploitation from Buffer Overflows to Firmware Rootkits

Adversarial C
This book is 100% completeLast updated on 2026-11-21

Adversarial C is Book X in the Adversarial Series — a continuous penetration testing engagement against Crucible Embedded, a defense-adjacent embedded systems manufacturer. Over thirteen chapters you will exploit buffer overflows in firmware update daemons, abuse format string vulnerabilities in logging services, corrupt heap metadata in real-time operating system processes, fuzz custom network protocols until they crack, extract secrets from firmware images, pivot through IoT gateways running stripped-down BusyBox, exploit race conditions in privileged services, and attack the software supply chain through build system manipulation.

The Adversarial C++ book is currently in the works, and should be released sometime before Christmas. So keep an eye open for that!

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

Adversarial C is Book X in the Adversarial Series — a continuous penetration testing engagement against Crucible Embedded, a defense-adjacent embedded systems manufacturer. Over thirteen chapters you will exploit buffer overflows in firmware update daemons, abuse format string vulnerabilities in logging services, corrupt heap metadata in real-time operating system processes, fuzz custom network protocols until they crack, extract secrets from firmware images, pivot through IoT gateways running stripped-down BusyBox, exploit race conditions in privileged services, and attack the software supply chain through build system manipulation.

Every exploit is written in C. Every tool is compiled from source. Every finding is documented to professional pentest-report standards with CVSS 3.1 scoring.

By the end of this book you will have captured 20 CTF flags, documented 47 findings, and built 10 custom offensive tools — all targeting embedded systems where memory safety is a luxury the firmware authors could not afford.


The Adversarial C++ book is currently in the works, and should be released sometime before Christmas. So keep an eye open for that!

---

Conventions

Throughout this book, the following conventions are used:

- Command prompts — `crucible㉿attacker` indicates the attack platform; `root@iot01` or `fw@build01` indicate target shells.

- Flags — CTF flags follow the format `CRUCIBLE{flag_text}` and are highlighted when captured.

- Findings — Vulnerability findings are boxed with an ID (e.g., `CRUC-F01`), title, CVSS 3.1 score, and remediation guidance.

- Code blocks — All exploit code is complete and functional. Language hints appear above each block.

- IP addresses — The engagement uses the `10.30.40.0/24` subnet. All addresses are fictional.

---

Disclaimer

This book is intended for authorized security testing and educational purposes only. All techniques are demonstrated against fictional infrastructure within a controlled lab environment. The fictional company "Crucible Embedded" does not exist. Never apply these techniques against systems without explicit written authorization from the system owner. Unauthorized access to computer systems is illegal under the Computer Fraud and Abuse Act (18 U.S.C. § 1030) and equivalent laws worldwide.

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

Adversarial C is his tenth 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 C

  1. Embedded Exploitation from Buffer Overflows to Firmware Rootkits

Chapter 00 — Engagement Brief

  1. Client Profile
  2. Engagement Scope
  3. Rules of Engagement
  4. Security Controls in Place
  5. Toolkit Preview
  6. Engagement Kickoff

Chapter 01 — Range Deployment

  1. Objective
  2. Attack Platform Setup
  3. Project Directory Structure
  4. Compilation Flags Reference
  5. Target Reconnaissance
  6. GDB Configuration for Embedded Debugging
  7. Vulnerable Service Verification
  8. Exploit Development Template
  9. Environment Validation

Chapter 02 — C Fundamentals for Red Teamers

  1. Objective
  2. The C Memory Model
  3. The Stack Frame in Detail
  4. Calling Conventions
  5. Dangerous Functions — The Exploitation Surface
  6. Undefined Behavior as Attack Surface
  7. Compilation Analysis with objdump and readelf
  8. Pwntools Integration for C Exploitation
  9. Key Takeaways for Exploitation

Chapter 03 — Buffer Overflows

  1. Objective
  2. Target: CruxNode Debug Service (IOT01:9999)
  3. Exploit 1: Classic Stack Overflow — CruxNode Debug Service
  4. Exploit 2: Off-by-One Overflow in CruxGate HTTP Admin
  5. Exploit 3: Return-to-libc on FW01
  6. Exploit 4: Stack Overflow with Canary Leak on BUILD01
  7. Additional Findings

Chapter 04 — Format String Exploitation

  1. Objective
  2. Format String Fundamentals
  3. Target 1: CruxGate Syslog Daemon (GW01:514)
  4. Target 2: FW01 Custom Logger Format String
  5. Auxiliary Findings

Chapter 05 — Heap Exploitation

  1. Objective
  2. Heap Allocator Internals
  3. Exploit 1: Use-After-Free in CruxForge Package Manager
  4. Exploit 2: Double-Free on CruxGate Session Manager
  5. Exploit 3: Heap Overflow in CruxNode RTOS Task Allocator
  6. Additional Findings

Chapter 06 — Integer Vulnerabilities

  1. Objective
  2. Integer Vulnerability Classes
  3. Exploit 1: Signed Integer Overflow in Firmware Size Check
  4. Exploit 2: Integer Truncation in CruxNode Packet Parser
  5. Exploit 3: Signedness Mismatch in CruxForge Access Control
  6. Additional Findings

Chapter 07 — Fuzzing & Vulnerability Discovery

  1. Objective
  2. Fuzzing Strategy
  3. Harness 1: AFL++ Fuzzing the CruxNode Packet Parser
  4. Fuzzer Results

Chapter 08 — Firmware Analysis & Extraction

  1. Objective
  2. Firmware Acquisition
  3. Tool: crucible_fwextract
  4. Firmware Analysis Results
  5. Critical Findings from Firmware Analysis
  6. Findings

Chapter 09 — Embedded Exploitation

  1. Objective
  2. ARM Exploitation Primer
  3. Tool: crucible_armpwn
  4. Attack Chain: IOT01 Full Compromise
  5. Pivoting from IOT01 into the Internal Network
  6. Findings

Chapter 10 — Race Conditions & Signal Handlers

  1. Objective
  2. Race Condition Taxonomy
  3. Tool: crucible_racer
  4. Findings

Chapter 11 — Supply Chain & Build System Attacks

  1. Objective
  2. Attack Surface Map
  3. Tool: crucible_chainload
  4. Full Supply Chain Attack Demonstration
  5. Findings

Chapter 12 — Reporting & Remediation

  1. Objective
  2. Engagement Summary
  3. Tool: crucible_patcher
  4. Verification Run
  5. Complete Findings Summary
  6. Attack Chains Demonstrated
  7. Remediation Priorities
  8. Tools Developed
  9. Flags Captured
  10. Conclusion

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