class SSHScan::Result
Public Class Methods
new()
click to toggle source
# File lib/ssh_scan/result.rb, line 9 def initialize() @version = SSHScan::VERSION @keys = nil @duplicate_host_key_ips = Set.new() @compliance = {} end
Public Instance Methods
auth_methods()
click to toggle source
# File lib/ssh_scan/result.rb, line 184 def auth_methods() @auth_methods || [] end
auth_methods=(auth_methods)
click to toggle source
# File lib/ssh_scan/result.rb, line 156 def auth_methods=(auth_methods) @auth_methods = auth_methods end
compliance_policy()
click to toggle source
# File lib/ssh_scan/result.rb, line 192 def compliance_policy @compliance["policy"] end
compliance_recommendations()
click to toggle source
# File lib/ssh_scan/result.rb, line 204 def compliance_recommendations @compliance["recommendations"] end
compliance_references()
click to toggle source
# File lib/ssh_scan/result.rb, line 200 def compliance_references @compliance["references"] end
compliant?()
click to toggle source
# File lib/ssh_scan/result.rb, line 196 def compliant? @compliance["compliant"] end
compression_algorithms_client_to_server()
click to toggle source
# File lib/ssh_scan/result.rb, line 112 def compression_algorithms_client_to_server @hex_result_hash ? @hex_result_hash[:compression_algorithms_client_to_server] : [] end
compression_algorithms_server_to_client()
click to toggle source
# File lib/ssh_scan/result.rb, line 116 def compression_algorithms_server_to_client @hex_result_hash ? @hex_result_hash[:compression_algorithms_server_to_client] : [] end
dns_keys()
click to toggle source
# File lib/ssh_scan/result.rb, line 168 def dns_keys @dns_keys end
dns_keys=(dns_keys)
click to toggle source
# File lib/ssh_scan/result.rb, line 172 def dns_keys=(dns_keys) @dns_keys = dns_keys end
duplicate_host_key_ips()
click to toggle source
# File lib/ssh_scan/result.rb, line 180 def duplicate_host_key_ips @duplicate_host_key_ips.to_a end
duplicate_host_key_ips=(duplicate_host_key_ips)
click to toggle source
# File lib/ssh_scan/result.rb, line 176 def duplicate_host_key_ips=(duplicate_host_key_ips) @duplicate_host_key_ips = duplicate_host_key_ips end
encryption_algorithms_client_to_server()
click to toggle source
# File lib/ssh_scan/result.rb, line 96 def encryption_algorithms_client_to_server @hex_result_hash ? @hex_result_hash[:encryption_algorithms_client_to_server] : [] end
encryption_algorithms_server_to_client()
click to toggle source
# File lib/ssh_scan/result.rb, line 100 def encryption_algorithms_server_to_client @hex_result_hash ? @hex_result_hash[:encryption_algorithms_server_to_client] : [] end
end_time()
click to toggle source
# File lib/ssh_scan/result.rb, line 152 def end_time @end_time end
error()
click to toggle source
# File lib/ssh_scan/result.rb, line 226 def error @error end
error=(error)
click to toggle source
# File lib/ssh_scan/result.rb, line 214 def error=(error) @error = error.to_s end
error?()
click to toggle source
# File lib/ssh_scan/result.rb, line 222 def error? !@error.nil? end
grade()
click to toggle source
# File lib/ssh_scan/result.rb, line 234 def grade @compliance["grade"] end
grade=(grade)
click to toggle source
# File lib/ssh_scan/result.rb, line 230 def grade=(grade) @compliance["grade"] = grade end
hostname()
click to toggle source
# File lib/ssh_scan/result.rb, line 52 def hostname() @hostname || "" end
hostname=(hostname)
click to toggle source
# File lib/ssh_scan/result.rb, line 48 def hostname=(hostname) @hostname = hostname end
ip()
click to toggle source
# File lib/ssh_scan/result.rb, line 20 def ip @ip end
ip=(ip)
click to toggle source
# File lib/ssh_scan/result.rb, line 24 def ip=(ip) unless ip.is_a?(String) && ip.ip_addr? raise ArgumentError, "Invalid attempt to set IP to a non-IP address value" end @ip = ip end
key_algorithms()
click to toggle source
# File lib/ssh_scan/result.rb, line 88 def key_algorithms @hex_result_hash ? @hex_result_hash[:key_algorithms] : [] end
keys()
click to toggle source
# File lib/ssh_scan/result.rb, line 160 def keys @keys || {} end
keys=(keys)
click to toggle source
# File lib/ssh_scan/result.rb, line 164 def keys=(keys) @keys = keys end
languages_client_to_server()
click to toggle source
# File lib/ssh_scan/result.rb, line 120 def languages_client_to_server @hex_result_hash ? @hex_result_hash[:languages_client_to_server] : [] end
languages_server_to_client()
click to toggle source
# File lib/ssh_scan/result.rb, line 124 def languages_server_to_client @hex_result_hash ? @hex_result_hash[:languages_server_to_client] : [] end
mac_algorithms_client_to_server()
click to toggle source
# File lib/ssh_scan/result.rb, line 104 def mac_algorithms_client_to_server @hex_result_hash ? @hex_result_hash[:mac_algorithms_client_to_server] : [] end
mac_algorithms_server_to_client()
click to toggle source
# File lib/ssh_scan/result.rb, line 108 def mac_algorithms_server_to_client @hex_result_hash ? @hex_result_hash[:mac_algorithms_server_to_client] : [] end
os_guess_common()
click to toggle source
# File lib/ssh_scan/result.rb, line 68 def os_guess_common self.banner.os_guess.common end
os_guess_cpe()
click to toggle source
# File lib/ssh_scan/result.rb, line 72 def os_guess_cpe self.banner.os_guess.cpe end
port()
click to toggle source
# File lib/ssh_scan/result.rb, line 32 def port @port end
port=(port)
click to toggle source
# File lib/ssh_scan/result.rb, line 36 def port=(port) unless port.is_a?(Integer) && port > 0 && port <= 65535 raise ArgumentError, "Invalid attempt to set port to a non-port value" end @port = port end
scan_duration()
click to toggle source
# File lib/ssh_scan/result.rb, line 144 def scan_duration if start_time.nil? || end_time.nil? return nil end end_time - start_time end
server_host_key_algorithms()
click to toggle source
# File lib/ssh_scan/result.rb, line 92 def server_host_key_algorithms @hex_result_hash ? @hex_result_hash[:server_host_key_algorithms] : [] end
set_client_attributes(client)
click to toggle source
# File lib/ssh_scan/result.rb, line 208 def set_client_attributes(client) self.ip = client.ip self.port = client.port || 22 self.banner = client.banner || SSHScan::Banner.new("") end
set_compliance=(compliance)
click to toggle source
# File lib/ssh_scan/result.rb, line 188 def set_compliance=(compliance) @compliance = compliance end
set_end_time()
click to toggle source
# File lib/ssh_scan/result.rb, line 140 def set_end_time @end_time = Time.now end
set_kex_result(kex_result)
click to toggle source
# File lib/ssh_scan/result.rb, line 128 def set_kex_result(kex_result) @hex_result_hash = kex_result.to_hash end
set_start_time()
click to toggle source
# File lib/ssh_scan/result.rb, line 132 def set_start_time @start_time = Time.now end
ssh_lib_guess_common()
click to toggle source
# File lib/ssh_scan/result.rb, line 76 def ssh_lib_guess_common self.banner.ssh_lib_guess.common end
ssh_lib_guess_cpe()
click to toggle source
# File lib/ssh_scan/result.rb, line 80 def ssh_lib_guess_cpe self.banner.ssh_lib_guess.cpe end
ssh_version()
click to toggle source
# File lib/ssh_scan/result.rb, line 64 def ssh_version self.banner.ssh_version end
start_time()
click to toggle source
# File lib/ssh_scan/result.rb, line 136 def start_time @start_time end
to_hash()
click to toggle source
# File lib/ssh_scan/result.rb, line 238 def to_hash hashed_object = { "ssh_scan_version" => self.version, "ip" => self.ip, "hostname" => self.hostname, "port" => self.port, "server_banner" => self.banner.to_s, "ssh_version" => self.ssh_version, "os" => self.os_guess_common, "os_cpe" => self.os_guess_cpe, "ssh_lib" => self.ssh_lib_guess_common, "ssh_lib_cpe" => self.ssh_lib_guess_cpe, "key_algorithms" => self.key_algorithms, "encryption_algorithms_client_to_server" => self.encryption_algorithms_client_to_server, "encryption_algorithms_server_to_client" => self.encryption_algorithms_server_to_client, "mac_algorithms_client_to_server" => self.mac_algorithms_client_to_server, "mac_algorithms_server_to_client" => self.mac_algorithms_server_to_client, "compression_algorithms_client_to_server" => self.compression_algorithms_client_to_server, "compression_algorithms_server_to_client" => self.compression_algorithms_server_to_client, "languages_client_to_server" => self.languages_client_to_server, "languages_server_to_client" => self.languages_server_to_client, "auth_methods" => self.auth_methods, "keys" => self.keys, "dns_keys" => self.dns_keys, "duplicate_host_key_ips" => self.duplicate_host_key_ips.uniq, "compliance" => @compliance, "start_time" => self.start_time, "end_time" => self.end_time, "scan_duration_seconds" => self.scan_duration, } if self.error? hashed_object["error"] = self.error end hashed_object end
to_json()
click to toggle source
# File lib/ssh_scan/result.rb, line 276 def to_json self.to_hash.to_json end
unset_error()
click to toggle source
# File lib/ssh_scan/result.rb, line 218 def unset_error @error = nil end
version()
click to toggle source
# File lib/ssh_scan/result.rb, line 16 def version @version end