lib/apullo/fingerprints/ssh.rb in apullo-0.1.3 vs lib/apullo/fingerprints/ssh.rb in apullo-0.1.4

- old
+ new

@@ -6,29 +6,33 @@ module Fingerprint class SSH < Base DEFAULT_OPTIONS = { "timeout" => 3 }.freeze DEFAULT_PORT = 22 - def results - @results ||= pluck - end - private - def pluck + def build_results + pluck_fingerprints + end + + def pluck_fingerprints result = scan keys = result.dig("keys") || [] keys.map do |cipher, data| + raw = data.dig("raw") fingerprints = data.dig("fingerprints") || [] - normalized = fingerprints.map do |hash, value| + normalized_fingerprints = fingerprints.map do |hash, value| [hash, value.delete(":")] end.to_h - [cipher, normalized] + [ + cipher, + { raw: raw, fingerprints: normalized_fingerprints } + ] end.to_h end def scan - return {} unless target.ipv4 + return {} unless target.host engine = SSHScan::ScanEngine.new dest = "#{target.host}:#{DEFAULT_PORT}" result = engine.scan_target(dest, DEFAULT_OPTIONS) result.to_hash