Page cover

Yummy

Synopsis

Yummy is a hard linux machine created by LazyTitan33arrow-up-right. The yummy.htb website is used showing its menu and reserving the table. Registering and login into the website we can save the reservation in .ics file but saving reservation is vulnerable to Path traversal, by exploiting it we will gain the website source-code and scripts used in cron jobs. The source code reveals the /admindashboard directory in website and contains the code to create the JWT token using RSA key pair. The new JWT token can be forged to gain the access to /admindashboard. The search field is vulnerable to SQL injection and we can abuse it to gain the shell as mysql. One of the cronjob script is running by www-data and we will get the shell as www-data by replacing the content of the script by reverse shell payload. The www-data contains the qa user password in one of the binary file and we can ssh into qa user using that password. The qa user has a sudo privilege to run hg binary which we will exploit to gain the shell as dev. The dev user has a sudo privilege to run rsync binary, we exploit it and gain the shell as root.

OS
Difficulty
Points
Release Date
Retired Date

Linux

Hard

40

05-10-2024

22-02-2025


Enumeration

Nmap

Started the nmap scan and found ssh and http services running.

nmap -Pn -sC -sV --min-rate=1000 10.10.11.36 
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-12-26 08:53 EST
Nmap scan report for yummy.htb (10.10.11.36)
Host is up (0.39s latency).
Not shown: 62793 closed tcp ports (conn-refused), 2740 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 a2:ed:65:77:e9:c4:2f:13:49:19:b0:b8:09:eb:56:36 (ECDSA)
|_  256 bc:df:25:35:5c:97:24:f2:69:b4:ce:60:17:50:3c:f0 (ED25519)
80/tcp open  http    Caddy httpd
|_http-server-header: Caddy
|_http-title: Yummy
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 231.39 seconds

Add the yummy.htb domain in /etc/hosts file.

Web - yummy.htb

The website is used to display the menu and book the reservation in yummy.

Creating the account and logging in gives us the access to the dashboard.

Booking a table gives the list of booked tables in dashboard and the option to cancel the reservation and save the calender.

Clicking on SAVE CALENDER and intercepting the request in burpsuite, the .ics file is exported and downloaded.

Replacing the .ics calender file name with another file the /exports endpoint was vulnerable to Path Traversal with which we can download the files from the system.

File - crontab

Downloading the crontab using the above Path Traversal vulnerability.

Crontab contains the three files. Downloading it through Path Traversal.

File - app_backup.sh

It contains the script to delete the previous backupapp.zip file and compressing the /opt/app folder contains recursively using zip in backupaap.zip file.

File - table_cleanup.sh

It is used to login into mysql as chef user into yummy_db and outputting the contains of sqlappointments.sql.

File - dbmonitor.sh

  • It checks whether the mysql is active or not, if not active it will add The database is down string in dbstaus.json file and tries to restart using the /data/scripts/fixer-v* script.

  • If the mysql is active it checks whether the dbstatus.json file is present or not, if it is present it checks for string database is down, then it will send the mail to root notifying that the database was down with timestamp else it will try to fix the database using the /data/scripts/fixer-v* script.

File - backupapp.zip

The backupapp.zip contains the app source code. The opt/app/app.py file reveals the mysql credential and the admindashboard directory is present in web and the username is administrator.

The opt/app/config/signature.py is used to create the session tokens for the web. It is generating the RSA key pair with random prime numbers and factor of n. If n is revealed we can modify the session tokens.


Exploit

Crafting new JWT token - admindashboard access [ Updating role ]

Previously intercepting the .ics file export request reveals the JWT token.

1

Register and login

Register in yummy.htb and intercept the login request in burpsuite. It will send two request login and dashboard. The dashboard request will give us JWT token.

2

Decoding JWT

Using jwt.io to decode the JWT reveals the role field as a customer. The value of n is revealed which we can use to change the role of customer into admin.

3

Creating python script

With the help of AI I have created the python script to change the role of JWT token and create the JWT with new updated role.

Replace the JWT token and value of n.

4

Execute the script

Create the python virtual environment and install the required packages.

We will get the new JWT token when executing the script with updated role.

5

Accessing /admindashboard

Decoding the new JWT using jwt.io.

The role has been changed. Login using the new JWT token, the /admindashboard is accessed.


Foothold

Pillaging - mysql database [ SQL injection ]

The admindashboard shows us the list of seat booked by the costumers. It also contains the input field for searching. Testing for sql injection via sqlmap by intercepting the search request and saving it into request.txt file.

It is vulnerable to sql injection. The yummy_db doesn't provide much of the data and checking the privileges reveals the read and write privileges.

Shell - mysql [ user - Abusing write privilege ]

Methodology

The write privilege gives us the access to write to file and gain the reverse shell. Previously, we know that the dbmonitor.sh checks that the database is down string is present or not in dbstatus.json and runs the fixer-v* script, if it is not present. We can write into dbstatus.json with some other data and fixer-v* with reverse shell code and gain the reverse shell.

Exploit

1

Creating the base64 reverse shell payload

2

Populating the files

Opening the nc listener and populating the dbstatus.json and fixer-v* files with the payload to gain the reverse shell.

3

Getting the reverse shell as mysql


Privilege Escalation

Shell - www-data

Pillaging the mysql user doesn't gave us anything useful. Similarly the www-data user is running the app_backup.sh script and we can put the reverse shell payload and gain the shell as www-data user.

Open the nc listener and execute the below commands.

Shell - qa [ pillaging www-data ]

The www-data contains app_qatesting directory, backupapp.zip and .bash_history file.

Searching the password word using grep in app-qatesting reveals different files containing the password word.

The app.py.i binary file reveals the qa user password which we can use to ssh into the qa user.

circle-info

The user.txt file contains the user flag 👏

Pillaging - qa [ user ]

The home directory contains two users directories qa and dev.

Checking the sudo privileges reveals that the qa user has a sudo privilege to run hg as a dev.

The hg command is a tool that provides a command-line interface to the Mercurial system, which is a distributed version control system used for software development.

The .hgrc file contains the config of hg and user qa and dev is a trusted user.

Shell - dev [ hg pull ]

The hg also uses the hooks similar to git which we can use to privilege escalate to dev user using the hg pull command to run the reverse shell script.

1

Adding hooks in .hgrc file

Add the above text into .hgrc file.

2

Setting up in /tmp directory

Change directory into /tmp and create the shell.sh with the reverse shell payload.

Create the .hg directory, add the write and read permission in .hg directory, copy and paste the .hgrc file from /home/qa.

3

Open the nc listener and execute the hg command

Pillaging - dev

Checking the sudo privilege reveals that the dev has a sudo privilege to run rsync as a root.

rsync is a utility for transferring and synchronizing files between a computer and a storage drive and across networked computers by comparing the modification times and sizes of files.

Shell - root [ rsync ]

Methodology

The bash binary will be copied into /home/dev/app-production/ directory and adds the suid bit into it but the above rsync command contains the -a flag which preserves the permissions, symbolic links and other attributes of the file. We can change the permission to root using the rsync --chown flag.

Exploit

1

Preparing bash binary

Copy the bash binary into /home/dev/app-production/ directory and add the suid bit into it.

2

Getting the root shell

Execute the rsync and bash binary to get the root shell.

circle-info

The root.txt file contains the root flag 🎉


Proof of Concept

The below video provides the PoC of Yummy machine.

Last updated