메모장 입니다2

picoctf 2017] just no 본문

Study/시스템

picoctf 2017] just no

Wooum@n 2018. 4. 9. 00:54

1.문제


A program at /problems/f6ae7c5798439ab46292af914f47b170 has access to a flag but refuses to share it. Can you convince it otherwise?




//justno.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, char **argv){
FILE* authf = fopen("../../problems/f6ae7c5798439ab46292af914f47b1
70/auth","r"); //access auth file in ../../../problems/f6ae7c5798439
ab46292af914f47b170
if(authf == NULL){
printf("could not find auth file in ../../problems/f6ae7c5798439
ab46292af914f47b170/\n");
return 0;
}
char auth[8];
fgets(auth,8,authf);
fclose(authf);
if(strcmp(auth,"no")!=0){
FILE* flagf;
flagf = fopen("/problems/f6ae7c5798439ab46292af914f47b170/flag",
"r");
char flag[64];
fgets(flag,64,flagf);
printf("Oh. Well the auth file doesn't say no anymore so... Here
's the flag: %s",flag);
fclose(flagf);
}else{
printf("auth file says no. So no. Just... no.\n");
}
return 0;





//auth

woounnan@shell-web:/problems/f6ae7c5798439ab46292af914f47b170$ ls
auth flag justno justno.c




*문제내용

auth에 no가 저장되어있는데

justno가 auth를 읽어서 확인했을 때 no가 아니어야 플래그를 출력해줌.







2.알게된 것


 -리눅스 fopen의 경로기준은 파일을 실행했을 때 실행한 사람의 현재위치가 기준이다.

(실행자가 /tmp/test 면 이 위치를 기준으로 상대경로가 적용됨)



'Study > 시스템' 카테고리의 다른 글

Linux] picoctf 2017 - Flagsay 1  (0) 2018.04.10
Linux] picoctf 2017 - Ive Got A Secret  (0) 2018.04.10
Immunity Debugger] PyCommand 사용법  (0) 2018.03.30
Windows] BOF  (0) 2018.03.30
windows] 쉘코드 작성  (0) 2018.03.29