Module: CMSScanner::Finders::Finder::Fingerprinter

Defined in:
lib/cms_scanner/finders/finder/fingerprinter.rb

Overview

Module to provide an easy way to fingerprint things such as versions

Instance Method Summary collapse

Instance Method Details

#fingerprint(fingerprints, opts = {}) {|Mixed, String, String| ... } ⇒ Object

Format should be the following: {

file_path_1: {
  md5_hash_1: version_1,
  md5_hash_2: [version_2]
},
file_path_2: {
  md5_hash_3: [version_1, version_2],
  md5_hash_4: version_3
}

} Note that the version can either be an array or a string

Parameters:

  • fingerprints (Hash)

    The fingerprints

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :show_progression (Boolean)

    Wether or not to display the progress bar

Yields:

  • (Mixed, String, String)

    version/s, url, hash The version associated to the fingerprint of the url



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cms_scanner/finders/finder/fingerprinter.rb', line 25

def fingerprint(fingerprints, opts = {})
  bar = progress_bar(total: fingerprints.size) if opts[:show_progression]

  fingerprints.each do |path, f|
    url     = target.url(path.dup)
    request = browser.forge_request(url, request_params)

    request.on_complete do |res|
      bar.progress += 1 if opts[:show_progression]

      md5sum = hexdigest(res.body)

      next unless f.key?(md5sum)

      yield f[md5sum], url, md5sum
    end

    hydra.queue(request)
  end

  hydra.run
end

#hexdigest(body) ⇒ String

Returns The hashed value for the given body.

Returns:

  • (String)

    The hashed value for the given body



54
55
56
# File 'lib/cms_scanner/finders/finder/fingerprinter.rb', line 54

def hexdigest(body)
  Digest::MD5.hexdigest(body)
end

#request_paramsHash

Returns:

  • (Hash)


49
50
51
# File 'lib/cms_scanner/finders/finder/fingerprinter.rb', line 49

def request_params
  {}
end