제리의 블로그

pwnable.kr fd 본문

Wargame/pwnable.kr

pwnable.kr fd

j3rrry 2018. 8. 24. 22:33

fd - 1 pt

Mommy! what is a file descriptor in Linux?

* try to play the wargame your self but if you are ABSOLUTE beginner, follow this tutorial link:
https://youtu.be/971eZhMHQQw

ssh fd@pwnable.kr -p2222 (pw:guest)

파일 디스크립터 문제입니다.

<출처: 위키피디아>

stdin 은 0, stdout 은 1, stderr 는 2 입니다. 표준 입출력이죠.




fd@ubuntu:~$ ls -l
total 16
-r-sr-x--- 1 fd_pwn fd   7322 Jun 11  2014 fd
-rw-r--r-- 1 root   root  418 Jun 11  2014 fd.c
-r--r----- 1 fd_pwn root   50 Jun 11  2014 flag




#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@ubuntu:~$ ./fd `python -c 'print 0x1234'`
LETMEWIN
good job :)
mommy! I think I know what a file descriptor is!!


'Wargame > pwnable.kr' 카테고리의 다른 글

pwnable.kr bof  (0) 2018.08.24
pwnable.kr collision  (0) 2018.08.24
pwnable.kr echo1  (0) 2018.08.22
pwnable.kr horcruxes  (1) 2018.08.20
pwnable.kr blukat  (0) 2018.08.19
Comments