Rotiple

fd

WarGame/Pwnable2015. 6. 25. 13:21

fd@ubuntu:~$ cat fd.c

#include 
#include 
#include 
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;

}



read함수의 첫번째 인자인 fd 값이 0이면 일반 입력을 받는다 .
read(0, buf, 32) 가 된다면 32바이트를 buf에 일반 입력을 받게 된다 .
그렇게 되려면 인자 argv[1] 이 0x1234(4660) 가 되야하며 buf의 값은 LETMEIN이 되야한다.



fd@ubuntu:~$ ./fd 4660
LETMEWIN  
good job :)
mommy! I think I know what a file descriptor is!!

'WarGame > Pwnable' 카테고리의 다른 글

shellshock  (0) 2015.07.06
mistake  (0) 2015.07.06
random  (0) 2015.07.06
passcode  (0) 2015.06.25
collision  (0) 2015.06.25