Ret2plt
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
The goal of this technique would be to leak an address from a function from the PLT to be able to bypass ASLR. This is because if, for example, you leak the address of the function puts
from the libc, you can then calculate where is the base of libc
and calculate offsets to access other functions such as system
.
This can be done with a pwntools
payload such as (from here):
Note how puts
(using the address from the PLT) is called with the address of puts
located in the GOT (Global Offset Table). This is because by the time puts
prints the GOT entry of puts, this entry will contain the exact address of puts
in memory.
Also note how the address of main
is used in the exploit so when puts
ends its execution, the binary calls main
again instead of exiting (so the leaked address will continue to be valid).
Note how in order for this to work the binary cannot be compiled with PIE or you must have found a leak to bypass PIE in order to know the address of the PLT, GOT and main. Otherwise, you need to bypass PIE first.
You can find a full example of this bypass here. This was the final exploit from that example:
https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html
64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call system('/bin/sh')
https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html
64 bits, ASLR enabled, no canary, stack overflow in main from a child function. ROP gadget to call puts to leak the address of puts from the GOT and then call an one gadget.
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)