Reading the Example
- Position-independent: the path is built on the stack at runtime and referenced through
RSP— no fixed address. - Null-free-friendly:
xorzeros registers, andmov al, 59avoids a zero-padded immediate. - Why push a NULL first:
execveneeds a null-terminated path string in memory. - Little-endian: bytes for
"/bin/sh"are stored reversed, which is why the constant looks scrambled.
Key Takeaway
Every design choice in real shellcode traces back to two constraints: run anywhere, contain no forbidden bytes.