Codegate 2018 Prequal RedVelvet

개요

RedVelvet - 182pts (Rev)
Happiness:)
Solve 28

Download

이곳

(Junior 으로 참가하여서 일반부와는 문제의 점수가 다를 수 있습니다.)

풀이

이 바이너리를 가상머신에서 실행시키면 입력을 한 번 받고 바로 종료한다.

먼저, IDA 를 통해서 바이너리를 분석해보았다.

27 글자만큼의 입력을 받고, func1 ~ func15 까지 거친 후 입력값을 SHA256 해시를 한 이후, 플래그의 해시로 추정되는 s2 와 같은지 검사한다.

func 함수들 안에는 만약 플래그의 조건이 맞지 않다면 종료하는 구문이 있었기에, angr 를 사용하였다.

아래와 같은 코드를 짜고, 실행시켰다.

from angr import *

p = Project("./RedVelvet", load_options={'auto_load_libs': False})
ex = p.surveyors.Explorer(find=(0x0000000000401546, ), avoid=(0x00000000004007D0,))
ex.run()

print("\"" + ex.found[0].state.posix.dumps(0) + "\"")
print(ex.found[0].state.posix.dumps(0).encode("hex"))
'''

출력은 다음과 같이 나왔다.

What_You_Wanna_Be?:)_lc_la**\x02\x0e\x8a\x8aJ\x0e\x8a\x8a\x1a\x1a\x02\x08\x0e*JJ\x8a*\x0e\n\x8a*JJ\x02\x02J\x8a\x0b\x8a*\x08\x00

그런데 뒷부분이 조금 이상하게 나왔다.

이 바이너리에서 받는 입력은 27글자이다. 널바이트를 포함한다면, What_You_Wanna_Be?:)_lc_la 까지이다.

그래서 What_You_Wanna_Be?:)_lc_la 를 그대로 넣어봤지만 올바르지 않다고 떴고,

조금의 게싱을 동원하여 lc_lala_la 로 바꾼 후에 넣어봤더니

shgroup@ubuntu:/mnt/hgfs/Writeup/ctf/codegate/2018-Prequal/Reversing/RedVelvet$ ./RedVelvet
Your flag : What_You_Wanna_Be?:)_la_la
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
HAPPINESS:)
flag : {" What_You_Wanna_Be?:)_la_la "}

다음과 같이 맞다고 하였다.

Flag

What_You_Wanna_Be?:)_la_la

As an event approaches, it is worth considering how details related to cosplay props will affect the complete look. When comparing costume options, it is sensible to balance details related to beginner costume choices with care and storage needs. To compare practical details about details related to long cosplay wigs, women's cosplay costumes with matching accessories offers a useful starting point for practical preparation. To stay comfortable throughout the event, it is useful to check details related to Genshin Impact cosplay costumes against the wearer's own needs.