2022-02-05 19:00:25 -05:00
|
|
|
#include <stdio.h>
|
2022-02-06 14:15:57 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
2022-02-14 17:45:07 -05:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
char* buf = "A string";
|
2022-02-05 19:00:25 -05:00
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]){
|
|
|
|
|
printf("Hello world from execve hijacker\n");
|
2022-02-14 17:45:07 -05:00
|
|
|
|
|
|
|
|
time_t rawtime;
|
|
|
|
|
struct tm * timeinfo;
|
|
|
|
|
|
|
|
|
|
time ( &rawtime );
|
|
|
|
|
timeinfo = localtime ( &rawtime );
|
|
|
|
|
char* timestr = asctime(timeinfo);
|
|
|
|
|
|
2022-02-05 19:00:25 -05:00
|
|
|
for(int ii=0; ii<argc; ii++){
|
|
|
|
|
printf("Argument %i is %s\n", ii, argv[ii]);
|
|
|
|
|
}
|
2022-02-06 14:15:57 -05:00
|
|
|
|
2022-02-14 17:45:07 -05:00
|
|
|
int fd = open("/tmp/execve_hijack", O_RDWR | O_CREAT | O_TRUNC, 0666);
|
2022-02-06 14:15:57 -05:00
|
|
|
|
|
|
|
|
int ii = 0;
|
2022-02-14 17:45:07 -05:00
|
|
|
while(*(timestr+ii)!='\0'){
|
|
|
|
|
write(fd, timestr+ii, 1);
|
|
|
|
|
ii++;
|
|
|
|
|
}
|
|
|
|
|
write(fd, "\t", 1);
|
|
|
|
|
|
|
|
|
|
ii = 0;
|
2022-02-06 14:15:57 -05:00
|
|
|
while(*(argv[0]+ii)!='\0'){
|
|
|
|
|
write(fd, argv[0]+ii, 1);
|
|
|
|
|
ii++;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-14 17:45:07 -05:00
|
|
|
write(fd, "\n", 1);
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
2022-02-05 19:00:25 -05:00
|
|
|
return 0;
|
|
|
|
|
}
|