NX-DEP (No-eXecute)
- •
What it is
- •
NX/DEP prevents instruction execution from pages without execute permission. It does not itself forbid a page from being both writable and executable; that is the separate W^X policy.
- •
- •
- •
When to use it
- •
An NX-protected stack blocks code execution there; inspect mappings before choosing Shellcode or existing-code reuse such as ROP Chain.
- •
A challenge may explicitly allocate an RWX input buffer even when other mappings are non-executable.
- •
An executable stack permits stack-resident shellcode; it says nothing about the permissions of other regions.
- •
- •
Examples
- •
Shellcode on an
rw-stack faults when executed. An explicitly mappedrwxchallenge buffer permits execution.
- •
- •
pwntools
- •
elf = ELF('./vuln') print(elf.nx)
- •
- •
Debugging
- •
checksec vmmap # inspect per-page R/W/X permissions
- •
- •
Protections and bypasses
- •
mprotectat runtime can flip a writable page to executable — usually reached via a ROP chain, since you need to call it before NX blocks you. - •
JIT-generated code is executable, but modern JITs can switch page permissions instead of keeping pages RWX. Writable-and-executable memory is not inherently required.
- •
- •
- •