Untitled

 avatar
unknown
plain_text
5 months ago
690 B
2
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
 #include <unistd.h>
void main()
{ int fd;
 fd = open("/etc/zzz", O_RDWR | O_APPEND);
 if (fd == -1) {
 printf("Cannot open /etc/zzz\n");
exit(0);
 }
 /* Simulate the tasks conducted by program */
 sleep(1);
 /* After the task, the root privileges are no longer
needed, so drop the root privileges permanently.*/
 setuid(getuid());
 if (fork()) { /* In the parent process */
close (fd);
exit(0);
 } else { /* in the child process */
/* Assume that the child process is compromised,
attackers have injected the following statements into
this process */
write (fd, "Malicious Data\n", 15);
close (fd);
 }
}
Editor is loading...
Leave a Comment