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
-
#fingerprint(fingerprints, opts = {}) {|Mixed, String, String| ... } ⇒ Object
Format should be like 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.
-
#hexdigest(body) ⇒ String
The hashed value for the given body.
- #request_params ⇒ Hash
Instance Method Details
#fingerprint(fingerprints, opts = {}) {|Mixed, String, String| ... } ⇒ Object
Format should be like 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
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 = {}) (opts.merge(total: fingerprints.size)) fingerprints.each do |path, f| url = target.url(path.dup) request = browser.forge_request(url, request_params) request.on_complete do |res| .increment 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.
54 55 56 |
# File 'lib/cms_scanner/finders/finder/fingerprinter.rb', line 54 def hexdigest(body) Digest::MD5.hexdigest(body) end |
#request_params ⇒ Hash
49 50 51 |
# File 'lib/cms_scanner/finders/finder/fingerprinter.rb', line 49 def request_params {} end |