This group is primarily intended for DNS management in AD enviroments
A domain user account which belongs to this group can manage DNS zones, DNS records and DNS configuration of the given nameserver, which is usually a DC
Moreover, it is closely tied to the DNS Server role in AD as this group is created during the feature installation
Enumeration
Listing the Groups to which the Current User belongs
whoami /groupsnet user <USER>
Members of DNS Admins
net localgroup "DNS Admins"
Code Execution as LOCAL SYSTEM
We must bear in mind that Windows DNS service supports custom plugins and can call functions from them to resolve some name queries
Since this service runs as LOCAL SYSTEM, we could use the dnscmd command line utility to load a malicious plugin DLL by specifying a remote path controlled by the attacker
Therefore, an operator could craft a DLL which executes a reverse shell when the DNS service is restarted
That is, we leverage theServerLevelPluginDLL hive to load an arbitrary DLL, as stated, once the DNS service is restarted, the given DLL will be loaded as LOCAL SYSTEM
In order to load the DLL, it’s required to restart the DNS service. We may be able to restart the DNS service since we are members of the DNS Admins group
Regardless of this, we should check which permissions the current user has over the DNS service object by retrieving the existing ACEs within the DACL of its security descriptor
Retrieving the Current User SID
To do so, first we need to know which SID the current user has
cmd.exe /c wmic useraccount where "name='%USERNAME%'" get sid
Once we know the SID of the current user, we can leverage the sc.exe sdshow command to retrieve the securityDescriptor of the given service object
sc.exe sdshow DNS
Restarting the DNS Service
With the appropiate permissions, we can restart the service as follows
sc.exe stop DNSsc.exe start DNS
Alternatives
If it does not work and we do not receive the reverse shell , simply transfer the DLL to the target and specify the local path of the DLL instead of a remote UNC path
Once we receive a shell as LOCAL SYSTEM and we can carry out any action as the latter, we should perfom certain cleanup actions to cover our tracks and ensure that the DNS service starts correctly i.e. without loading any malicous DLL which can affect the service availability
Retrieving the value of ServerLevelPluginDll
So first, we must validate that the key value was modified correctly
To prevent WPAD Spoofing, Microsoft introduced the Global Query Block List starting with Window Server 2008, which causes the DNS server to respond with a NXDOMAIN indicating that the asked name does not exist, even if it really exists
However, the situation changes when an operator compromises a domain user account which belongs to the DNS Admins built-in group
Since any member of this group has the ability to enable, disable or edit the Global Query Block List, the entry for WPAD can be removed from this list
Immediately afterward, the operator can create a new DNS record in the DNS zone named WPAD.domain.internal pointing to the attacker’s IP Address
Once this is done, any victim that has the Automatically detect Proxy settings option enabled, which is default, will be subject to the following →
A certain web client within its system ( e.g. IE ) will try to automatically detect any valid proxy configuration
It will send a query name asking for the resolution of WPAD.domain.internal to the Primary DNS Server, which is typically the DC on a domain-joined machine
The DC will respond with the attacker IP Address as the adversary has created the WPAD.domain.internal DNS record previously
Then it will send an HTTP request to the attacker’s HTTP server requesting a wpad.dat resouce, which is a JS PAC file that contains a proxy configuration
The HTTP server responds with a 401 Unauthorized error and a WWW-Authenticate HTTP header asking for some type of authentication to the client
Lastly, the victim’s web client sends an authentication to the attacker and the latter leverage it to capture Net-NTLMv2 hashes or relay the authentication to other node
Requirements
That said, in order to be able to carry out this technique, the following requirements must be met
Controlled domain user account belonging to the DNS ADMINS group
Attacker machine in the same network as the AD environment
Abuse - Windows
Veryfing Group Membership
whoami /groups | findstr /I "DNS"
Disabling or Deleting the WPAD entry from the Global Query Block List