Page cover

Heal

Synopsis

Heal is a medium linux machine created by rajHerearrow-up-right. The download pdf feature is vulnerable to Path Traversal vulnerability. The take-survey subdomain is using LimeSurvey and LimeSurvey admin login password is found in Rails on ruby config file which is fetched exploiting the Path Traversal vulnerability. The install plugin feature in LimeSurvey is vulnerable to RCE and exploited it to gain the reverse shell as www-data. The config file of LimeSurvey config file reveals the password and /home directory reveals the user. The password gives us access to the ron user. The hashicorp consul binary is running and the RCE vulnerability is created when malicious service is created . The vulnerability is exploited and gained the reverse shell as a root.

OS
Difficulty
Points
Release Date
Retired Date

Linux

Medium

30

14-12-2024

17-05-2025


Enumeration

Nmap

nmap -Pn -sC -sV --min-rate=1000 10.10.11.46
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-17 07:43 EDT
Nmap scan report for 10.10.11.46
Host is up (0.50s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 68:af:80:86:6e:61:7e:bf:0b:ea:10:52:d7:7a:94:3d (ECDSA)
|_  256 52:f4:8d:f1:c7:85:b6:6f:c6:5f:b2:db:a6:17:68:ae (ED25519)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://heal.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 41.54 seconds

Web - heal.htb

The website is resume builder and we have to create the account to create our resume. I have created the account and login as a test user. The form is presented to input our information to be presented in the resume.

At the bottom of the form the EXPORT AS PDF button is present. The /export and /download endpoints are requested and PDF is downloaded.

download request
Downloaded PDF

Intercepting the GET request from /download endpoint and sending it to the repeater in burp without forwarding it, then changing the value of filename parameter. The Path Traversal vulnerability is found.

Clicking SURVEY > TAKE THE SURVEY button the take-survey subdomain is found. The api.heal.htb is also requested during interacting with the site. Add take-survey and api subdomain in /etc/hosts file.

Web - api.heal.htb

It only returns the rails on ruby page with it's version.

Web - take-survey.heal.htb

The Next button takes to the form where we can write the about the features to be implemented, nothing interesting. The / endpoint takes to the LimeSurvey home page where LimeSurvey Administrator email is given for contact.

Fuzzing - Directories

The /admin directory is present. Visiting the /admin directory it redirects to /index.php/admin/authentication/sa/login which gives us the LimeSurvey login page.

Ruby Files - Path Traversal Exploit [ heal.htb ]

The api.heal.htb shows the ruby page and the application configuration file of ruby is present in /config/application.rb file.

Nothing much interesting but the application.rb file is fetched and that means the configuration for database file which is database.yml is also present.

The path to three sqlite3 file for development, test and production is present here. Downloading development.sqlite3 file.

Database - development.sqlite3 [ LimeSurvey Access ]

Enumerating the development database gives us the two users and their hashes. The second user account is the account created by me while building the resume in heal.htb. Cracking the hash using hashcat.

Using the above password to login into the LimeSurvey.

The Account section gives us the LimeSurvey version.


Foothold

Shell - www-data [ LimeSurvey RCE ]

Installing plugins in LimeSurvey can be used for RCE. The github user Y1LD1R1M-1337arrow-up-right has created the github repositoryarrow-up-right for exploiting LimeSurvey to gain RCE. Using the repository for getting shell.

Exploit

1

Git clone the repository

2

Modifying config.xml and php-rev.php file

Change the ip number and port number according to your ip and choice of port.

3

Zip both the files

4

Upload the plugin

Go to Configuration > Plugins and click on Upload & Install button.

5

Getting shell

Once the plugin is installed, open the nc listener and navigate to /upload/plugins/Y1LD1R1M/php-rev.php


Privilege Escalation

Shell - ron

The home directory contains ron and ralph directories.

Enumerating the LimeSurvey config.php file, the database password is found.

The above password works for ron user SSH login.

Pillaging - ron [ user ]

Checking the process using ps aux reveals that the root is running consularrow-up-right.

The consul binary and it's config file is present in the system.

Shell - root [ consul RCE ]

Creating the service using consul with command in args parameter.

Exploit

1

Creating malicious service

2

Executing bash and getting root shell


Proof of Concept

The below video provides the PoC of Heal machine.

Last updated