Worker - [HTB]

Cover Image for Worker - [HTB]
Marmeus
Marmeus

Introduction

Worker is a medium level Windows machine where the attacker first will have to face something similar to git in order to find a new domain, a user and a password. Then, using Azure devops will have to upload a reverse shell with the purpose of finding another user name and password getting the user flag with evil-Winrm. Finally, once again, using Azure devops the attacker will have to configure a pipeline, so at building time Azure will print the root flag.

Enumeration

As always start scanning all opened ports with nmap.

Then, I continue with a deeper scan obtaining a bit of information about each service.

In port 80 there is a Windows Server web page with just and image (Using gobuster didn't provide much information).

image-20201105232141140

In the port 3690 there is a service named subversion (a software versioning and revision control system distributed as open source under the Apache License (Is like a GitHub Repository)), where we can retrieve a lot of information using subversion-cli tool and its specials syntax.

Let's First gathere some information like the repository like its author, the number of changes, its root repository ...

Secondly, which files are stored in the repository.

We can download them with the following commands.

In the movedt.txt file there is a new domain, where we can dig deeper in order to find more information.

However, in order to get access we need to provide some credentials, but we don't have any.

image-20201106132643313

Inside the "dimension.worker.htb/index.html" we can find several domains. However, adding theme to the "/etc/hosts" file doesn't doesn't seem to be useful for now.

image-20201107162313953

Looking into the different "revisions" there is a PowerShell file named "deploy.ps1", where we can find a user name and a password.

This credential is being used to access to the devops domain, where there is an Azure DevOps page (Azure DevOps is a Microsoft product that provides version control of files like Git). Inside the web page, we can see a repository about a "Smart hotel".

image-20201107170111566

Explotation

The files inside the repository are the same as the ones that we can find for the web http://spectral.worker.htb/.

image-20201107175705969
image-20201108224839109

So, we could upload a web reverse shell for windows server so we can get access to the server internals. However, we can not upload a shell directly to the repository, we need to do a pull request.

image-20201108222639839

Furthermore, we can not create a branch followed by a pull request because the request will never be completed because we don't have any work items linked.

image-20201108225202399

Finally, in order to upload a reverse shell we need to go to the "Boards" section clicking in one of the Work items.

image-20201108225249696

Then, we need to click on the 3 dots, clicking on new branch.

image-20201130153758411

The appearing pop up should looks like this (Obviously, without the word exploit :V ).

image-20201108225342604

Once, our shell has been uploaded to the repository, we can create a pull request.

image-20201108225516941
image-20201108225441575

Click on "Create" and finally on "Complete" and our shell will be uploaded.

image-20201108225619068

Now, we can create a listening port and when we access to http://spectral.worker.htb/rshell.aspx, we retrieve our reverse shell. However, you won't find anything useful on the C: drive, that is because this machine is composed with another hard drive.

Inside W:\ there is a file named passwd with a lot of users and passwords.

Between all of them, the one below works for accessing to the system using the winrm service (5985)

For that we can use evil-winrm as you can see with the following command.

Furthermore, this credential can be used to get access to the Azure DevOps web page. Finding a new repository.

image-20201108233830832

Privilege escalation

Because we have access to the repository, we can use the Azure Pipelines to execute code on the windows machine that will be executed once our pull request has been accepted. So in order to get our root flag, we need to access to the repository, press "Pipelines" and then "New pipeline".

image-20201130171041121

After that, click on "Azure Repos Git" as our platform for the repository.

image-20201130172109762

Select the repository "PartsUnlimited".

image-20201130172231446

Click on "ASP.NET Core" for building and testing ASP.NET Core projects.

image-20201130172306839

Modify the "azyre-pipelines.yml" file so during building time will be executed.

Note: Don't forget to remove the line pool: 'Default'

image-20201130173558230

Then, click in the "Save and run" button and wait to pipeline to finish.

image-20201130173706133

Finally, click on "dotnet build release" so you will see the root flag.

image-20201130174324853