Ret2dlresolve

Basic Information

As explained in the page about GOT/PLT and Relro, binaries without Full Relro will resolve symbols (like addresses to external libraries) the first time they are used. This resolution occurs calling the function _dl_runtime_resolve.

The _dl_runtime_resolve function takes from the stack references to some structures it needs in order to resolve the specified symbol.

Therefore, it's possible to fake all these structures to make the dynamic linked resolving the requested symbol (like system function) and call it with a configured parameter (e.g. system('/bin/sh')).

Usually, all these structures are faked by making an initial ROP chain that calls read over a writable memory, then the structures and the string '/bin/sh' are passed so they are stored by read in a known location, and then the ROP chain continues by calling _dl_runtime_resolve , having it resolve the address of system in the fake structures and calling this address with the address to $'/bin/sh'.

Chek this video for a nice explanation about this technique in the second half of the video:

Or check these pages for a step-by-step explanation:

Attack Summary

  1. Write fake estructures in some place

  2. Set the first argument of system ($rdi = &'/bin/sh')

  3. Set on the stack the addresses to the structures to call _dl_runtime_resolve

  4. Call _dl_runtime_resolve

  5. system will be resolved and called with '/bin/sh' as argument

From the pwntools documentation, this is how a ret2dlresolve attack look like:

Example

Pure Pwntools

You can find an example of this technique here containing a very good explanation of the final ROP chain, but here is the final exploit used:

Raw

Other Examples & References

Last updated