Skip to content

Commit adb4c89

Browse files
author
HD Moore
committed
Add a scanner module for CVE-2013-0156
1 parent 52157b9 commit adb4c89

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Auxiliary
11+
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Auxiliary::Scanner
14+
15+
def initialize(info={})
16+
super(update_info(info,
17+
'Name' => 'Ruby on Rails XML Processor YAML Deserialization Scanner',
18+
'Description' => %q{
19+
This module attempts to identify Ruby on Rails instances vulnerable to
20+
an arbitrary object instantiation flaw in the XML request processor.
21+
},
22+
'Author' => 'hdm',
23+
'License' => MSF_LICENSE,
24+
'References' =>
25+
[
26+
['CVE', '2013-0156'],
27+
['URL', 'https://community.rapid7.com/community/metasploit/blog/2013/01/09/serialization-mischief-in-ruby-land-cve-2013-0156']
28+
]
29+
))
30+
31+
register_options(
32+
OptString.new('URIPATH', [true, "The URI to test", "/"])
33+
], self.class)
34+
end
35+
36+
def send_probe(ptype, pdata)
37+
odata = %Q^<?xml version="1.0" encoding="UTF-8"?>\n<probe type="#{ptype}"><![CDATA[\n#{pdata}\n]]></probe>^
38+
begin
39+
res = send_request_cgi({
40+
'uri' => datastore['URIPATH'] || "/",
41+
'method' => 'POST',
42+
'ctype' => 'application/xml',
43+
'data' => odata
44+
}, 25)
45+
rescue ::Timeout::Error
46+
nil
47+
end
48+
end
49+
50+
def run_host(ip)
51+
52+
res1 = send_probe("string", "hello")
53+
res2 = send_probe("yaml", "--- !ruby/object:Time {}\n")
54+
res3 = send_probe("yaml", "--- !ruby/object:\x00")
55+
56+
unless res1
57+
vprint_status("#{rhost}:#{rport} No reply to the initial XML request")
58+
return
59+
end
60+
61+
unless res2
62+
vprint_status("#{rhost}:#{rport} No reply to the initial YAML probe")
63+
return
64+
end
65+
66+
unless res3
67+
vprint_status("#{rhost}:#{rport} No reply to the second YAML probe")
68+
return
69+
end
70+
71+
if res1.code.to_s =~ /^[45]/
72+
vprint_status("#{rhost}:#{rport} The server replied with #{res1.code} for our initial XML request, double check URIPATH")
73+
end
74+
75+
if res2.code.to_s =~ /^[23]/ and res3.code != res2.code and res3.code != 200
76+
print_good("#{rhost}:#{rport} is likely vulnerable due to a #{res3.code} reply for invalid YAML")
77+
report_vuln({
78+
:host => rhost,
79+
:port => rport,
80+
:proto => 'tcp',
81+
:name => self.name,
82+
:info => "Module triggered a #{res3.code} reply",
83+
:refs => self.references
84+
})
85+
else
86+
vprint_status("#{rhost}:#{rport} is not likely to be vulnerable or URIPATH must be set")
87+
end
88+
end
89+
90+
end

0 commit comments

Comments
 (0)