> For the complete documentation index, see [llms.txt](https://xenon-cyber-docs.gitbook.io/ctf-checklist/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xenon-cyber-docs.gitbook.io/ctf-checklist/binary-exploitation/stack/stack-pivoting.md).

# Stack Pivoting

Stacking pivoting is a technique to use when you don't have enough stack space to perform normal ROP activities

For example:

```c
char buf[64];

read(0,buf,72);
```

This only allows you to write 8 extra bytes after filling up the buffer which means there isn't enough to do a full ROP, meaning that you have to pivot through the stack to allow you to write more.

One of the ways this can be done is through a `sub rsp; #; ret;`

This subtracts the `rsp` back so you have more area to write in the stack meaning you can write your full ROP chain.
