Class: SSHScan::Result
- Inherits:
-
Object
- Object
- SSHScan::Result
- Defined in:
- lib/ssh_scan/result.rb
Instance Method Summary collapse
- #auth_methods ⇒ Object
- #auth_methods=(auth_methods) ⇒ Object
- #banner ⇒ Object
- #banner=(banner) ⇒ Object
- #compliance_policy ⇒ Object
- #compliance_recommendations ⇒ Object
- #compliance_references ⇒ Object
- #compliant? ⇒ Boolean
- #compression_algorithms_client_to_server ⇒ Object
- #compression_algorithms_server_to_client ⇒ Object
- #cookie ⇒ Object
- #dns_keys ⇒ Object
- #dns_keys=(dns_keys) ⇒ Object
- #duplicate_host_key_ips ⇒ Object
- #duplicate_host_key_ips=(duplicate_host_key_ips) ⇒ Object
- #encryption_algorithms_client_to_server ⇒ Object
- #encryption_algorithms_server_to_client ⇒ Object
- #end_time ⇒ Object
- #error ⇒ Object
- #error=(error) ⇒ Object
- #error? ⇒ Boolean
- #grade ⇒ Object
- #grade=(grade) ⇒ Object
- #hostname ⇒ Object
- #hostname=(hostname) ⇒ Object
-
#initialize ⇒ Result
constructor
A new instance of Result.
- #ip ⇒ Object
- #ip=(ip) ⇒ Object
- #key_algorithms ⇒ Object
- #keys ⇒ Object
- #keys=(keys) ⇒ Object
- #languages_client_to_server ⇒ Object
- #languages_server_to_client ⇒ Object
- #mac_algorithms_client_to_server ⇒ Object
- #mac_algorithms_server_to_client ⇒ Object
- #os_guess_common ⇒ Object
- #os_guess_cpe ⇒ Object
- #port ⇒ Object
- #port=(port) ⇒ Object
- #scan_duration ⇒ Object
- #server_host_key_algorithms ⇒ Object
- #set_client_attributes(client) ⇒ Object
- #set_compliance=(compliance) ⇒ Object
- #set_end_time ⇒ Object
- #set_kex_result(kex_result) ⇒ Object
- #set_start_time ⇒ Object
- #ssh_lib_guess_common ⇒ Object
- #ssh_lib_guess_cpe ⇒ Object
- #ssh_version ⇒ Object
- #start_time ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #unset_error ⇒ Object
- #version ⇒ Object
Constructor Details
Instance Method Details
#auth_methods ⇒ Object
184 185 186 |
# File 'lib/ssh_scan/result.rb', line 184 def auth_methods() @auth_methods || [] end |
#auth_methods=(auth_methods) ⇒ Object
156 157 158 |
# File 'lib/ssh_scan/result.rb', line 156 def auth_methods=(auth_methods) @auth_methods = auth_methods end |
#banner ⇒ Object
44 45 46 |
# File 'lib/ssh_scan/result.rb', line 44 def () @banner || SSHScan::Banner.new("") end |
#banner=(banner) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/ssh_scan/result.rb', line 56 def () unless .is_a?(SSHScan::Banner) raise ArgumentError, "Invalid attempt to set banner with a non-banner object" end @banner = end |
#compliance_policy ⇒ Object
192 193 194 |
# File 'lib/ssh_scan/result.rb', line 192 def compliance_policy @compliance["policy"] end |
#compliance_recommendations ⇒ Object
204 205 206 |
# File 'lib/ssh_scan/result.rb', line 204 def compliance_recommendations @compliance["recommendations"] end |
#compliance_references ⇒ Object
200 201 202 |
# File 'lib/ssh_scan/result.rb', line 200 def compliance_references @compliance["references"] end |
#compliant? ⇒ Boolean
196 197 198 |
# File 'lib/ssh_scan/result.rb', line 196 def compliant? @compliance["compliant"] end |
#compression_algorithms_client_to_server ⇒ Object
112 113 114 |
# 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 ⇒ Object
116 117 118 |
# 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 |
#cookie ⇒ Object
84 85 86 |
# File 'lib/ssh_scan/result.rb', line 84 def @cookie || "" end |
#dns_keys ⇒ Object
168 169 170 |
# File 'lib/ssh_scan/result.rb', line 168 def dns_keys @dns_keys end |
#dns_keys=(dns_keys) ⇒ Object
172 173 174 |
# File 'lib/ssh_scan/result.rb', line 172 def dns_keys=(dns_keys) @dns_keys = dns_keys end |
#duplicate_host_key_ips ⇒ Object
180 181 182 |
# 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) ⇒ Object
176 177 178 |
# 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 ⇒ Object
96 97 98 |
# 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 ⇒ Object
100 101 102 |
# 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 ⇒ Object
152 153 154 |
# File 'lib/ssh_scan/result.rb', line 152 def end_time @end_time end |
#error ⇒ Object
226 227 228 |
# File 'lib/ssh_scan/result.rb', line 226 def error @error end |
#error=(error) ⇒ Object
214 215 216 |
# File 'lib/ssh_scan/result.rb', line 214 def error=(error) @error = error.to_s end |
#error? ⇒ Boolean
222 223 224 |
# File 'lib/ssh_scan/result.rb', line 222 def error? !@error.nil? end |
#grade ⇒ Object
234 235 236 |
# File 'lib/ssh_scan/result.rb', line 234 def grade @compliance["grade"] end |
#grade=(grade) ⇒ Object
230 231 232 |
# File 'lib/ssh_scan/result.rb', line 230 def grade=(grade) @compliance["grade"] = grade end |
#hostname ⇒ Object
52 53 54 |
# File 'lib/ssh_scan/result.rb', line 52 def hostname() @hostname || "" end |
#hostname=(hostname) ⇒ Object
48 49 50 |
# File 'lib/ssh_scan/result.rb', line 48 def hostname=(hostname) @hostname = hostname end |
#ip ⇒ Object
20 21 22 |
# File 'lib/ssh_scan/result.rb', line 20 def ip @ip end |
#ip=(ip) ⇒ Object
24 25 26 27 28 29 30 |
# 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 ⇒ Object
88 89 90 |
# File 'lib/ssh_scan/result.rb', line 88 def key_algorithms @hex_result_hash ? @hex_result_hash[:key_algorithms] : [] end |
#keys ⇒ Object
160 161 162 |
# File 'lib/ssh_scan/result.rb', line 160 def keys @keys || {} end |
#keys=(keys) ⇒ Object
164 165 166 |
# File 'lib/ssh_scan/result.rb', line 164 def keys=(keys) @keys = keys end |
#languages_client_to_server ⇒ Object
120 121 122 |
# 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 ⇒ Object
124 125 126 |
# 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 ⇒ Object
104 105 106 |
# 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 ⇒ Object
108 109 110 |
# 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 ⇒ Object
68 69 70 |
# File 'lib/ssh_scan/result.rb', line 68 def os_guess_common self..os_guess.common end |
#os_guess_cpe ⇒ Object
72 73 74 |
# File 'lib/ssh_scan/result.rb', line 72 def os_guess_cpe self..os_guess.cpe end |
#port ⇒ Object
32 33 34 |
# File 'lib/ssh_scan/result.rb', line 32 def port @port end |
#port=(port) ⇒ Object
36 37 38 39 40 41 42 |
# 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 ⇒ Object
144 145 146 147 148 149 150 |
# 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 ⇒ Object
92 93 94 |
# 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) ⇒ Object
208 209 210 211 212 |
# File 'lib/ssh_scan/result.rb', line 208 def set_client_attributes(client) self.ip = client.ip self.port = client.port || 22 self. = client. || SSHScan::Banner.new("") end |
#set_compliance=(compliance) ⇒ Object
188 189 190 |
# File 'lib/ssh_scan/result.rb', line 188 def set_compliance=(compliance) @compliance = compliance end |
#set_end_time ⇒ Object
140 141 142 |
# File 'lib/ssh_scan/result.rb', line 140 def set_end_time @end_time = Time.now end |
#set_kex_result(kex_result) ⇒ Object
128 129 130 |
# 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 ⇒ Object
132 133 134 |
# File 'lib/ssh_scan/result.rb', line 132 def set_start_time @start_time = Time.now end |
#ssh_lib_guess_common ⇒ Object
76 77 78 |
# File 'lib/ssh_scan/result.rb', line 76 def ssh_lib_guess_common self..ssh_lib_guess.common end |
#ssh_lib_guess_cpe ⇒ Object
80 81 82 |
# File 'lib/ssh_scan/result.rb', line 80 def ssh_lib_guess_cpe self..ssh_lib_guess.cpe end |
#ssh_version ⇒ Object
64 65 66 |
# File 'lib/ssh_scan/result.rb', line 64 def ssh_version self..ssh_version end |
#start_time ⇒ Object
136 137 138 |
# File 'lib/ssh_scan/result.rb', line 136 def start_time @start_time end |
#to_hash ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# 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..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 ⇒ Object
276 277 278 |
# File 'lib/ssh_scan/result.rb', line 276 def to_json self.to_hash.to_json end |
#unset_error ⇒ Object
218 219 220 |
# File 'lib/ssh_scan/result.rb', line 218 def unset_error @error = nil end |
#version ⇒ Object
16 17 18 |
# File 'lib/ssh_scan/result.rb', line 16 def version @version end |