-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dnsadmin ServerLevelPluginDLL Feature Abuse Privilege Escalation #12983
Conversation
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
Sorry for the delay on this. I tried to setup an environment to test this but I'm still stuck :
Does anyone already have an environment ready to test this? Perhaps it's because I have Windows Server 2016 instead of 2019? |
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected. We have been unable to test this module successfully. This may be due to software or hardware requirements we cannot replicate. To help unblock this pull request, please:
Once there's a clear path for testing and evaluating this module, we can progress with this further. |
Please let us know how to set up our environments to test this, #12983 (comment) |
To set up a development environment:
|
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
Ok can confirm that I did the following to set up a vulnerable server on Windows Server 2019:
When this is all done the
Note that without the final step, step 11, you will get the following output:
In my opinion this is technically exploitable if the server is restarted as the service will have to start itself up again, however I can see how this might not be an ideal solution and why it may be preferred to have the user have permissions to restart the service. That being said given that this isn't the default settings from the looks of things I do have some reservations about marking the target as unexploitable simply because the current user doesn't have permissions to restart the service themselves. |
Confirmation of this technique working on a Windows Server 2019 Standard Edition server with August 2020 patches applied (fully up to date as of today). Using the same configuration options as mentioned above:
|
This comment has been minimized.
This comment has been minimized.
Also since I was interested in this as well and it was pointed out, no this doesn't stop the DNS server from operating. This was taken after the exploit, with the DNS server to query set to 127.0.0.1:
|
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb
Outdated
Show resolved
Hide resolved
Ok so one issue I did notice with this exploit as well is that if for w.e reason the DLL gets picked up by AV, then we get into a very odd situation whereby the DNS Server cannot restart. So for instance lets just say I did this cause I was a pentester and I panic'd
Then I go in later and realize the DNS server is down so I try to restart it:
Looks like one cannot restart the service so long as that registry link still exists. I'm going to go in and update the output of the module and the documentation so that the user is aware that there is a potential failure point and to let them know how to resolve this. Its unlikely to occur as even during testing MS Defender wasn't fast enough to pick up the file but its possible that there may be other AVs or circumstances that cause this to occur so it would be good to make the user aware of this as well as how to resolve the issue. PS @ide0x90 I also rebased your repo since it was getting close to 5000 commits behind |
DLL generation appears to work well, no issues there. Will need to update the code that starts the DNS service so that it has a timeout as otherwise if one can't start the DNS service, we will get a hang on the line |
Nevermind looks like for some odd reason this was the default temp directory for my user:
All good. |
Thanks for your pull request! Before this pull request can be merged, it must pass the checks of our automated linting tools. We use Rubocop and msftidy to ensure the quality of our code. This can be ran from the root directory of Metasploit:
You can automate most of these changes with the
Please update your branch after these have been made, and reach out if you have any problems. |
Ok so made a few updates to this the last few days, which included adding in the installation instructions, applying RuboCop updates, handling a potential infinite loop case, and fixing a case where I had incorrectly placed the logic for the AV check too early in the code, which was causing the exploit to fail when it tried to use a UNC path as the location of the DLL. Things I would still like to try to solve are as follows:
|
…ter the module executes. Added OS check (>= Server 2003 is vulnerable so far). Now cleans up dropped DLL and modified registry value.
…uations the module could run into, and also include some new documentation on the new option we have added in to try to prevent this from happening
… other processes deleted the uploaded DLL file, thereby preventing a situation where the DNS server is unable to restart. Also add in some warning's r.e when we enter the danger section and when we exit it so that users at more aware of when this is happening.
… loop state. New code should prevent this from happening
…n the GitHub comments. Also RuboCop the exploit module code.
…th is used, as there is no chance the AV on the host can remove the file on the UNC share, and the UNC share won't be accessed until the exact moment it is needed
… 'Enable insecure guest logons' enabled if their build number is greater than or equal to 10.0.16299.0, which was the build where this change first was implemented.
…d the fact that the use of UNC paths could cause an issue if they are not typed in correctly. Also update the module documentation to use the output from recent tests to reflect recent changes. Shortern the module description and update its stability rating. Finally add in a reliability rating for the exploit module.
Original Release Notes |
Release NotesNew module |
This module exploits a feature in the DNS service of Windows Server. Users of the DnsAdmins group can set the
ServerLevelPluginDll
value using dnscmd.exe to create a registry key atHKLM\SYSTEM\CurrentControlSet\services\DNS\Parameters\
named
ServerLevelPluginDll
that can be made to point to an arbitrary DLL. After doing so, restarting the service will load the DLLand cause it to execute, providing us with SYSTEM privileges. Increasing WfsDelay is recommended when using a UNC path.
Targets
Windows Server 2003 and above
Verification
use exploit/windows/local/dnsadmin_serverlevelplugindll
set PAYLOAD <payload>
. Payload architecture must be the same as the target systemset LHOST <lhost>
set LPORT <lport>
set SESSION <session_no>
to specify sessionset DLLNAME <dllname>
if you want to name your DLL something other thanmsf.dll
set DLLPATH <dllpath>
if you want to place your DLL somewhere other than%TEMP%
or want to use a UNC pathset MAKEDLL true
if you want to just make the DLL, and not carry out the exploitexploit
to get SYSTEM shell ifMAKEDLL
is set tofalse
, or to write the DLL to the~/.msf4/local
folder ifMAKEDLL
is set totrue
TODO: