小编use*_*094的帖子

是否可以使函数从堆栈中的字符串执行代码?

#include <stdio.h>

int main(int argc, char** argv)
{
    void (*p) (void);
    /* this obviously won't work, but what string could I put in 
       here (if anything) to make this execute something meaningful?
       Does any OS allow instructions to be read from
       the stack rather than text area of the process image? */
    char *c = "void f() { printf(\"Hello, world!\"); }";
    p = ( void (*)() )c;
    p();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c shellcode

9
推荐指数
3
解决办法
4843
查看次数

标签 统计

c ×1

shellcode ×1