ret2csu
Controlling registers when gadgets are lacking
Last updated
Was this helpful?
Controlling registers when gadgets are lacking
Last updated
Was this helpful?
ret2csu is a technique for populating registers when there is a lack of gadgets. More information can be found in the , but a summary is as follows:
When an application is dynamically compiled (compiled with libc linked to it), there is a selection of functions it contains to allow the linking. These functions contain within them a selection of gadgets that we can use to populate registers we lack gadgets for, most importantly __libc_csu_init
, which contains the following two gadgets:
The second might not look like a gadget, but if you look it calls r15 + rbx*8
. The first gadget chain allows us to control both r15
and rbx
in that series of huge pop
operations, meaning whe can control where the second gadget calls afterwards.
These gadget chains allow us, despite an apparent lack of gadgets, to populate the RDX and RSI registers (which are important for parameters) via the second gadget, then jump wherever we wish by simply controlling r15
and rbx
to workable values.
This means we can potentially pull off syscalls for execve
, or populate parameters for functions such as write()
.