Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/app/finders/plugins/xpath.rb
485 views
1
# frozen_string_literal: true
2
3
module WPScan
4
module Finders
5
module Plugins
6
# Plugins finder from the Dynamic Finder 'Xpath'
7
class Xpath < Finders::DynamicFinder::WpItems::Finder
8
DEFAULT_CONFIDENCE = 40
9
10
# @param [ Hash ] opts The options from the #passive, #aggressive methods
11
# @param [ Typhoeus::Response ] response
12
# @param [ String ] slug
13
# @param [ String ] klass
14
# @param [ Hash ] config The related dynamic finder config hash
15
#
16
# @return [ Plugin ] The detected plugin in the response, related to the config
17
def process_response(opts, response, slug, klass, config)
18
response.html.xpath(config['xpath']).each do |node|
19
next if config['pattern'] && !node.text.match(config['pattern'])
20
21
return Model::Plugin.new(
22
slug,
23
target,
24
opts.merge(found_by: found_by(klass), confidence: config['confidence'] || DEFAULT_CONFIDENCE)
25
)
26
end
27
end
28
end
29
end
30
end
31
end
32
33