Before exploiting a pwn challenge, you need to know what defenses you're up against. checksec reads an ELF binary's headers and reports which protections it was compiled with. It ships with pwntools (pwn checksec) and as a standalone script.
Running it
$ pwn checksec ./vuln
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x400000)
Each line rules a family of techniques in or out.
Stack canary
A canary is a random value placed between local buffers and the saved return address, checked before the function returns. If an overflow changes it, the program aborts with *** stack smashing detected ***. No canary means a plain stack overflow can reach the return address. With a canary, you first need to leak it — a format string bug is a common way.
NX (non-executable stack)
With NX enabled, the stack and heap can't be executed, so injecting shellcode into a buffer and jumping to it fails. You reuse code that's already in the binary or libc instead — return-to-win functions, ret2libc, or a ROP chain. NX disabled makes classic shellcode injection possible.
PIE (position-independent executable)
A PIE binary is loaded at a random base address each run, so the addresses of its functions and gadgets change. No PIE means addresses are fixed (often starting at 0x400000) and you can hard-code them in your exploit. With PIE, you need to leak one address from the binary and compute the base from it.
RELRO
RELRO controls whether the Global Offset Table (GOT) — the table of resolved library function addresses — is writable. Partial RELRO leaves it writable, so overwriting a GOT entry (for example, replacing puts with system) is an option. Full RELRO makes it read-only after startup.
Putting it together
- No canary + No PIE → overflow straight to a fixed address; the classic beginner setup
- NX enabled → no shellcode; use existing code (ret2win, ret2libc, ROP)
- PIE or canary present → you'll need an information leak first
- Partial RELRO → GOT overwrites are on the table
Remember that ASLR on the system also randomizes libc and the stack regardless of PIE. Run checksec first on every pwn challenge — it takes a second and tells you which of our guides, from basic buffer overflows to ROP, applies.