Skip to main content

Posts

Showing posts with the label Absolutely relative

picoCTF2018 Miscellaneous Absolutely-relative

picoCTF2018 Miscellaneous Absolutely-relative Objective: In a filesystem, everything is relative ¯\_(ツ)_/¯. Can you find a way to get a flag from this program [1] ? You can find it in /problems/absolutely-relative_2_69862edfe341b57b6ed2c62c7107daee on the shell server. Source [2] . Here is the program we need to retrieve the flag #include <stdio.h> #include <string.h> #define yes_len 3 const char *yes = "yes"; int main() {     char flag[99];     char permission[10];     int i;     FILE * file;     file = fopen("/problems/absolutely-relative_2_69862edfe341b57b6ed2c62c7107daee/flag.txt" , "r");     if (file) {      while (fscanf(file, "%s", flag)!=EOF)      fclose(file);     }     file = fopen( "./permission.txt" , "r");     if (file) {      for (i = 0; i < 5; i++){             fscanf(file, "%s", permission);         }         permission[5] = '\0';         fcl