Notice
Recent Posts
Recent Comments
Link
«   2026/03   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

Void

[pwnable.kr] fd 본문

pwnable.kr

[pwnable.kr] fd

pdw0412 2025. 1. 18. 22:07
$ ssh fd@pwnable.kr -p2222
fd@pwnable.kr's password:
 ____  __    __  ____    ____  ____   _        ___      __  _  ____
|    \|  |__|  ||    \  /    ||    \ | |      /  _]    |  |/ ]|    \
|  o  )  |  |  ||  _  ||  o  ||  o  )| |     /  [_     |  ' / |  D  )
|   _/|  |  |  ||  |  ||     ||     || |___ |    _]    |    \ |    /
|  |  |  `  '  ||  |  ||  _  ||  O  ||     ||   [_  __ |     \|    \
|  |   \      / |  |  ||  |  ||     ||     ||     ||  ||  .  ||  .  \
|__|    \_/\_/  |__|__||__|__||_____||_____||_____||__||__|\_||__|\_|

- Site admin : daehee87@khu.ac.kr
- irc.netgarage.org:6667 / #pwnable.kr
- Simply type "irssi" command to join IRC now
- files under /tmp can be erased anytime. make your directory under /tmp
- to use peda, issue `source /usr/share/peda/peda.py` in gdb terminal
You have mail.
Last login: Sat Jan 18 08:04:35 2025 from 211.105.38.94
fd@pwnable:~$ ls
fd  fd.c  flag

 

ssh fd@pwnable.kr -p2222 (pw:guest) 로 서버에 접속할 수 있다. 서버에는 바이너리와 소스코드, flag가 있다. fd.c를 확인해보자.

 

//fd.c

#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를 auto(argv[1])-0x1234로 설정하고, read()에서 fd를 파일 디스크립터로 설정한다. 표준입력 파일 디스크립터는 0이므로 우리가 값을 입력하기 위해서는 auto(argv[1])를 0x1234(4660) 으로 설정해야한다. 이후 "LETMEWIN\n"을 입력하면 flag를 얻을 수 있다.

 

 

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

 

 

mommy! I think I know what a file descriptor is!!

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

[pwnable.kr] brain fuck  (0) 2025.01.19
[pwnable.kr] flag  (0) 2025.01.19
[pwnable.kr] bof  (0) 2025.01.19
[pwnable.kr] collision  (0) 2025.01.19