IT 그리고 정보보안/Write-up
Pwnable.kr - fd
plummmm
2021. 4. 12. 19:21
반응형
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char buf[32];
int main(int argc, char* argv[], char* envp[]){
if(argc<2){
printf("pass argv[1] a number\n");
return 0;
}
int fd = atoi( argv[1] ) - 0x1234;
int len = 0;
len = read(fd, buf, 32);
if(!strcmp("LETMEWIN\n", buf)){
printf("good job :)\n");
system("/bin/cat flag");
exit(0);
}
printf("learn about Linux file IO\n");
return 0;
}
fd.c 라고 소스코드가 있네. 함 봅시다.
문제 이름이 fd 인것을 보아 파일 디스크립터에 관련된 문제인 것 같다.
프로그램 인자로 파일 디스크립터 값을 조정할 수 있다.
그냥 딱히 생각 나는 것이 표준 출력으로 fd를 바꾸어
거기다가 if문 조건에 부합하는 LETMEWIN 을 치면 될 것 같네.
fd@ubuntu:~$ ./fd 4661
LETMEWIN
good job :)
mommy! I think I know what a file descriptor is!!
반응형