-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Add module for CVE-2022-21999 and More Railgun Definitions #16344
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clean up code, add EnumPrinters definitions
bwatters-r7
reviewed
Mar 15, 2022
bwatters-r7
reviewed
Mar 15, 2022
modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb
Outdated
Show resolved
Hide resolved
Co-authored-by: Brendan <bwatters@rapid7.com>
Release NotesThis PR adds a module targeting SpoolFool (AKA CVE-2022-21999), a local privilege escalation targeting the spool service on Windows 10 or Server builds 18362 or earlier. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The Windows Print Spooler has a privilege escalation vulnerability that can be leveraged to achieve code execution as SYSTEM.
The
SpoolDirectory
, a configuration setting that holds the path that a printer's spooled jobs are sent to, is writable for all users, and it can be configured viaSetPrinterDataEx()
provided the caller has thePRINTER_ACCESS_ADMINISTER
permission. If theSpoolDirectory
path does not exist, it will be created once the print spooler reinitializes.Calling
SetPrinterDataEx()
with theCopyFiles\
registry key will load the dll passed in as thepData
argument, meaning that writing a dll to theSpoolDirectory
location can be loaded by the print spooler.Using a directory junction and UNC path for the
SpoolDirectory
, the exploit writes a payload toC:\Windows\System32\spool\drivers\x64\4
and loads it by callingSetPrinterDataEx()
, resulting in code execution as SYSTEM.Verification
use exploit/windows/local/cve_2022_21999_spoolfool_privesc
set SESSION <sess_no>
set LHOST <lhost>
set LPORT <port_no>
run
Notes
This exploit can succeed a max of two times since the Print Spooler will not automatically restart after two crashes. This could be fixed with a reboot, but I decided not to add that in since that's pretty invasive
Windows 7 and Windows Server 2016 are also technically vulnerable, but not supported by this module. Windows 7 does not appear to have the
AppVTerminator.dll
that's used to force a crash in the Print Spooler, so the only other option would be rebooting, which I didn't add for the reason mentioned above. The one version of 2016 I tested only allowedadministrators
to open an existing printer / add a new oneGetting a session literally takes minutes, and I haven't figured out a way to shorten that. The
Sending stage..
is pretty immediate, but getting an actual meterpreter prompt takes minutesThis exploit does not use all of the definitions, constants, etc. added, but I figured they may be useful to add in now for potential modules later down the line
Scenarios
Windows 10 21H2 (Build 19044.1288)