0x01 fd
題目描述:
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://www.youtube.com/watch?v=blAxTfcW9VU
ssh fd@pwnable.kr -p2222 (pw:guest)
解題思路:
ssh連接上去后ls發(fā)現(xiàn)有fd fd.c flag三個(gè)文件
cat 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,fd是文件描述符,查閱資料發(fā)現(xiàn)fd為0,1,2分別代表stdin,stdout,stderr,所以本題需要讓fd為0,然后輸入LETMEWIN就可以通過if判斷,得到flag了,atoi函數(shù)是將字符串轉(zhuǎn)換為整數(shù)的,0x1234的十進(jìn)制為4660,那么參數(shù)為4660,運(yùn)行./fd 4660然后輸入LETMEWIN,即可得到flag。