Overwriting a GOT Entry
- If you have a write primitive (buffer overflow into a data pointer, format-string
%n, arbitrary write bug), the GOT is a prime target because it is writable under partial RELRO. - Idea: overwrite the GOT entry of a function the program is about to call with the address of code you want to run:
GOT[printf] = &system— then the nextprintf("/bin/sh")actually callssystem("/bin/sh").GOT[some_func] = one_gadget— a single libc address that callsexecve("/bin/sh", ...)when constraints hold.- This turns a benign, attacker-influenced call into arbitrary code execution — no shellcode, no stack execution needed.
Key Takeaway
GOT overwrite converts a write primitive into a control-flow primitive.