I'm trying to exploit a program which has the set-guid bit enabled. The program is simple it contains the following (stage.c):
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, char **argv)
{
gid_t egid = getegid();
setregid(egid, egid);
system("cat /etc/passwd");
return 0;
}
I need to call a program called "grade" with the group of the given program. I can't create new files. What can I do?