Visual HTB

IP

10.10.11.234

Initial Nmap scan

sudo nmap -p- --min-rate 10000 10.10.11.234 | cut -d"/" -f1 | tr '\n' ','

Looks like we have one port open on the machine

80

Lets get a bit more information on port 80

sudo nmap -sCV -p80 -oA nmap_scan 10.10.11.234

results

PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.56 ((Win64) OpenSSL/1.1.1t PHP/8.1.17)
|_http-title: Visual - Revolutionizing Visual Studio Builds
|_http-server-header: Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.1.17

we can see the following

  • we have a HTTP web server Apache 2.4.56 ((Win64))

  • Windows server, But what version?

Lets checkout the web server

initial thoughts

  • Looks like some kind of Visual Studio compilation service

  • supports .NET 6.0 and C# programs, make sure the a /sln file (maybe reverse-shell ?)

  • we submit out GitHub repo link, the service then compiles our .sln files, then sends back the exe or DLL files

Since this is still a web server Lets see if we can enumerate any directories

directories

results

from this we can see

  • we have PHP application running on the web server

Lets test the functionality of this compiling service, ill set up a netcat listener and point the URL submission to my local machine

  1. nc listener

  1. we can now submit "http://10.10.14.2/ting.git" through the web app

  1. Results

Looking at the git documentation

reveals the back end is essentially executing a git clone <submitted url>

Next, Lets set up a local git repo via docker using gitea

we can find the installation steps via below

Lets create a repo and perform further analysis of this function

  1. create a repo

Once you have created an account and logged in we can simply hit the plus icon next to "Repositories"

  1. Now we want to create a test file, name it whatever you want, leave all other options empty if you wish, click save, then we should see the following

  1. Now we want to clone a simple c# program and push it into our newly created repo , i chose the following

clone the repo to our local machine

Now we want to push our repo to gitea

from here we can submit our repository URL to

After the build has completed we are presented with build artifacts

although these artifacts don't provide a direct vulnerability, we have what is called a build event, think of it like executing a predefined command before the build process starts, if we could manipulate the MSBuild's PreBuildEvent, we will have the ability to download and execute a Powershell reverse-shell on the target server

How do we do this?

  • we need to define a custom target or PreBuild that runs before the PreBuildEvent

we can craft a malicious visual.csproj file with a PreBuildevent event that will execute the following commands on the target

Lets Lets add this file to our visual-HTB repo

Now we can modify our PowerShell script, i've opted for a nishang powershell

start a python server

start our listner

we can know use the build function within the target and specify our repo

we know have a shell on the system

Given our current user is a web based service account, typically these kind of services possess the "impersonatePrivilege" Permission,

Lets check privileges

  • we can see we dont have the impersonatePrivilege, But we can utilise a tool called "FullPowers"

we can download it to our local machine

Now we need to upgrade our shell lets download nc64.exe onto our local machine

start a listener on our local machine

execute netcat on the target

  • this didn't work

Maybe we can get a PHP reverse-shell within the C:\xampp\htdocs\uploads directory so we can have some what persistence on the machine

for this we will use pentest monkeys updated php-reverse-shell

  • after we have added our ip and port, lets transfer it to the target

  • Lets start our nc listener

Now when we naviaget to http://10.10.11.234/uploads/rev.phparrow-up-right in our browser this will trigger the php script

Alright we are ready to execute FullPower.exe

Now if we check our privileges we can see we know have SeImpersonatePrivilege enabled for our current user

Now we can perform some token manipulation and hopefully gain system authority

we can use God potatoe for this, and exploit the SeImpersonatePrivilege

Lets transfer godpotatoe to our target machine

Now we can run godpotatoe and execute commands as nt authority\system , lets establish a netcat reverse-shell

  1. start a listener on our local machine

  1. execute godpotato

we are now nt authority/system

Last updated