Class: WPScan::Finders::DynamicFinder::Version::QueryParameter

Inherits:
Finder
  • Object
show all
Defined in:
lib/wpscan/finders/dynamic_finder/version/query_parameter.rb

Overview

Version finder using QueryParameter method

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Finder

#aggressive, child_class_constant, create_child_class, #passive

Class Method Details

.child_class_constantsHash

Returns:

  • (Hash)


10
11
12
13
14
# File 'lib/wpscan/finders/dynamic_finder/version/query_parameter.rb', line 10

def self.child_class_constants
  @child_class_constants ||= super().merge(
    XPATH: nil, FILES: nil, PATTERN: /(?:v|ver|version)\=(?<v>\d+\.[\.\d]+)/i, CONFIDENCE_PER_OCCURENCE: 10
  )
end

Instance Method Details

#find(response, _opts = {}) ⇒ Array<Version>?

Parameters:

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/wpscan/finders/dynamic_finder/version/query_parameter.rb', line 19

def find(response, _opts = {})
  found = []

  scan_response(response).each do |version_number, occurences|
    found << create_version(
      version_number,
      confidence: self.class::CONFIDENCE_PER_OCCURENCE * occurences.size,
      interesting_entries: occurences
    )
  end

  found.compact
end

#path_patternRegexp

Returns:

  • (Regexp)


56
57
58
# File 'lib/wpscan/finders/dynamic_finder/version/query_parameter.rb', line 56

def path_pattern
  @path_pattern ||= %r{/(?:#{self.class::FILES.join('|')})\z}i
end

#scan_response(response) ⇒ Hash

Parameters:

Returns:

  • (Hash)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wpscan/finders/dynamic_finder/version/query_parameter.rb', line 35

def scan_response(response)
  found = {}

  target.in_scope_uris(response, xpath) do |uri|
    next unless uri.path =~ path_pattern && uri.query&.match(self.class::PATTERN)

    version = Regexp.last_match[:v].to_s

    found[version] ||= []
    found[version] << uri.to_s
  end

  found
end

#xpathString

Returns:

  • (String)


51
52
53
# File 'lib/wpscan/finders/dynamic_finder/version/query_parameter.rb', line 51

def xpath
  @xpath ||= self.class::XPATH || '//link[@href]/@href|//script[@src]/@src'
end