January 03, 2017

pwnable.kr fd solution



ENGLISH>
Connect to the pwnable.kr server with 2222 port and enter id as fd and pw as guest.

The first time you connect, there are fd, fd.c, and flag files in your home directory. In particular, the fd file has sticky-bit permission.

Somehow, the result of compiling the fd.c seems to be the fd file, and the fd seems to be related to the flag file.


한글>
엄마! 리눅스에서 파일 디스크립터란 뭔가요?

* 스스로 워게임을 플레이 해보세요. 그러나 진짜 처음이라면 다음의 튜토리얼 링크를 참고하기 바랍니다.

ssh fd@pwnable.kr -p 2222 (pw:guest)
→ port 2222번으로 pwnable.kr 서버로 접속하며 id는 fd, pw는 guest이다.


처음 접속하면 홈 디렉터리에 fd, fd.c, flag 파일이 있다. 특히 fd 파일은 sticky-bit가 설정되어 있다.

왠지 fd.c를 컴파일한 결과가 fd일 것 같으며, fd는 flag와 연관이 있을 것 같다.




ENGLISH>
The contents of the fd.c file are the same as the above image. The atoi function is a function that returns the input string as a integer value. The source code subtracts the value of 0x1234 from the atoi result.

If you set the value of the fd variable to 0(=default input), the value you entered in the read() function is stored in the buf variable.

한글>
fd.c 파일의 내용은 위 이미지와 같다. atoi함수는 입력받은 문자열을 숫자로 반환하여 주는 함수이다. 소스코드에서는 atoi 결과에서 0x1234의 값을 뺀다.

fd 변수의 값을 0(=default input)으로 설정하면, read() 함수에서 우리가 입력한 값이 buf 변수에 저장된다.




ENGLISH>
The value of 0x1234 is 4660 in decimal. When you enter the 4660, the fd variable value becomes 0, and the additional input value is stored in the buf variable.

Enter "LETMEWIN" to get the correct answer.


한글>
0x1234의 값은 10진수로 4660이다. 우리가 4660값을 입력하면 fd 변수 값이 0이 되며, 추가로 입력된 값은 buf 변수로 저장된다.

"LETMEWIN"을 입력하여 정답을 획득한다.