is it possible to make a function execute code from a string on the stack?

前端 未结 3 1516
感情败类
感情败类 2021-01-04 21:01
#include 

int main(int argc, char** argv)
{
    void (*p) (void);
    /* this obviously won\'t work, but what string could I put in 
       here (if          


        
3条回答
  •  没有蜡笔的小新
    2021-01-04 21:44

    Sort of, but not really, there is no eval() in c, like in many scripting languages.

    However, what you are describing is sort of like a Buffer Overflow exploit.

    Where, you use a string to write "code" (not c syntax, but machine code) into the address space after the buffer. Here's a nice little tutorial of the topic.

    Don't use this information to write a virus :(

提交回复
热议问题