Derailed
Enumeration
Rustscan
sudo rustscan -t 1500 -b 1500 --ulimit 65000 -a 10.129.253.213 -- -sV -sC -oA ./rust/{{ip}}Ports
Open 10.129.253.213:22
Open 10.129.253.213:3000Services
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
3000/tcp open http syn-ack ttl 63 nginx 1.18.0
|_http-title: derailed.htb
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: nginx/1.18.0
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelDirsearch
Web Enum
General Overview
The app allows us to create notes which are displayed in a kind of markdown format. You can do that either as a guest or an user
Registration: /register Login: /login Notes: /clipnotes/ID Administration Panel: /administration Reporting Notes: /report/ID
The admin panel isn't available for guests or user, tells us Only available for admins and redirects us to the login page
Routes
Routes can be found on http://derailed.htb:3000/rails/info/routes
/rails/info/properties
Exploitation
After testing different routes for a longer period of time I started checking the registration and login process.
When calling http://derailed.htb:3000/administration we can see that only admins are allowed to view that page. Seems like we're dealing with roles that are assigned to each account.
Register Request
We can see that which parameters are set when we register as a normal user
Mass Assignment Vulnerability
After playing around for a while I discovered the right parameter to create an admin account
LFI
While I checked out the admin panel I discovered that I as an administrator am able to download reports.
That's a candidate for a nice local file inclusion
Original Request
Get /etc/passwd
This will show us all the users that are currently on the machine and give us an overview
User with a home directory
SQLITE DB
Let's get some password hashes from the sqlite db associated to our app. We found the root dir by checking http://derailed.htb:3000/rails/info/properties
User Flag
RCE - Kernel-level Open Function
While poking around we discover the admin_controller that will show us what vulnerability we can abuse to archive remote code execution.
Ruby Vulnerabilities & Exploits
/var/www/rails-app/app/controllers/admin_controller.rb
Shell
We get our foothold by abusing the Kernel-level Open Function
Privilege Escalation
Local Enumeration
While poking around we already detected that openmediavault is installed
User: openmediavault-webgui
We can switch to the openmediavault-webgui due to password reuse.
Checking /etc/passwd you can see that this account is associated to Toby Wright and the password we were able to crack was called toby
Creds
openmediavault-webgui:greenday
Pivoting Setup
To reach the app you have to have either port forwarding or use a tunnel. Chisel did the job for me, it's my go to tool :)
Reset Webpanel Password
Since the default credentials doesn't work we have to reset the password
SSH Key Deployment
After some time of digging aroung the app and learning how it functions we notice that we are able to deploy ssh keys with it using it's config files as the webpanel doesn't allow us to do anything related to user management.
/etc/openmediavault/config.xml
We just have to change the block for the user test to user root add our ssh key and visit the Web GUI to apply our changes
Rooted
Last updated