Class: TLSmap::App::Extractor::Sslscan2

Inherits:
Object
  • Object
show all
Defined in:
lib/tls_map/extractor.rb

Overview

Parsing sslscan2

Class Method Summary collapse

Class Method Details

.extract_cipher(xml_doc, online = false) ⇒ Array<String>

Extract the ciphers from the sslscan2 output file

Parameters:

  • xml_doc (REXML::Document)

    XML document as returned by REXML::Document

  • online (defaults to: false)

    By default use the offline mode with CLI for better performance. Online mode will use TLSmap::App and fetch upstream resources to get latest updates but is a lot slower.

Returns:

  • (Array<String>)

    Cipher array (IANA names)



162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/tls_map/extractor.rb', line 162

def extract_cipher(xml_doc, online = false) # rubocop:disable Metrics/MethodLength
  raw = {
    'SSL2.0' => [], 'SSL3.0' => [],
    'TLS1.0' => [], 'TLS1.1' => [], 'TLS1.2' => [], 'TLS1.3' => []
  }
  tm = online ? TLSmap::App.new : TLSmap::CLI.new
  xml_doc.root.each_element('//cipher') do |node|
    sslv = node.attributes['sslversion'].gsub('v', '')
    cipher = tm.search(:codepoint, node.attributes['id'][2..], :iana)[:iana]
    raw[sslv].push(cipher)
  end
  raw
end

.parse(file, online = false) ⇒ Array<String>

Extract the ciphers from the sslscan2 output file

Parameters:

  • file (String)

    Path of the sslscan2 output file, beware of the format expected. See TLSmap::App::Extractor

Returns:

  • (Array<String>)

    Cipher array (IANA names)



152
153
154
155
# File 'lib/tls_map/extractor.rb', line 152

def parse(file, online = false)
  doc = REXML::Document.new(File.new(file))
  extract_cipher(doc, online)
end