Artificial

hackthebox.com - Β© HACKTHEBOX

Intro

Box Info

πŸ”— Name

🎯 Target IP

10.10.11.74

πŸ“ˆ Difficulty level

🟩Easy

🐧OS

Linux


Recon

Start Reconnaissance

Add the found values to the /etc/hosts file


Exploitation

Deserialization RCE via load_model

Critical issue:

  • Any .h5 file uploaded by a user is loaded directly

  • This TensorFlow deserialization vulnerability lets the user run arbitrary Python code as the web server user

Impact: Full remote code execution (RCE).

Browse http://artificial.htb/ and register a user

  • Download Dockerfile and move it into the artificial directory

  • Let's try the PoC locally with the provided Dockerfile

  • Should receive a shell on the nc listener

  • CTRL+C to stop

  • exploit.h5 model is generated

Upload the exploit.h5 model inside http://artificial.htb/dashboard with the registered user


Foothold

Shell as user app

Start a nc listener and click View Predictions on the uploaded model

  • Set a full interactive TTY Shell

There is secret key hardcoded in the source:

πŸ“Œ Try SSH with gael:Sup3rS3cr3tKey4rtIfici4L -> not working

Weak Password Hashing

  • Using MD5 for password hashing is insecure

  • Can be brute-forced easily

  • No salt


Lateral Movement

Dump the users.db SQLite file and crack MD5 hashes

  • Copy users.db to local KaliVM

πŸ“Œ Crack the MD5 hashes

  • Create a hashes.txt file with user:hash values

  • Run john

Shell as user gael

πŸ“Œ SSH with gael:mattp005numbertwo


Privilege Escalation

backrest_root Creds bruteforce

  • Copy backrest_backup.tar.gz to local KaliVM

  • Crack the bcrypt hash

SSH Local port forwarding

  • Create a secure tunnel between Kali local port 9898 and 127.0.0.1:9898 on the remote machine, to expose the remote Backrest API service locally

Browse to http://localhost:9898/

  • πŸ“Œ use backrest_root:!@#$%^ credentials to login

Restic server and backup exfiltration

On Kali, host a Restic Server, to receive backups over HTTP from the remote Backrest

  • In the BackrestAPI - Add a Repo

  • Test the configuration and Submit (save)

  • In the BackrestAPI - Add a Plan with the following values and Submit

  • Run the Backup Plan manually

    • This will create a snapshot on the Kali Restic Server

  • Restore the backup

Shell as root - SSH with SSH key


Post Exploitation

Why does cleanup.sh exist:

  • To remove any uploaded files, logs, or traces of exploitation

  • To restore the environment to an expected state every 10 minutes

  • To make persistent compromise harder to maintain

What to watch out for if re-exploiting:

  • Any malicious files or shells you drop will be deleted within 10 min

  • Evidence in logs or SQLite will be wiped

  • Any config changes will be overwritten


Summary

  1. Uploaded a malicious .h5 TensorFlow model to the web app.

  2. The model triggered remote code execution as the app user.

  3. Enumerated the system and dumped the SQLite database with user hashes.

  4. Cracked MD5 hashes from users.db, recovering plaintext passwords.

  5. Used the cracked credentials to SSH in as gael.

  6. Found /var/backups/backrest_backup.tar.gz owned by sysadm.

  7. Extracted it locally and discovered backrest config with a bcrypt password hash.

  8. Cracked the bcrypt hash to get backrest_root credentials.

  9. SSH-tunneled port 9898 to access the Backrest API running as root.

  10. Authenticated to the API using the cracked credentials.

  11. Set up a rest-server on Kali to receive backups.

  12. Used Backrest to backup /root to Kali machine.

  13. Restored the backup locally and retrieved root.txt.


Extra


Last updated

Was this helpful?