1. Process Virtual Memory Architecture
When an executable binary (e.g., a Windows Portable Executable .exe or Linux ELF) is loaded into memory, the operating system creates an isolated virtual address space.
In 32-bit x86 systems, this virtual address space spans 2^{32} bytes (4 GB), ranging from 0x00000000 to 0xFFFFFFFF:
High Memory Addresses (0xFFFFFFFF)
+-------------------------------------------------------------+
| Kernel Space (Operating System Drivers & Core Subsystems) |
+-------------------------------------------------------------+
| User Space Stack (Grows DOWNWARD towards low memory \/) |
| [ Local Variables | Saved EBP | Saved EIP Return Address ] |
+-------------------------------------------------------------+
| | |
| v |
| Unallocated Memory |
| ^ |
| | |
+-------------------------------------------------------------+
| Heap (Grows UPWARD /\ - Dynamic allocations: malloc / new) |
+-------------------------------------------------------------+
| .bss Segment (Uninitialized Global / Static Variables) |
+-------------------------------------------------------------+
| .data Segment (Initialized Global / Static Variables) |
+-------------------------------------------------------------+
| .text Segment (Compiled Machine Code Assembly Instructions) |
+-------------------------------------------------------------+
Low Memory Addresses (0x00000000)2. Intel x86 CPU Register Hierarchy
Registers are microscopic, ultra-high-speed memory cells positioned directly on the CPU die:
x86 Register Architecture Matrix:
| Register Name | Functional Purpose | Role in Exploit Engineering |
|---|---|---|
| EAX | Accumulator Register | Holds function return values and arithmetic results |
| EBX | Base Register | Pointer to data in the DS segment; general storage |
| ECX | Counter Register | Loop iteration counter and string operation counter |
| EDX | Data Register | I/O pointer and arithmetic overflow operations |
| ESP | Extended Stack Pointer | Critical: Points directly to the current top of the stack |
| EBP | Extended Base Pointer | Critical: Anchors the base frame for local function variables |
| EIP | Extended Instruction Pointer | Holy Grail: Points to the next instruction to execute! |
3. Little-Endian Byte Ordering
Intel x86 microprocessors store multi-byte data words in memory using Little-Endian format: the least significant byte (LSB) is stored at the lowest memory address:
Memory Address: 0x0012FF40 0x0012FF41 0x0012FF42 0x0012FF43
Memory Bytes: [ 78 ] [ 56 ] [ 34 ] [ 12 ]
Interpreted 32-bit Value: 0x12345678When constructing exploit payloads targeting a specific memory address (e.g., targeting a JMP ESP instruction located at 0x625011AF), the payload in Python must reverse the byte order: b"\xaf\x11\x50\x62"!