windowsAccess

Leveraged SeManageVolumePrivilege and DLL hijacking permission to escalate privileges.

Summary

  • The machine had a file upload functionality but implemented protections that denied uploading files with a .php extension.

  • The web application allowed the upload of .htaccess files, enabling a bypass of these defenses.

  • Uploading a webshell provided access to the svc_apache user.

  • Another user, svc_mssql, was identified on the machine, and an SPN was present for this user.

    • This situation was ideal for attempting Kerberoasting.

  • Rubeus.exe was used to perform Kerberoasting, successfully retrieving the password for the svc_mssql user.

  • The svc_mssql user had the SeManageVolumePrivilege, which was exploited using seManageVolumnExploit.exe to gain administrative write privileges on the entire machine.

  • DLL injection was used to inject a malicious DLL, resulting in a reverse shell as the NT user.

🧵Let's Unpack

Enumeration

# Nmap
sudo nmap -sC -sN -A -oN nmapFull -p- -A 192.168.176.187
 
Nmap scan report for 192.168.176.187
Host is up (0.073s latency).

PORT      STATE SERVICE       VERSION
53/tcp    open  domain        Simple DNS Plus
80/tcp    open  http          Apache httpd 2.4.48 ((Win64) OpenSSL/1.1.1k PHP/8.0.7)
|_http-server-header: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.7
|_http-title: Access The Event
| http-methods: 
|_  Potentially risky methods: TRACE
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2024-06-27 14:48:30Z)
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: access.offsec0., Site: Default-First-Site-Name)
445/tcp   open  microsoft-ds?
464/tcp   open  kpasswd5?
593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp   open  tcpwrapped
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: access.offsec0., Site: Default-First-Site-Name)
3269/tcp  open  tcpwrapped
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
9389/tcp  open  mc-nmf        .NET Message Framing
49666/tcp open  msrpc         Microsoft Windows RPC
49668/tcp open  msrpc         Microsoft Windows RPC
49673/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49674/tcp open  msrpc         Microsoft Windows RPC
49677/tcp open  msrpc         Microsoft Windows RPC
49704/tcp open  msrpc         Microsoft Windows RPC
49790/tcp open  msrpc         Microsoft Windows RPC

A web app on port 80 had upload functionality and implemented all possible protections to prevent Arbitrary file upload issues. However, it also supported the upload of a .htaccess file.

Bypassing PHP protection by uploading .htaccess file

on uploading this file, .evil extension will be interpreted as php and will get executed.

Initial Foothold

Let's get reverse shell using above findings

Privilege Escalation/Lateral Movement

On getting a reverse shell, I found a user list

Found SPN of svc_mssql service, which indicates that we could perform Kerberosting

Getting a shell as svc_mssql using RunasCs as Remote access is disabled for this user.

Lateral Movement (svc_apache -> svc_mssql)

https://github.com/antonioCoco/RunasCsarrow-up-right

PrivEsc (svc_mssql -> administrator)

We are going to escalate privileges using the SeManageVolumePrivilege permission.

chevron-rightTL'DRhashtag

If a user has privileges, we can use the following technique to get elevated shell.

Background

The general idea is that the attacker can leverage this particular privilege with the exploitation to get full control over "C:\", and then it can craft a ".dll" file and place it in somewhere "C:\Windows\System32\" to trigger the payload as root.

Technique

On executing the exploit, we can write anything in the C:\ directory. A simple Priv escalation would be to add a malicious DLL that would give us an elevated reverse shell on execution.

Download thisarrow-up-right exploit and transfer it to victim machine

Now, we need to create a malicious DLL that would give us a reverse shell

Now, place this DLL in such a place where executing it would be simple, for instance on running systeminfo command we should be able to get a reverse shell.

we can move the DLL to C:\\windows\\system32\\wbem directory

Refer to this amazing ddlref created by S1ren:

dllref is a list of DLLs that can be used for privilege escalation. This list not only includes various options but also the trigger points for each DLL. In our case, other DLLs can be used instead of tzres.dll to achieve the reverse shell trigger.

Last updated