Runner is a medium-difficulty machine from HackTheBox, where we first begin by exploiting TeamCity to obtain ssh credentials and our user flag, later port forwarding an internal Portainer application where we can abuse CVE-2024-21626 to do a docker escape and catch our root flag.
PS C:\Users\0xkujen\OneDrive\Bureau\HackThebox\HTB_Machines\Runner> nmap -A-Pn10.129.202.190 Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-2321:09 W. Central Africa Standard Time NSOCK ERROR [0.2660s] ssl_init_helper(): OpenSSL legacy provider failed to load.
Nmap scan report for10.129.202.190 Host is up (0.29s latency). Not shown: 997 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.6 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2563eea454bc5d16d6fe2d4d13b0a3da94f (ECDSA) |_ 25664cc75de4ae6a5b473eb3f1bcfb4e394 (ED25519) 80/tcp open http nginx 1.18.0 (Ubuntu) |_http-title: Did not follow redirect to http://runner.htb/ |_http-server-header: nginx/1.18.0 (Ubuntu) 8000/tcp open nagios-nsca Nagios NSCA |_http-title: Site doesn't have a title (text/plain; charset=utf-8). No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ). TCP/IP fingerprint: OS:SCAN(V=7.93%E=4%D=8/23%OT=22%CT=1%CU=35190%PV=Y%DS=2%DC=T%G=Y%TM=66C8ECF OS:C%P=i686-pc-windows-windows)SEQ(SP=102%GCD=1%ISR=10E%TI=Z%CI=Z%II=I%TS=A OS:)SEQ(CI=Z%II=I)SEQ(CI=Z%II=I%TS=A)OPS(O1=M54EST11NW7%O2=M54EST11NW7%O3=M OS:54ENNT11NW7%O4=M54EST11NW7%O5=M54EST11NW7%O6=M54EST11)WIN(W1=FE88%W2=FE8 OS:8%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(R=Y%DF=Y%T=40%W=FAF0%O=M54ENNSNW7% OS:CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y OS:%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%R OS:D=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0% OS:S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPC OS:K=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S) Network Distance: 2 hops Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel TRACEROUTE (using port 53/tcp) HOP RTT ADDRESS 1 976.00 ms 10.10.16.1 2 174.00 ms 10.129.202.190 OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 106.53 seconds
We can see that we have OpenSSH running on port 22, a web application exposed on port 80 and an exposed 8000 port.
When navigating to http://10.129.202.190, we find that it’s redirecting us to runner.htb domain. So we go ahead and add that entry to our /etc/hosts file. Web App Port 80
This seems like a casual web application without any actual features.
TeamCity is a Continuous Integration and Deployment server that provides out-of-the-box continuous unit testing, code quality analysis, and early reporting on build problems. TeamCity Login
CVE-2023-42793
Checking the TeamCity version Version 2023.05.3, we can find a public Remote Code Execution exploit here It will create an admin account for us to login with:
We open http://127.0.0.1:9000 and we are prompted with Portainer Portainer Portal
1
Portainer is your container management software to deploy, troubleshoot, and secure applications across cloud, datacenter, and Industrial IoT use cases.
We can use Matthew credentials to login: Portainer Login
By checking portainer we can see that we have a couple of docker images: Docker Images
We want to abuse the ubuntu:latest image in order to somehow gain some shell access.
After doing some research I stumbled onto this article about CVE-2024-21626 . Therefore I have to create a container built on the ubuntu:latest image with a working directory of /proc/self/fd/8. CVE-2024-21626
CVE-2024-21626
And after creating the container, I used the container console to access the container as root, where I can find my root flag. By moving up several directories, I’m able to access files from the host:
CVE-2024-21626
And that was it for this writeup! Thanks for reading! -0xkujen