<문제>
Baby's first reversing, I think. Get it to terminate with exit 0 with an input matching the flag format (WPI{foo bar baz})
<풀이>
file mhm 명령어 이용하면 python 3.8 byte-compiled 라고 한다.
https://shwoghk14.blogspot.com/2020/05/forensics-pyc-py.html
Forensics .pyc 파일 .py로 복구하기
별빛 연구소(StarLight Lab)
shwoghk14.blogspot.com
인터넷으로 검색해보니 디코딩 툴이 있어 확장자 .pyc 붙여주고 툴 이용해 python 파일로 변환하고 내용 확인
uncompyle6 mhm.pyc
# uncompyle6 version 3.7.4
# Python bytecode 3.8 (3413)
# Decompiled from: Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: uhhhhhhh.py
# Compiled at: 2021-03-05 00:04:38
# Size of source mod 2**32: 1222 bytes
def __main__(inp):
i = -4
for c in inp:
if i == 4:
if c != ' ':
exit(82)
else:
if i == -4:
if c != 'W':
exit(133)
else:
if i == -2:
if c != 'I':
exit(42069)
elif i == -1 and c != '{':
exit(11037)
if i == 10:
if c != '}':
exit(9001)
else:
if i == 1:
if c != '@':
exit(11037)
if i == 2 and c != '5':
exit(11037)
if i == 7 and c != 'P':
exit(11037)
if i == 3:
if c != 'E':
exit(11037)
else:
if i == 0:
if c != 'h':
exit(82)
if i == 5 and c != 'h':
exit(11037)
if i == -3 and c != 'P':
exit(133)
if i == 9:
if c != '!':
exit(133)
else:
if i == 6:
if c != '0':
exit(133)
if i == 8 and c != '3':
exit(133)
i += 1
else:
print(':)')
__main__(input('hi'))
# okay decompiling mhm.pyc
WPICTF의 플래스 형식은 WPI{}
첫번째 문자인 W는 i가 -4자리에 있는지 확인하는 과정을 거치니까 차례대로 문자 조합해보면
FLAG : WPI{h@5E h0P3!}
'CTF > Reversing' 카테고리의 다른 글
[UMassCTF]easteregg (0) | 2021.03.31 |
---|---|
[hackCTF] Welcome_REV (0) | 2021.02.07 |
[hackCTF] Reversing Me (0) | 2021.01.31 |
[picoCTF] droids2 (0) | 2021.01.20 |
[picoCTF] droids1 (0) | 2021.01.20 |