[HTB | Insane] Derailed

Port Scanning
We start with a simple nmap scan:
We can see that we have 2 open ports:
Port 22: simple ssh
Port 3000 Apache web server (thats redirect us to derailed.htb)
Web Scanning
Website Enumeration
Doing some routine directory fuzzing we discovered a /administration endpoint that we can't get access (302 Error) (maybe it will need it later)

This is a clipnote website that run on "Ruby on Rails" (a ruby framework)

That's interesting, when we create a note it gives us an id of that note (in a sequential order), maybe we can try fuzzing it.
Fuzzing was not the solution, but there is a "Report Clip" function that alerted us immediatly, as soon as we send a report the page showed us "The note has been reported. Our admins will soon have a look at it.".
Thats XSS 100%

XXS to RCE
We searched for a bit and we found somenthing useful: when we create a long name (we probably overflow the username) and add a javascript tag, when we create a note we will get xss execution and get a callback execution. Username used: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<select<style/><img src='http://<IP>/error'>
We can encode this payload using this converter tool and insert it in a onerror=""eval(String.fromCharCode())" to request the admin page which we can't see:
Final username to get administration page:
In the administrator page we can observe a strange form that make a post request and a file .log that we suspected was insecure due the non proper use of the "open" ruby function as explained in this website. we just need to make our exploits that send our command:
And we got a nice remote code execution!
Privilege Escalation
First Escalation With New Credentials
Finding new credentials was not an hard find: we just got spawned in the webserver directory which there was a good directory for us: "db" Here we found a development.sqlite3 database and after a little ".tables" and "SELECT" we found out 2 users:
We tried to crack the passwords with john but we managed to crack only one: greenday for the user toby
Listing /etc/passwd we can see that the user openmediavault-webgui is in fact our Toby user:
Openmediavault
After a few hours enumerating the machine, trying to load the page on 127.0.0.1:80 with chisel we found a file that is owned by root but we have full access on it: /etc/openmediavault/config.xml A bit of searching in th enetwork we scarped 2 useful links: https://forum.openmediavault.org/index.php?thread/7822-guide-enable-ssh-with-public-key-authentication-securing-remote-webui-access-to/ https://docs.openmediavault.org/en/6.x/development/tools/index.html
The exploit is simple: we need to add another user in the xml file (root user for example), add our ssh-keys ogenerated by the user "openmediavault-webgui" (because we dont know if ssh as root from the external network is possible) and reload the configuration.
Generate new ssh keys (v2 as said in the forum thread)
ssh-keygen -t rsa;ssh-keygen -e -f ~/.ssh/id_rsa.pubGo on /etc/openmediavault/config.xml, add your ssh public key v2 like this
<sshpubkey>SSH_PUB_KEY</sshpubkey>inside (because you need to add an xml object) like this:

Use this string to check that it's all right:
/usr/sbin/omv-confdbadm read conf.system.usermngmnt.userAnd then use this command to apply the changes:
/usr/sbin/omv-rpc -u admin "config" "applyChanges" "{\"modules\": [\"ssh\"],\"force\":true}"And if this return true:
We've done it! Now we just need to connect as root to get root privileges! ssh [email protected] -i ~/.ssh/id_rsa
uid=0(root) gid=0(root) groups=0(root)
That's was a really cool box and thanks for the reading.
Hope to see you soon!
Pedio Zaki
Last updated
Was this helpful?