Class: SSLScan::Commands::Command

Inherits:
Object
  • Object
show all
Includes:
FastGettext::Translation
Defined in:
lib/ssl_scan/commands/command.rb

Direct Known Subclasses

Host

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results = [], stream = nil) ⇒ Command

Returns a new instance of Command.



7
8
9
10
11
# File 'lib/ssl_scan/commands/command.rb', line 7

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

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/ssl_scan/commands/command.rb', line 4

def errors
  @errors
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/ssl_scan/commands/command.rb', line 4

def options
  @options
end

#resultsObject

Returns the value of attribute results.



4
5
6
# File 'lib/ssl_scan/commands/command.rb', line 4

def results
  @results
end

#streamObject

Returns the value of attribute stream.



4
5
6
# File 'lib/ssl_scan/commands/command.rb', line 4

def stream
  @stream
end

Instance Method Details

#executeObject



13
14
15
# File 'lib/ssl_scan/commands/command.rb', line 13

def execute
  raise "Implement"
end

#write_ciphers(scanner = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ssl_scan/commands/command.rb', line 33

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

#write_header(host, port = 443) ⇒ Object

Display Methods



18
19
20
# File 'lib/ssl_scan/commands/command.rb', line 18

def write_header(host, port=443)
  stream.printf _("\nTesting SSL server %{host} on port %{port}\n") % { host: host, port: port }
end

#write_preferred_ciphers(scanner) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/ssl_scan/commands/command.rb', line 22

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