Core Exploit Techniques and Defensive Hooks

Buffer‑Overflow Basics

A buffer is a contiguous memory region used to store input (e.g., a string from the network). If a program writes more bytes than the buffer can hold, the excess overwrites adjacent memory (variables, saved registers, or the return address).

ConsequenceTypical exploitation goal
Corrupt local variablesCrash the program (Denial‑of‑Service)
Overwrite saved frame pointerLeak stack contents
Overwrite return addressHijack control flow → arbitrary code execution

Classic mitigation checklist:

  1. Stack canaries – a known sentinel placed before the saved return address; altered canaries abort the process.
  2. ASLR (Address Space Layout Randomisation) – randomises base addresses of stack, heap, and libraries, making gadget discovery harder.
  3. NX/DEP (No‑Execute) – marks stack/heap pages non‑executable, forcing attackers toward code‑reuse techniques (see next section).