Class: SSLScan::Commands::Targets

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

Instance Attribute Summary collapse

Attributes inherited from Command

#options, #results

Instance Method Summary collapse

Methods inherited from Command

#display_ciphers, #display_header

Constructor Details

#initialize(filename = "", options) ⇒ Targets

Returns a new instance of Targets.



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

def initialize(filename="", options)
  super()
  @file = File.read(filename)
  @hosts = @file.split("\n").map(&:strip).select { |h| h.length > 0 }
  @options = options
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/ssl_scan/commands/targets.rb', line 5

def file
  @file
end

#hostsObject

Returns the value of attribute hosts.



5
6
7
# File 'lib/ssl_scan/commands/targets.rb', line 5

def hosts
  @hosts
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ssl_scan/commands/targets.rb', line 14

def execute
  hosts.each do |host|
    parts = host.split(":")
    if parts.length == 2
      display_header(parts[0], parts[1])
      scanner = SSLScan::Scanner.new(parts[0], parts[1].to_i)
    else
      display_header(host)
      scanner = SSLScan::Scanner.new(parts[0])
    end
    display_ciphers(scanner)
    @results << scanner.results
  end
end