相关疑难解决方法(0)

从C程序加载原始代码

我正在编写一个程序来加载和执行文件中的代码.但是我遇到了一个问题:"写"系统调用不起作用.代码成功加载并执行,但不在屏幕上显示任何文本.

加载代码的程序:

#include < stdio.h >
#include < stdlib.h >

int main(int argc,char* argv[])
{
    unsigned int f_size = 0;
    unsigned char* code_buf = NULL;
    void (*func_call)(void) = NULL;

    if(argc < 2) 
    {
        printf("Usage: %s <FILE>\n",argv[0]);
        return 1;
    }

    FILE* fp = fopen(argv[1],"rb");
    if(!fp)
    {
        printf("Error while opening this file: %s\n",argv[1]);
        return 1;
    }

    unsigned int fsize = 0;
    fseek(fp,0,SEEK_END);
    fsize = ftell(fp);
    fseek(fp,0,SEEK_SET);
    if(fsize < 4)
    {
        printf("Code size must be > 4 bytes\n");
        return 1;
    }

    code_buf = …
Run Code Online (Sandbox Code Playgroud)

c linux assembly system-calls shellcode

11
推荐指数
1
解决办法
1440
查看次数

标签 统计

assembly ×1

c ×1

linux ×1

shellcode ×1

system-calls ×1