Skip to content

Commit 6b5e016

Browse files
committed
Improves detection of WP Version, Plugins etc by checking 404
1 parent 85aa9f6 commit 6b5e016

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+457
-147
lines changed

app/finders/main_theme.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
22

3-
require_relative 'main_theme/css_style'
3+
require_relative 'main_theme/css_style_in_homepage'
4+
require_relative 'main_theme/css_style_in_404_page'
45
require_relative 'main_theme/woo_framework_meta_generator'
56
require_relative 'main_theme/urls_in_homepage'
7+
require_relative 'main_theme/urls_in_404_page'
68

79
module WPScan
810
module Finders
@@ -14,9 +16,11 @@ class Base
1416
# @param [ WPScan::Target ] target
1517
def initialize(target)
1618
finders <<
17-
MainTheme::CssStyle.new(target) <<
19+
MainTheme::CssStyleInHomepage.new(target) <<
20+
MainTheme::CssStyleIn404Page.new(target) <<
1821
MainTheme::WooFrameworkMetaGenerator.new(target) <<
19-
MainTheme::UrlsInHomepage.new(target)
22+
MainTheme::UrlsInHomepage.new(target) <<
23+
MainTheme::UrlsIn404Page.new(target)
2024
end
2125
end
2226
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
module WPScan
4+
module Finders
5+
module MainTheme
6+
# From the CSS style in the 404 page
7+
class CssStyleIn404Page < CssStyleInHomepage
8+
def passive(opts = {})
9+
passive_from_css_href(target.error_404_res, opts) || passive_from_style_code(target.error_404_res, opts)
10+
end
11+
end
12+
end
13+
end
14+
end

app/finders/main_theme/css_style.rb renamed to app/finders/main_theme/css_style_in_homepage.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
module WPScan
44
module Finders
55
module MainTheme
6-
# From the css style
7-
class CssStyle < CMSScanner::Finders::Finder
8-
include Finders::WpItems::URLsInHomepage
6+
# From the CSS style in the homepage
7+
class CssStyleInHomepage < CMSScanner::Finders::Finder
8+
include Finders::WpItems::UrlsInPage # To have the item_code_pattern method available here
99

1010
def create_theme(slug, style_url, opts)
1111
Model::Theme.new(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module WPScan
4+
module Finders
5+
module MainTheme
6+
# URLs In 404 Page Finder
7+
class UrlsIn404Page < UrlsInHomepage
8+
# @return [ Typhoeus::Response ]
9+
def page_res
10+
@page_res ||= target.error_404_res
11+
end
12+
end
13+
end
14+
end
15+
end

app/finders/main_theme/urls_in_homepage.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Finders
55
module MainTheme
66
# URLs In Homepage Finder
77
class UrlsInHomepage < CMSScanner::Finders::Finder
8-
include WpItems::URLsInHomepage
8+
include WpItems::UrlsInPage
99

1010
# @param [ Hash ] opts
1111
#
@@ -21,6 +21,11 @@ def passive(opts = {})
2121

2222
found
2323
end
24+
25+
# @return [ Typhoeus::Response ]
26+
def page_res
27+
@page_res ||= target.homepage_res
28+
end
2429
end
2530
end
2631
end

app/finders/main_theme/woo_framework_meta_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class WooFrameworkMetaGenerator < CMSScanner::Finders::Finder
1010
PATTERN = /#{THEME_PATTERN}\s+#{FRAMEWORK_PATTERN}/i.freeze
1111

1212
def passive(opts = {})
13-
return unless target.homepage_res.body =~ PATTERN
13+
return unless target.homepage_res.body =~ PATTERN || target.error_404_res.body =~ PATTERN
1414

1515
Model::Theme.new(
1616
Regexp.last_match[1],

app/finders/plugins.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require_relative 'plugins/urls_in_homepage'
4+
require_relative 'plugins/urls_in_404_page'
45
require_relative 'plugins/known_locations'
56
# From the DynamicFinders
67
require_relative 'plugins/comment'
@@ -22,6 +23,7 @@ class Base
2223
def initialize(target)
2324
finders <<
2425
Plugins::UrlsInHomepage.new(target) <<
26+
Plugins::UrlsIn404Page.new(target) <<
2527
Plugins::HeaderPattern.new(target) <<
2628
Plugins::Comment.new(target) <<
2729
Plugins::Xpath.new(target) <<
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
module WPScan
4+
module Finders
5+
module Plugins
6+
# URLs In 404 Page Finder
7+
# Typically, the items detected from URLs like /wp-content/plugins/<slug>/
8+
class UrlsIn404Page < UrlsInHomepage
9+
# @return [ Typhoeus::Response ]
10+
def page_res
11+
@page_res ||= target.error_404_res
12+
end
13+
end
14+
end
15+
end
16+
end

app/finders/plugins/urls_in_homepage.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ module WPScan
44
module Finders
55
module Plugins
66
# URLs In Homepage Finder
7-
# Typically, the items detected from URLs like
8-
# /wp-content/plugins/<slug>/
7+
# Typically, the items detected from URLs like /wp-content/plugins/<slug>/
98
class UrlsInHomepage < CMSScanner::Finders::Finder
10-
include WpItems::URLsInHomepage
9+
include WpItems::UrlsInPage
1110

1211
# @param [ Hash ] opts
1312
#
@@ -21,6 +20,11 @@ def passive(opts = {})
2120

2221
found
2322
end
23+
24+
# @return [ Typhoeus::Response ]
25+
def page_res
26+
@page_res ||= target.homepage_res
27+
end
2428
end
2529
end
2630
end

app/finders/themes.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# frozen_string_literal: true
22

33
require_relative 'themes/urls_in_homepage'
4+
require_relative 'themes/urls_in_404_page'
45
require_relative 'themes/known_locations'
56

67
module WPScan
78
module Finders
89
module Themes
9-
# themes Finder
10+
# Themes Finder
1011
class Base
1112
include CMSScanner::Finders::SameTypeFinder
1213

1314
# @param [ WPScan::Target ] target
1415
def initialize(target)
1516
finders <<
1617
Themes::UrlsInHomepage.new(target) <<
18+
Themes::UrlsIn404Page.new(target) <<
1719
Themes::KnownLocations.new(target)
1820
end
1921
end

0 commit comments

Comments
 (0)