fixing some refactoring bugs

This commit is contained in:
Conor Horan-Kates 2016-10-15 09:31:22 -07:00
parent a48cec0de4
commit 4b909d144c

View File

@ -82,6 +82,8 @@ end
# #
## main() ## main()
address = ARGV.first
if address.nil? if address.nil?
puts sprintf('usage: %s <ipaddress/range>', __FILE__) puts sprintf('usage: %s <ipaddress/range>', __FILE__)
puts sprintf(' %s 192.168.1.42', __FILE__) puts sprintf(' %s 192.168.1.42', __FILE__)
@ -135,8 +137,8 @@ targets.each do |target|
begin begin
puts sprintf(' trying pin[%s]', pin) puts sprintf(' trying pin[%s]', pin)
response = check_pin(url, pin) response = app.check_pin(url, pin)
responses << { :ip => target, :pin => pin, :results => response } app.responses << { :ip => target, :pin => pin, :results => response }
if response if response
app.add_pin_to_db(target, pin) app.add_pin_to_db(target, pin)
@ -149,20 +151,20 @@ targets.each do |target|
rescue => e rescue => e
puts sprintf('ERROR: something bad happened on pin[%s]: [%s:%s]', pin, e.class, e.message) puts sprintf('ERROR: something bad happened on pin[%s]: [%s:%s]', pin, e.class, e.message)
errors << { :exception => e, :pin => pin } app.errors << { :exception => e, :pin => pin }
end end
end end
unless errors.empty? unless app.errors.empty?
errors.each do |e| app.errors.each do |e|
puts sprintf('ERROR: pin[%s] trace[%s]', e[:pin], e[:exception]) puts sprintf('ERROR: pin[%s] trace[%s]', e[:pin], e[:exception])
end end
puts sprintf('ERROR: [%d] total errors', errors.size) puts sprintf('ERROR: [%d] total errors', app.errors.size)
else else
# TODO this is going to get lost in the console output when running against multiple targets -- should we stop printing the PINs attempted? # TODO this is going to get lost in the console output when running against multiple targets -- should we stop printing the PINs attempted?
puts sprintf('tested[%s] PINs, found correct one[%s]', responses.size, ) puts sprintf('tested[%s] PINs, found correct one[%s]', app.responses.size, )
end end
end end