
Level19
level19의 계정으로 접속한 후, hint를 확인해보면 다음과 같습니다.

입력받는 문자열의 길이를 체크하지 않는 gets함수이기 때문에, BOF취약점이 존재합니다. 코드 분석을위해 gdb를 이용하였습니다.

메모리 공간으로 할당된 크기는 40byte입니다. 만약 이 정보들을 가지고 BOF공격을 시도하게 되면, level20의 권한이 아닌 level19의 권한으로 shell이 실행됩니다.
level20권한의 shell을 실행시키기 위해 setreuid(3100,3100)과 system("/bin/sh")를 실행시킬 것입니다.이를 위해 Chaining RTL을 이용하였습니다. Chaining RTL을 위해 스택을 도식화해보면 다음과 같습니다.

먼저 setreuid() 와 system()의 주소를 찾았습니다.

pop -pop - ret 을 찾기 위해 다음과 같이 objdump를 이용하였습니다.

마지막으로 /bin/sh의 주소를 이용하기 위해 level11에서 사용했던 코드를 이용했습니다.

위 코드를 컴파일한 후, 실행하면 다음과 같이 /bin/sh가 위치한 주소를 알 수 있습니다.

필요한 값들을 모두 알았으니, 위에 도식화한 그림순으로 값을 대입하여 payload를 구성하여 입력하였습니다.

No comments:
Post a Comment