Non-Fiction, Informative, Educational

Exploit Developer eBook

A Coursebook on Exploit Developer

by Zeller Evelin

  • English
  • 143 pages
  • 2026
  • SamEnrico

A Coursebook on Exploit Developer

Formats

Free sample

Chapter 1: The Memory Beneath...--– The first thing you must understand about exploit development is that software lies to you. Not intentionally, not with malice, but with the quiet deception of abstraction. Every time you write a line of C, every time a function returns, every time a variable changes value, the hardware underneath is performing a desperate dance of electrical states that your high-level mind has been trained to ignore. The compiler, the operating system, the runtime—they all conspire to convince you that memory is a clean, orderly place where variables have names and functions have boundaries. This is a beautiful fiction. And your job as an exploit developer is to learn to see through it.The truth is far more primitive and far more dangerous. Memory is just a long, flat sequence of bytes—millions or billions of them, each identified by a number called an address. There are no variable names down here. No types. No security boundaries. Just bytes, arranged in patterns that the CPU interprets as code, data, or pointers. When a program runs, it allocates regions of this memory for different purposes: code lives in one area, global variables in another, dynamically allocated data in yet another. But at the machine level, these are just conventions. Nothing physically prevents a program from treating a return address as if it were a string, or executing data as if it were code. That is where you come in.This chapter strips away every layer of abstraction between you and the machine. You will learn to see the stack not as a convenient place to store local variables, but as a linear array of return addresses waiting to be corrupted. You will learn to watch the instruction pointer—the CPU's own sense of "where it is"—as it marches through memory, vulnerable to anyone who can rewrite the address it reads next. And you will learn why the C language, for all its age and power, remains the single greatest source of exploitable vulnerabilities in the history of computing.By the end of this chapter, you will have written your first program that crashes not because it has a bug, but because you deliberately corrupted its memory. You will have watched the instruction pointer go to a value you chose. And you will understand that exploit development is not about magic or mystery—it is about understanding exactly where the abstractions end and the raw machine begins.1.1 The Myth of Safe Software Every exploit you will ever write exists because of a fundamental mismatch between how programmers think about memory and how memory actually works. A programmer sees a variable named password[8] and thinks, "This is a container for eight characters." The CPU sees a memory address and eight bytes. Nothing in the hardware enforces that the code which writes to those eight bytes stops at eight. Nothing prevents code from reading beyond them. The programmer's intention is enforced solely by the compiler, the runtime checks the programmer chooses to write, and—most critically—by trust.That trust is the exploit developer's currency.Consider the strcpy function. It copies bytes from one memory location to another until it encounters a zero byte (the null terminator). The function has no idea how large the destination buffer is. It assumes—trusts—that the programmer has allocated enough space. When that trust is misplaced, bytes keep copying past the end of the buffer, overwriting whatever memory happens to be adjacent. This is not a bug in strcpy; it is a feature of C. The language prioritizes speed and flexibility over safety. Every C programmer knows they should use strncpy or memcpy with explicit length checks. But developers are human. Humans make mistakes. And a single forgotten bounds check can be enough to turn a trusted application into an attacker's entry point.This is why the C language has been called "the mother of all vulnerabilities." According to industry data, memory corruption bugs—buffer overflows, use-after-free errors, format string vulnerabilities—consistently account for 60-70% of all critical-severity CVEs. The 2023 CWE Top 25 Most Dangerous Software Weaknesses lists Out-of-bounds Write (CWE-787) as number one. Use After Free (CWE-416) is number three. These are not obscure edge cases; they are the daily bread of every exploit developer.But here is the truth that separates exploit developers from penetration testers and bug hunters: you cannot exploit what you cannot see. You cannot corrupt what you do not understand. Every book, every course, every tutorial will tell you that buffer overflows overwrite return addresses. Few will show you what that actually looks like in the CPU registers. Fewer still will make you watch it happen, instruction by instruction, address by address.That changes now.1.2 The x86_64 Register Set: Your New Best Friends Before you can control a program, you need to understand what the program uses to control itself. The CPU has a small number of extremely fast storage locations called registers. These are not memory—they live directly on the processor die and can be accessed in a single clock cycle. When a program does anything useful, it moves data between registers and main memory, performs arithmetic on register values, and uses registers to track its own execution state.For exploit development, you care about a subset of the x86_64 register set. Learn these. Internalize them. They will become as familiar to you as your own home address.The General Purpose Registers The x86_64 architecture provides sixteen general-purpose registers, each 64 bits wide. Their names—rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, and r8 through r15—are historical artifacts, but the convention matters because you will see them in every disassembler and debugger.rax (accumulator register): Often holds the return value of a function. When main() returns 0, that 0 lives in rax.rdi, rsi, rdx, rcx, r8, r9: Used to pass arguments to functions. The first argument goes in rdi, the second in rsi, the third in rdx, and so on. When you see a call to printf("%s", buffer), the format string pointer will be in rdi and the buffer pointer in rsi.rbp (base pointer): Used to reference local variables and function arguments on the stack. In many compiled binaries (especially those with frame pointers enabled), rbp points to a fixed location within the current stack frame.rsp (stack pointer): Points to the top of the stack. As you push data onto the stack, rsp decreases (the stack grows downward in memory). As you pop data, rsp increases. This register is so critical that corrupting it usually crashes the program immediately.The Instruction Pointer: Your Final Target The most important register for exploit development is the one you cannot directly write: rip, the instruction pointer. (On 32-bit x86 systems, this is called eip; on 16-bit, ip. Throughout this book, we use the 64-bit nomenclature.)rip contains the memory address of the next instruction the CPU will execute. The CPU fetches the bytes at that address, decodes them into an instruction, executes that instruction, and then advances rip to the next address. This happens billions of times per second. Control flow—the sequence of instructions a program follows—is just the evolution of rip over time.When you overwrite a return address on the stack, you are changing where the CPU will go when the current function finishes. When you hijack a function…

This is the end of the free sample. Get the eBook to keep going. Buy now

About this book

A Coursebook on Exploit Developer

Details

Author
Zeller Evelin
Publisher
SamEnrico
Language
English
Genre
Non-Fiction, Informative, Educational
Released
2026-05-18
Pages (approx.)
143
Available as
eBook, Audiobook

Read better in the ZLOADR app

Your eBooks on your phone or tablet. Sign in with your SamEnrico account and start reading.

More by Zeller Evelin

See all