Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/app/finders/timthumbs/known_locations.rb
485 views
1
# frozen_string_literal: true
2
3
module WPScan
4
module Finders
5
module Timthumbs
6
# Known Locations Timthumbs Finder
7
# Note: A vulnerable version, 2.8.13 can be found here:
8
# https://github.com/GabrielGil/TimThumb/blob/980c3d6a823477761570475e8b83d3e9fcd2d7ae/timthumb.php
9
class KnownLocations < CMSScanner::Finders::Finder
10
include CMSScanner::Finders::Finder::Enumerator
11
12
# @return [ Array<Integer> ]
13
def valid_response_codes
14
@valid_response_codes ||= [400]
15
end
16
17
# @param [ Hash ] opts
18
# @option opts [ String ] :list Mandatory
19
#
20
# @return [ Array<Timthumb> ]
21
def aggressive(opts = {})
22
found = []
23
24
enumerate(target_urls(opts), opts.merge(check_full_response: 400)) do |res|
25
next unless /no image specified/i.match?(res.body)
26
27
found << Model::Timthumb.new(res.request.url, opts.merge(found_by: found_by, confidence: 100))
28
end
29
30
found
31
end
32
33
# @param [ Hash ] opts
34
# @option opts [ String ] :list Mandatory
35
#
36
# @return [ Hash ]
37
def target_urls(opts = {})
38
urls = {}
39
40
File.open(opts[:list]).each_with_index do |path, index|
41
urls[target.url(path.chomp)] = index
42
end
43
44
# Add potential timthumbs located in the main theme
45
if target.main_theme
46
main_theme_timthumbs_paths.each do |path|
47
urls[target.main_theme.url(path)] = 1 # index not important there
48
end
49
end
50
51
urls
52
end
53
54
def main_theme_timthumbs_paths
55
%w[timthumb.php lib/timthumb.php inc/timthumb.php includes/timthumb.php
56
scripts/timthumb.php tools/timthumb.php functions/timthumb.php]
57
end
58
59
def create_progress_bar(opts = {})
60
super(opts.merge(title: ' Checking Known Locations -'))
61
end
62
end
63
end
64
end
65
end
66
67