Windows Privilege Escalation DNSAdmin to Domain Admin DLL Injection.
Udesh
· 2 Min
Hi everyone, today I will be writing about a privilege escalation technique that I used in a recent pentest. This technique is a bit different from the usual ones and I thought it would be a good idea to share it with you all.
Introduction
DNSAdmin to Domain Admin DLL Injection is a privilege escalation technique that exploits a vulnerability in the Windows DNS service. By leveraging the permissions granted to users in the DNSAdmins group, an attacker can inject a malicious DLL into the DNS service, which runs under the SYSTEM context on a Domain Controller. This allows the attacker to gain SYSTEM-level privileges, effectively becoming a Domain Admin.
How it Works:
- Compromise a DNSAdmin User: The attacker gains access to a user account that is a member of the DNSAdmins group.
- Create a Malicious DLL: The attacker develops a DLL that contains malicious code designed to execute with SYSTEM privileges.
- Inject the DLL: The attacker uses the DNSAdmin permissions to inject the malicious DLL into the DNS service.
- Trigger the Payload: The attacker triggers the payload by restarting the DNS service, causing the malicious DLL to execute with SYSTEM privileges.
Prepping
First, let's check if our user is part of the DNSAdmins group:
type the following command in the command prompt:
As you can see, our user is already in the DNSAdmins group.(MEGABANK\DnsAdmins)
Creating & Serving the Malicious DLL
Now, we need to prepare a DLL that will be used as the serverlevelplugindll. We'll use the msfvenom tool for this.
Next, let's use Impacket's smbserver.py to serve this DLL file in to the victim machine.
Injecting the DLL
Now, we need to inject the malicious DLL into the DNS service. We can do this using the dnscmd tool.
Before you continue, make sure you have started your listener on the attacking machine to catch the reverse shell.
Triggering the Payload
To trigger the payload, we need to restart the DNS service. We can do this using the following command:
If everything goes well, you should receive a reverse shell on your attacking machine. 😎