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发现有fd fd.c flag三个文件
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是文件描述符,查阅资料发现fd为0,1,2分别代表stdin,stdout,stderr,所以本题需要让fd为0,然后输入LETMEWIN就可以通过if判断,得到flag了,atoi函数是将字符串转换为整数的,0x1234的十进制为4660,那么参数为4660,运行./fd 4660然后输入LETMEWIN,即可得到flag。