Sha256: ff99d3d76b57791297af7cc0aa5cc4a0ed509649173fbc2a4f835fdfb6481804

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require "stringio"

module SSLScan
  module Commands
    class Command
      attr_accessor :results, :options, :stream, :errors

      def initialize(results=[], stream=nil)
        @results = results
        @errors  = []
        @stream  = stream || STDOUT
      end

      def execute
        raise "Implement"
      end

      # Display Methods
      def write_header(host, port=443)
        stream.printf "\nTesting SSL server #{host} on port #{port}"
      end

      def write_preferred_ciphers(scanner)
        stream.printf("\nServer Preferred Cipher(s)\n")
        ciphers = scanner.get_preferred_ciphers
        ciphers.each do |c|
          if c.length > 1 && !c[1].empty?
            stream.printf("%12s %10s %s\n", c[0], "#{c[1][3]} bits", c[1][0])
          end
        end
        stream.printf("\n")
      end

      def write_ciphers(scanner=nil)
        stream.printf "\nSupported Server Cipher(s):\n"

        sslv = options.only_ssl2 || options.only_ssl3 || options.only_tls1 || false
        
        if sslv
          scanner.scan_ssl_version(sslv) do |ssl_version, cipher_name, alg_length, status|
            unless options.no_failed && status == :failed
              stream.printf("%12s %10s %10s %s\n", status, ssl_version, "#{alg_length} bits",  cipher_name)
            end
          end
        else
          scanner.scan do |ssl_version, cipher_name, alg_length, status|
            unless options.no_failed && status == :failed
              stream.printf "%12s %10s %10s %s\n", status, ssl_version, "#{alg_length} bits",  cipher_name
            end
          end
        end
        stream.printf("\n")
        scanner
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ssl_scan-0.0.5 lib/ssl_scan/commands/command.rb
ssl_scan-0.0.4 lib/ssl_scan/commands/command.rb