@@ -32,7 +32,7 @@ def initialize(info={})
32
32
33
33
register_options (
34
34
[
35
- OptString . new ( 'STOP_ON_SUCCESS' , [ true , ' Stop guessing when a credential works for a host' , true ] )
35
+ OptBool . new ( 'STOP_ON_SUCCESS' , [ true , " Stop guessing when a credential works for a host" , true ] )
36
36
] , self . class )
37
37
38
38
end
@@ -125,7 +125,6 @@ def do_login(user, pass)
125
125
126
126
if not res or res . code == 401
127
127
vprint_error ( "#{ rhost } :#{ rport } - FAILED LOGIN - #{ user . inspect } :#{ pass . inspect } with code #{ res . code } " )
128
- return :skip_pass
129
128
else
130
129
print_good ( "#{ rhost } :#{ rport } - SUCCESSFUL LOGIN - #{ user . inspect } :#{ pass . inspect } " )
131
130
@@ -168,20 +167,22 @@ def collect_info(user, pass)
168
167
}
169
168
} )
170
169
171
- release_ver = JSON . parse ( res . body ) [ "release" ]
172
- product_name = JSON . parse ( res . body ) [ "product" ]
170
+ if res and res . body
171
+ release_ver = JSON . parse ( res . body ) [ "release" ]
172
+ product_name = JSON . parse ( res . body ) [ "product" ]
173
173
174
- vprint_status ( "#{ rhost } :#{ rport } - Collecting device platform info..." )
175
- print_good ( "#{ rhost } :#{ rport } - Release version: '#{ release_ver } ', Product Name: '#{ product_name } '" )
174
+ vprint_status ( "#{ rhost } :#{ rport } - Collecting device platform info..." )
175
+ vprint_good ( "#{ rhost } :#{ rport } - Release version: '#{ release_ver } ', Product Name: '#{ product_name } '" )
176
176
177
- report_note (
178
- :host => rhost ,
179
- :proto => 'tcp' ,
180
- :port => rport ,
181
- :sname => "RFCode Reader" ,
182
- :data => 'Release Version: #{release_ver}, Product: #{product_name}' ,
183
- :type => 'Info'
184
- )
177
+ report_note (
178
+ :host => rhost ,
179
+ :proto => 'tcp' ,
180
+ :port => rport ,
181
+ :sname => "RFCode Reader" ,
182
+ :data => "Release Version: #{ release_ver } , Product: #{ product_name } " ,
183
+ :type => 'Info'
184
+ )
185
+ end
185
186
186
187
res = send_request_cgi (
187
188
{
@@ -194,19 +195,20 @@ def collect_info(user, pass)
194
195
}
195
196
} )
196
197
197
- userlist = JSON . parse ( res . body )
198
- vprint_status ( "#{ rhost } :#{ rport } - Collecting user list..." )
199
- print_good ( "#{ rhost } :#{ rport } - User list & role: #{ userlist } " )
200
-
201
- report_note (
202
- :host => rhost ,
203
- :proto => 'tcp' ,
204
- :port => rport ,
205
- :sname => "RFCode Reader" ,
206
- :data => 'User List & Roles: #{userlist}' ,
207
- :type => 'Info'
208
- )
198
+ if res and res . body
199
+ userlist = JSON . parse ( res . body )
200
+ vprint_status ( "#{ rhost } :#{ rport } - Collecting user list..." )
201
+ vprint_good ( "#{ rhost } :#{ rport } - User list & role: #{ userlist } " )
209
202
203
+ report_note (
204
+ :host => rhost ,
205
+ :proto => 'tcp' ,
206
+ :port => rport ,
207
+ :sname => "RFCode Reader" ,
208
+ :data => "User List & Roles: #{ userlist } " ,
209
+ :type => 'Info'
210
+ )
211
+ end
210
212
211
213
res = send_request_cgi (
212
214
{
@@ -219,19 +221,27 @@ def collect_info(user, pass)
219
221
}
220
222
} )
221
223
222
- eth0_info = JSON . parse ( res . body ) [ "eth0" ]
223
- vprint_status ( "#{ rhost } :#{ rport } - Collecting interface info..." )
224
- print_good ( "#{ rhost } :#{ rport } - Interface eth0 info: #{ eth0_info } " )
225
-
226
- report_note (
227
- :host => rhost ,
228
- :proto => 'tcp' ,
229
- :port => rport ,
230
- :sname => "RFCode Reader" ,
231
- :data => 'Interface eth0: #{eth0_info}' ,
232
- :type => 'Info'
233
- )
224
+ if res and res . body
225
+ eth0_info = JSON . parse ( res . body ) [ "eth0" ]
226
+ vprint_status ( "#{ rhost } :#{ rport } - Collecting interface info..." )
227
+ vprint_good ( "#{ rhost } :#{ rport } - Interface eth0 info: #{ eth0_info } " )
228
+
229
+ report_note (
230
+ :host => rhost ,
231
+ :proto => 'tcp' ,
232
+ :port => rport ,
233
+ :sname => "RFCode Reader" ,
234
+ :data => "Interface eth0: #{ eth0_info } " ,
235
+ :type => 'Info'
236
+ )
237
+ end
234
238
239
+ return
240
+ rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError , ::Errno ::EPIPE
241
+ vprint_error ( "#{ rhost } :#{ rport } - HTTP Connection Failed while collecting info" )
242
+ return
243
+ rescue JSON ::ParserError
244
+ vprint_error ( "#{ rhost } :#{ rport } - Unable to parse JSON response while collecting info" )
235
245
return
236
246
end
237
247
end
0 commit comments