https://github.com/ctfs/write-ups-2016/tree/master/secuinside-ctf-quals-2016/cgc/cykor_00002-150
write up : https://ctf.rip/secuinside2016-cykor00002/
vagrant@crs:~$ ./cykor_00002 |
우선 실행하고 실행 된 내용 문자열을 기반으로 ida 분석을 진행 하도록 합시다.
int main_sub_8048F50() |
compare_key_sub_8048150() 를 확인 하면 특정 값을 맞춰야지, 통과할 수 있게 되어 있습니다.
_BOOL4 compare_key_sub_8048150() |
여기에 있는 변수를 다음과 같이 치환하여 python의 수학 라이브러리인 z3 라이브러리를 활용 하여 맞는 값을 찾습니다.
(※ z3 : https://github.com/Z3Prover/z3)
babyhack@ubuntu:~$ python scripts/mk_make.py --python --pypkgdir=/usr/lib/python2.7/dist-packages babyhack@ubuntu:~$ cd ./build/make; sudo make install |
z3가 준비 되었다면, 다음의 코드를 사용하면 됩니다.
from z3 import * |
[ result ] babyhack@ubuntu:~/tmp/Secuinside/2016$ python exp.py |
10진수로 표시 되기 때문에 문자로 표시 하는 코드를 작성 해야 한다.
[ covert ] babyhack@ubuntu:~/tmp/Secuinside/2016$ cat sort.py |
[ result ] babyhack@ubuntu:~/tmp/Secuinside/2016$ python sort.py |
이제 찾은 내용을 테스트 해 보도록 합시다.
vagrant@crs:~$ ./cykor_00002 |
CGC에 전달하는 코드 작성은 예제 코드를 기반으로 XML 작성 합니다.
<!DOCTYPE pov SYSTEM "/usr/share/cgc-docs/replay.dtd"> |
exploit 코드는 다음과 같습니다.
#!/usr/bin/python |
'Reverse > pwnable' 카테고리의 다른 글
[CGC] 공격 예제 코드 작성 - SecuInside 2016(CGC/cykor_00001) (0) | 2016.08.02 |
---|---|
[vagrant] CGC (Cyber Grand Challenge) 환경 구축 (0) | 2016.08.02 |
[pwntools] test code (0) | 2016.07.27 |
[pwntools] 함수 offset 계산 방법 (0) | 2016.07.21 |
[defcon 24 - 2016] Reversing - baby-re (0) | 2016.05.24 |