Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ layout: default

<h1>News</h1>

<hr>
<article>
<div style="display: flex;">
<div style="flex: 1">
<center>
<img width="400em" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATcAAACiCAMAAAATIHpEAAAA1VBMVEUUHSz///+f7wEAABcBEiQAABmi8wATHCxeY2qj9gAAAC0TGywQGikAABsPFiqM0wma5wMwN0IJFSYAAB2ws7bV1tkaJTW5u70AAADh4uPw8fIGCC0oLz18ug9GS1UAAA9biRpikxpOVFt3sRibnqGlqKxobXSRlJkAAA3r7O0ACSANEixYXWWGio/k5eY/REwJDCw+XCSCww52eoDExslnmRtNdCCP2ggsQSkwRyUgLytxqRVIayFEZCaIzQ1Xgh9QeB0aJyoVICk0TiQkNSgvRSl9gYj8DtWUAAAI4klEQVR4nO2afVvivBLGS1uo9AWhUF6KWl9AoCCi4Oquq667Pn7/j3Qyk6QW0LPsc/DSPdf9+0PbNG2TO5PJZIphAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADvifPRDfgr8boz1/voRvxtOMascrV75Xc/uiF/GRX3y3W5VL7+4lY+uil/ERX35r5cMk2zVL7/CuU2xHO/3ZJqpRL9KZ98g5vbhJl3WC2TavsXJ6RcuXr4s4ul9TdU3O/CsdEEvXPH7sU9Hws3N/7ohn1qPPdmv0RKVR9mM7Gojsc/rtn2Lr9isr6JiNhuTXZsV49dKZMnwpESK3f7E8q9ijPrPpg8LS9v3Erm0Dz3cZ/dnPkwnn1k+z4pzuxul1Xb/b4SeVSEmyvJK1gf1hgfcdhRPXzFqmbCzXFMcoX9wwpOZZcC3fLhq17Mc3+UKQyuzlYMLrRtWxb54ijMnkblt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7abKJ/t6w/M8htgXjf1Odos36/l0D8tW47T3sR75NRbybx9dEmcF92crnHFvxgpnzzit0lreO4Tp97K1QfaXWndnLH7Q6p2/wtf7F+l4qpPz9cXbkXts8ixsZqUhPvoBn5aZl35G67y/o0rdbs5YdXMo/Fsq9/P/r9wHJV6K5tX98LydqVjK53cuBDtv1Nxv5Kb4x9bmvIXl/cX+K3qBozpC4OpKVe/dMcwtt/jGN7MfahK5cR8HeNHSBvjuD/JzQnH9oTY44/w3F+X5v0dHNuf4oxnN2NEbH+McHMVODYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4Df8BwlV4YFGdyRNAAAAAElFTkSuQmCC" alt="">
</center>
</div>
<div style="flex: 1">
<h2>HackTheBox - Runner - Writeup</h2>
<p>Season 5 is started on HackTheBox. A new writeup for HackTheBox - Runner is now Available.</p>

<center>
<a href="{{'/pages/writeups/hackthebox/machiens/runner/runner'}}" class="btn">Check it Out</a>
</center>

<br>
<small>25 Apr 2024</small>
</div>
</div>
</article>


<hr>
<article>
<div style="display: flex;">
Expand Down
8 changes: 8 additions & 0 deletions pages/writeups.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ layout: default
<th scope="col">Writeup</th>
</thead>
<tbody>
<tr>
<td><a href="https://www.hackthebox.com/">HackTheBox</a></td>
<td>Machine</td>
<td>Runner</td>
<td class="d-flex justify-content-center">
<a href="{{'/pages/writeups/hackthebox/machines/runner/runner'}}" class="btn">Read</a>
</td>
</tr>
<tr>
<td><a href="https://www.hackthebox.com/">HackTheBox</a></td>
<td>Web</td>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions pages/writeups/hackthebox/machines/runner/runner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
layout: post
author: k0d14k
title: Runner (machine)
---

<img src="runner.png" alt="logo" style="width:100px;"/>


Tags: `TeamCity`, `SSH Private Key`, `Portainer Privilege Escalation`

---

## Introduction and information gathering

In this machine provided by HackThebBox We have a CI/CD provider’s web site.

![Untitled](Untitled.png)

Looking into the web site it doesn’t seem to provide any useful information So i start with a `gobuster` enumeration (I used [this](https://github.com/danielmiessler/SecLists/blob/master/Discovery/DNS/bitquark-subdomains-top100000.txt) wordlist in this pentest).

```bash
┌──(k0d14k㉿k0d14k)-[~/…/tools/SecLists/Discovery/DNS]
└─$ gobuster vhost -u runner.htb -t 100 -w bitquark-subdomains-top100000.txt --append-domain
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://runner.htb
[+] Method: GET
[+] Threads: 100
[+] Wordlist: bitquark-subdomains-top100000.txt
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
[+] Append Domain: true
===============================================================
Starting gobuster in VHOST enumeration mode
===============================================================
Found: teamcity.runner.htb Status: 401 [Size: 66]
Progress: 100000 / 100001 (100.00%)
===============================================================
Finished
===============================================================

```

As shown by the `gobuster` execution, there is an alternative DNS known as `teamcity.runner.htb`.

![Untitled](Untitled%201.png)

I never heard of this service before but I used `IntelliJ Idea` in the past so I know the `JetBrains` style and this is a `JetBrains` Service.

Searching for some more information I noticed that this version of `TeamCity` has at least two CVEs and so I start to try some exploits.

Bot of these CVEs are explained [here](https://www.rapid7.com/blog/post/2024/03/04/etr-cve-2024-27198-and-cve-2024-27199-jetbrains-teamcity-multiple-authentication-bypass-vulnerabilities-fixed/) and I can confirm that, using this article, I was able to get an administrator’s access token to get logged in.

As the guide suggests I’ve got the admin id by accessing the endpoint: `/hax?jsp=/app/rest/users;.jsp`

![Untitled](Untitled%202.png)

Then, by the following request, I’ve got the admin’s token:

![Untitled](Untitled%203.png)

And now I’m able to access the admin dashboard in `/admin/admin.html`.

![Untitled](Untitled%204.png)

## Getting the first access

In the left menu, We have many entries. If you look better you’ll notice that there is the `Server Administration` sub-menu that seems very interesting.

In this part we have a `backup` functionality and it seems to provide very useful information:

![Untitled](Untitled%205.png)

After I downloaded and unzipped the backup I found an SSH key in the project's directory so We could establish a connection using one of the default users: `john` or `matthew`. So after set `400` permission over the `id_rsa` file We could launch the command:

```bash
ssh -i id_rsa john@runner.htb
```

And We are effectively connected as `john`.

![Untitled](Untitled%206.png)

### Road to ROOT

Now our focus is: “How can We become root”? Let’s see if We covered every host by catting `/etc/hosts`:

```bash
john@runner:/tmp$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 runner runner.htb teamcity.runner.htb portainer-administration.runner.htb

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

```

OK, We’ve got a new host: `portainer-administration.runner.htb`. Another useful piece of information that I didn’t tell you (but you should know if you are following this guide to solve the machine) is that in the backup there was a set of bcrypted passwords.

As I told you before, Matthew is a local user on the server. Maybe this user is linked to portainer so let’s try to crack the password using `hashcat`.

```bash
┌──(k0d14k㉿k0d14k)-[~/…/projects/AllProjects/pluginData/ssh_keys]
└─$ hashcat -m 3200 hash /usr/share/wordlists/rockyou.txt -w 3 -S --show
$2a$07$q.m8WQP8niXODv55lJVovOmxGtg6K/YPHbD48/JQsdGLulmeVo.Em:piper123
```

I used the `--show` flag because I just got this password, you should create the hash file (containing the bcrypt) and copy-paste the command without the flag).

Let’s try to login into portainer with the founded credentials:

![Untitled](Untitled%207.png)

In portainer there is a really pretty way to gain privileges.

First of all the attacker needs to create a volume with the following attributes:

```bash
type=tmpfs
device=tmpfs
o=bind
device=/root
```

Then you should be able to create a new interactive container, where you are root by default, and mount this volume, when you attach a shell you get the host /root in your virtual filesystem.

So let’s connect a shell to the container:

![Untitled](Untitled%208.png)

And then get our last flag:

![Untitled](Untitled%209.png)

---

## Flags

## User flag: f2ed51639b0070b93164b4707927dc6d

## Root flag: 608da84938460b9541397de388d09997
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.