October 2018
Beginner
794 pages
19h 23m
English
We write a simple C program (ch7/query_creds.c); when run, it prints to stdout its process credentials (we show the relevant code):
#define SHOW_CREDS() do { \ printf("RUID=%d EUID=%d\n" \ "RGID=%d EGID=%d\n", \ getuid(), geteuid(), \ getgid(), getegid()); \} while (0)int main(int argc, char **argv){ SHOW_CREDS(); if (geteuid() == 0) { printf("%s now effectively running as root! ...\n", argv[0]); sleep(1); } exit (EXIT_SUCCESS);}
Build it and try it out:
$ ./query_credsRUID=1000 EUID=1000RGID=1000 EGID=1000$ sudo ./query_creds[sudo] password for seawolf: xxx RUID=0 EUID=0RGID=0 EGID=0./query_creds now effectively running as root! ...$
Note the following:
Read now
Unlock full access