Runner is a linux machine with medium difficulty by TheCyberGeek develops. It has exploitable vulnerabilities based on the version of TeamCity. I will exploit the CVE-2023-42793 POC to get the possibility to create user with admin privileges.
Enumeration
Nmap
Start with running an nmap scan to determine which services are running on the machine.
-sC: Run default scripts
-sV: Determine service version
-T 4: Set timing template
--min-rate 3000: Send packets at a minimum rate of 3000
-v: Increase verbosity
The nmap scan shows that the machine is running an SSH server on port 22 and a web server on port 80. The web server is running nginx 1.18.0. There is also a Nagios NSCA service running on port 8000.
One noticeable thing is that the web server is related to CI/CD. So I decided to find some hidden routes on the web server that is related to CI/CD.
The ffuf scan showed the following subdomains:
The ffuf scan showed that the web server has a subdomain teamcity that requires authentication. I visited the teamcity subdomain and it showed the following page:
I have successfully exploited the vulnerability and created a user with admin privileges. Now I can login to the TeamCity subdomain. I found a backup file of the TeamCity project. I downloaded the backup file and extracted it. It contains lots of useful information.
Public Key:
This public-key will be useful later.
I tried searching for the database dump in the backup file and found the users file. It contains the following information:
I managed to crack matthew password using hashcat and rockyou.txt wordlist.
The password is pi*****.
Privilege Escalation
Let’s first login to john user using public key from id_rsa.
I successfully logged in as john user, and get the user flag.
Now let’s investigate the machine for privilege escalation.
I found that the machine has a hostname portainer-administration.runner.htb. I visited the hostname and it showed the following page:
I logged in using mathew and the version of portainer is 2.19.4 which also have a vulnerability CVE-2024-29296
Portainer Exploitation
Ideas:
I want to connect to the root drive of the host, from there as the root user I can freely access any resources on the host.
Exploitation:
First, I need to create a local liked drive.
Then I need to create a container with the volume and the teamcity:latest.
I set the working dir to /mnt and console to be Interactive & TTY. Then I bind the volume to /mnt/root.
Now I can access the console of the container and get the root flag.