• Home
  • Posts
  • Categories
  • GitHub
  • Email
© 2025 sk8thing.dev

Hack The Box - Sea writeup

23 December 2024
2 min read
CTF WriteupHack The BoxMachineLinux

Nmap scan

...
PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 63 OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 e3:54:e0:72:20:3c:01:42:93:d1:66:9d:90:0c:ab:e8 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCZDkHH698ON6uxM3eFCVttoRXc1PMUSj8hDaiwlDlii0p8K8+6UOqhJno4Iti+VlIcHEc2THRsyhFdWAygICYaNoPsJ0nhkZsLkFyu/lmW7frIwINgdNXJOLnVSMWEdBWvVU7owy+9jpdm4AHAj6mu8vcPiuJ39YwBInzuCEhbNPncrgvXB1J4dEsQQAO4+KVH+QZ5ZCVm1pjXTjsFcStBtakBMykgReUX9GQJ9Y2D2XcqVyLPxrT98rYy+n5fV5OE7+J9aiUHccdZVngsGC1CXbbCT2jBRByxEMn+Hl+GI/r6Wi0IEbSY4mdesq8IHBmzw1T24A74SLrPYS9UDGSxEdB5rU6P3t91rOR3CvWQ1pdCZwkwC4S+kT35v32L8TH08Sw4Iiq806D6L2sUNORrhKBa5jQ7kGsjygTf0uahQ+g9GNTFkjLspjtTlZbJZCWsz2v0hG+fzDfKEpfC55/FhD5EDbwGKRfuL/YnZUPzywsheq1H7F0xTRTdr4w0At8=
|   256 f3:24:4b:08:aa:51:9d:56:15:3d:67:56:74:7c:20:38 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMMoxImb/cXq07mVspMdCWkVQUTq96f6rKz6j5qFBfFnBkdjc07QzVuwhYZ61PX1Dm/PsAKW0VJfw/mctYsMwjM=
|   256 30:b1:05:c6:41:50:ff:22:a3:7f:41:06:0e:67:fd:50 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHuXW9Vi0myIh6MhZ28W8FeJo0FRKNduQvcSzUAkWw7z
80/tcp open  http    syn-ack ttl 63 Apache httpd 2.4.41 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Sea - Home
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
...

There are only two open ports: HTTP and SSH.

Port 80

While exploring the page, the only noteworthy thing I found was a contact form, which appeared to be a promising lead.

HTB Sea main page

HTB Sea main page

HTB Sea contact form

HTB Sea contact form

Directory discovery

I began scanning for directories using gobuster and after a little bit of searching I discovered several interesting files in the /themes/bike directory.

HTB Sea GoBuster index

HTB Sea GoBuster index

HTB Sea GoBuster themes bike

HTB Sea GoBuster themes bike

The README.md file indicates that the application is using WonderCMS, and the /version endpoint reveals that the version in use is 3.2.0. I then searched online for known vulnerabilities in this version and discovered CVE-2023-41425.

User flag

After successfully exploiting the vulnerability, I gained a shell as www-data. I then uploaded linpeas and discovered a particularly interesting file, database.js, which contained a hash.

HTB Sea form reverse shell

HTB Sea form reverse shell

HTB Sea database.js

HTB Sea database.js

I spent some time trying to identify the hash, as it contained escape characters that initially threw me off. After realizing it was a bcrypt hash, I attempted to crack it using john.

HTB Sea john

HTB Sea john

After successfully cracking the hash, I reviewed the linpeas results for available users. I then attempted to log in as geo and amay using the cracked password. The password worked for amay, and I was able to claim the user flag.

HTB Sea user flag

HTB Sea user flag

Root flag

Upon further inspecting the linpeas logs, I discovered an application running on port 8080 internally. I set up an SSH tunnel to access it and found a system monitoring page.

HTB Sea internal ports

HTB Sea internal ports

HTB Sea system monitor

HTB Sea system monitor

I inspected the traffic using Burp Suite and modified the log_file parameter. It appeared that this parameter was an argument for the cat command.

HTB Sea form first attempt

HTB Sea form first attempt

The application detected suspicious commands, so I spent some time searching for a way to bypass this restriction. I noticed that although an error message for suspicious commands was displayed, the commands were still executed by the server. I managed to escalate my privileges by granting amay full sudo access through the sudoers file and finally printed the root flag.

HTB Sea form root flag

HTB Sea form root flag