开发者

Exercise about stack overflow

I'm trying to learn stack overflows but I have a problem with an exercise. In the vulnerable program the part of the code that must receive my shellcode is:

开发者_C百科
 int array[8];
 index = (int) strtol(argv[1], NULL, 10);
 value = (int) strtoul(argv[2], NULL, 16);
 array[index] = value;

I found easily the index of the array to use to overwrite RET. Then I tried to find the offset of the return address in the vulnerable program like this:

./victim 12 $(printf "%0512x" 0)

I tried a lot of different lengths, but at every possible length I get a segmentation fault. This is weird, because my book says that I should be able to get a segmentation fault only where the saved return address is. I'm a beginner, so probably I'm doing some basic mistake. Can anyone help me to solve this problem? Thanks in advance for any help.


You are getting a segmentation fault because you're only providing your program with a single argument, but yet you're calling strtoul on argv[2], which is a NULL pointer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜