Class: SSHScan::ScanEngine
- Inherits:
-
Object
- Object
- SSHScan::ScanEngine
- Defined in:
- lib/ssh_scan/scan_engine.rb
Instance Method Summary collapse
-
#scan(ip, port, policy) ⇒ Object
TODO: this is pretty crude, clean this up a bit.
Instance Method Details
#scan(ip, port, policy) ⇒ Object
TODO: this is pretty crude, clean this up a bit
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ssh_scan/scan_engine.rb', line 8 def scan(ip, port, policy) # Do initial protocol exchange sock = TCPSocket.new(ip, port) server_protocol = sock.gets sock.puts(SSHScan::Constants::DEFAULT_PROTOCOL) # Perform Key Initialization Exchange sock.write(SSHScan::Constants::DEFAULT_KEY_INIT_RAW) resp = sock.read(4) resp += sock.read(resp.unpack("N").first) kex_init_response = SSHScan::KeyExchangeInit.read(resp) sock.close # Assemble and print results result = { :ip => ip, :port => port, :server_banner => server_protocol.chomp } result.merge!(kex_init_response.to_hash) # Evaluate for Policy Compliance policy_mgr = SSHScan::PolicyManager.new(result, policy) result['compliance'] = policy_mgr.compliance_results return result end |