Artificial

Intro
Recon
Start Reconnaissance
Add the found values to the /etc/hosts file
Exploitation
Deserialization RCE via load_model
load_modelCritical issue:
Any
.h5file uploaded by a user is loaded directlyThis 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
Dockerfileand move it into the artificial directoryLet's try the PoC locally with the provided
Dockerfile
Should receive a shell on the
nclistenerCTRL+Cto stopexploit.h5model 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.dbto local KaliVM
π Crack the MD5 hashes
Create a
hashes.txtfile withuser:hashvalues
Run
john
Shell as user gael
π SSH with gael:mattp005numbertwo
Privilege Escalation
backrest_root Creds bruteforce
Copy
backrest_backup.tar.gzto local KaliVM
Crack the bcrypt hash
SSH Local port forwarding
Create a secure tunnel between Kali local port
9898and127.0.0.1:9898on 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
Uploaded a malicious
.h5TensorFlow model to the web app.The model triggered remote code execution as the
appuser.Enumerated the system and dumped the SQLite database with user hashes.
Cracked MD5 hashes from
users.db, recovering plaintext passwords.Used the cracked credentials to SSH in as
gael.Found
/var/backups/backrest_backup.tar.gzowned bysysadm.Extracted it locally and discovered
backrestconfig with a bcrypt password hash.Cracked the bcrypt hash to get
backrest_rootcredentials.SSH-tunneled port 9898 to access the Backrest API running as root.
Authenticated to the API using the cracked credentials.
Set up a rest-server on Kali to receive backups.
Used Backrest to backup
/rootto Kali machine.Restored the backup locally and retrieved
root.txt.
Extra
Last updated
Was this helpful?
