Class: SSLScan::Commands::Host

Inherits:
Command
  • Object
show all
Defined in:
lib/ssl_scan/commands/host.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#errors, #results, #stream

Instance Method Summary collapse

Methods inherited from Command

#write_ciphers, #write_header, #write_preferred_ciphers

Constructor Details

#initialize(hostname, options = {}, output = nil) ⇒ Host

Returns a new instance of Host.



6
7
8
9
10
# File 'lib/ssl_scan/commands/host.rb', line 6

def initialize(hostname, options={}, output=nil)
  super([], output)
  @hostname = hostname
  @options  = options
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



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

def hostname
  @hostname
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ssl_scan/commands/host.rb', line 12

def execute
  parts = hostname.split(":")
  if parts.length == 2
    scanner = SSLScan::Scanner.new(parts[0], parts[1].to_i)
  else
    scanner = SSLScan::Scanner.new(parts[0])
  end
  # If we can't get any SSL connection, then don't bother testing
  # individual ciphers.
  if [:rejected, :failed].include?(scanner.test_ssl) and [:rejected, :failed].include?(scanner.test_tls)
    errors << "SSL Connection failed"
    return false
  end

  if parts.length == 2
    write_header(parts[0], parts[1])
  else
    write_header(parts[0])
  end

  if options.only_cert
    scanner.get_first_valid_cert
    @results << scanner.results
  else
    write_ciphers(scanner)
    write_preferred_ciphers(scanner)
    @results << scanner.results
  end
end