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

Inherits:
Object
  • Object
show all
Defined in:
lib/tls_map/app/extractor/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)



166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/tls_map/app/extractor/extractor.rb', line 166

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)



156
157
158
159
# File 'lib/tls_map/app/extractor/extractor.rb', line 156

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