Class: TLSmap::App::Extractor::Tlsx

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

Overview

Parsing tlsx

Class Method Summary collapse

Class Method Details

.extract_cipher(json_data) ⇒ Array<String>

Extract the ciphers from the tlsx output file

Parameters:

  • json_data (Hash)

    Ruby hash of the parsed JSON

Returns:

  • (Array<String>)

    Cipher array (IANA names)



294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/tls_map/app/extractor/extractor.rb', line 294

def extract_cipher(json_data) # rubocop:disable Metrics/MethodLength
  raw = {
    'SSL2.0' => [], 'SSL3.0' => [],
    'TLS1.0' => [], 'TLS1.1' => [], 'TLS1.2' => [], 'TLS1.3' => []
  }
  json_data['cipher_enum'].each do |version|
    next if version['ciphers'].nil?

    version['ciphers'].each do |cipher|
      raw[id2prot(version['version'])].push(cipher)
    end
  end
  raw.transform_values(&:uniq)
end

.id2prot(id) ⇒ String

Convert tlsx protocol id to protocol name in TLSmap format

Parameters:

  • id (String)

    tlsx protocol id

Returns:

  • (String)

    protocol name in TLSmap format



312
313
314
315
316
317
318
# File 'lib/tls_map/app/extractor/extractor.rb', line 312

def id2prot(id)
  prot = {
    'ssl30' => 'SSL3.0', 'tls10' => 'TLS1.0',
    'tls11' => 'TLS1.1', 'tls12' => 'TLS1.2', 'tls13' => 'TLS1.3'
  }
  prot[id]
end

.parse(file) ⇒ Array<String>

Extract the ciphers from the tlsx output file

Parameters:

Returns:

  • (Array<String>)

    Cipher array (IANA names)



286
287
288
289
# File 'lib/tls_map/app/extractor/extractor.rb', line 286

def parse(file)
  data = Utils.json_load_file(file)
  extract_cipher(data)
end