SSRC:
/* stack1.c *SỞ dòng char buf[8]; cho thấy mảng buf chỉ có thể chứa tối đa là 8 ký tự
* specially crafted to feed your brain by gera */
#include <stdio.h>
int main() {
int cookie = 0x1337;
char buf[8];
printf("buf: %08x cookie: %08x\n", &buf, &cookie);
fflush(stdout);
fgets(buf,13,stdin);
fflush(stdout);
printf("cookie value: %.8x\n",cookie);
if (cookie == 0x41424344)
printf("HERE IS YOUR FLAG: xxxxxxxxxxxxxxxxxxxxxxxxx\n");
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxx is censored, it is not real-flag, you must pwn on remote host to get real-flag :)
Mà dòng fgets lại cho phép đầu vào lên tới 13 kí tự
==> bị BOF ở mảng buf sẽ bị tràn lên biến cookie (vì stack là đi lên :D)
0x41 là kí tự A
0x42 là kí tự B
0x43 là kí tự C
0x44 là kí tự D
Vậy ta phải input 8 kí tự cho biến buf và 4 kí tự "DCBA" để tràn lên biến cookie :D

0 nhận xét:
Đăng nhận xét