March 25, 2017

pwnable.kr mistake solution


We all make mistakes. let's move on.
(don't take this too seriously, no fancy hacking skill is required at all)
우리는 모두 실수를 합니다. 어디 해봅시다.
(너무 심각하게 생각하지 마세요. 특별한 해킹 스킬이 필요한 것은 아닙니다.)

This task is based on real event
Thanks to dhmonkey
이 과제는 실시간 이벤트에 기반하고 있습니다.
dhmonkey 님에게 감사의 말씀을 드립니다.





You can check the above code by opening mistake.c file.
mistake.c 파일을 열면 위 코드를 확인할 수 있다.

If pw_buf and pw_buf2 are the same, the program reads the flag file with the privilege of mistake_pwn.
pw_buf와 pw_buf2가 동일하면, mistake_pwn의 권한으로, flag 파일을 읽는 프로그램이다.

The first box above has the same meaning as fd=(open()<0) by operator precedence. The result of oepn<0 is 0(=false), so the fd contains 0(=StdInput). Finally, the value input by the keyboard enters pw_buf.
위에서 첫 번째 네모는 연산자 우선순위에 의해 fd=(open()<0)와 같은 의미이다. oepn<0의 결과는 0(=false)이므로 fd에는 0(=StdInput)이 들어간다. 결국 키보드로 입력된 값이 pw_buf에 들어간다.

The value input by scanf enters pw_buf2
pw_buf2는 scanf에 의해 입력된 값이 들어간다. 

Before the two values are compared, pw_buf2 goes through the xor() function, which performs an XOR 1 operation on each position of the input value.
두 값이 비교되기 전에 pw_buf2는 xor() 함수를 거치게 되는데, 이 함수는 입력된 값의 각 자리에 XOR 1 연산을 수행한다. 






You should input 10 arbitrary values and 10 xor() value of the arbitrary value(If you want to input a character like the first line, you have to input it as ASCII code.).
임의의 값 10개, 그 임의의 값에 xor 연산의 결과 값 10개를 넣으면 된다(첫 번째 라인처럼 문자를 입력하려면 아스키 코드로 입력해야 한다.).