阅读背景:

如何使用修改后的ls程序执行另一个程序?

来源:互联网 

I got a modified ls:

我有一个修改过的ls:

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

int main(int argc, char **argv){
    char command[50];
    strcpy(command,"/bin/ls ");
    gid_t egid = getegid();
    setregid(egid, egid);
    if(argc > 1) {
        if(strlen(argv[1]) > 40) {
            printf("The command you have given is too long, try again.\n");
            return 0;
        }
        strcat(command,argv[1]);
        system(command);
    }else{
        printf("This is a special NSA-modified 'ls' program. See 'man ls' for further details on how to use it.\n");
        printf("USAGE: %s [flags & files]\n",argv[0]);
    }
    return 0;
}
#include <



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: