Module: Wpxf::WordPress::Fingerprint
- Included in:
- Module
- Defined in:
- lib/wpxf/wordpress/fingerprint.rb
Overview
Provides functionality for fingerprinting WordPress and its components.
Instance Method Summary collapse
-
#check_plugin_version_from_changelog(plugin_name, file_name, fixed = nil, introduced = nil) ⇒ Symbol
Checks a plugin's changelog for a vulnerable version.
-
#check_plugin_version_from_readme(name, fixed = nil, introduced = nil) ⇒ Symbol
Checks a plugin's readme for a vulnerable version.
-
#check_theme_version_from_readme(name, fixed = nil, introduced = nil) ⇒ Symbol
Checks a theme's readme for a vulnerable version.
-
#check_theme_version_from_style(name, fixed = nil, introduced = nil) ⇒ Symbol
Checks the style.css file for a vulnerable version.
-
#check_version_from_custom_file(url, regex, fixed = nil, introduced = nil) ⇒ Symbol
Checks a custom file for a vulnerable version.
-
#wordpress_and_online? ⇒ Boolean
Check if the host is online and running WordPress.
-
#wordpress_version ⇒ Version?
Extract the WordPress version information from various sources.
Instance Method Details
#check_plugin_version_from_changelog(plugin_name, file_name, fixed = nil, introduced = nil) ⇒ Symbol
Checks a plugin's changelog for a vulnerable version.
65 66 67 68 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 65 def check_plugin_version_from_changelog(plugin_name, file_name, fixed = nil, introduced = nil) changelog = normalize_uri(wordpress_url_plugins, plugin_name, file_name) check_version_from_custom_file(changelog, /=\s([\d\.]+)\s=/, fixed, introduced) end |
#check_plugin_version_from_readme(name, fixed = nil, introduced = nil) ⇒ Symbol
Checks a plugin's readme for a vulnerable version.
55 56 57 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 55 def check_plugin_version_from_readme(name, fixed = nil, introduced = nil) _check_version_from_readme(:plugin, name, fixed, introduced) end |
#check_theme_version_from_readme(name, fixed = nil, introduced = nil) ⇒ Symbol
Checks a theme's readme for a vulnerable version.
46 47 48 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 46 def check_theme_version_from_readme(name, fixed = nil, introduced = nil) _check_version_from_readme(:theme, name, fixed, introduced) end |
#check_theme_version_from_style(name, fixed = nil, introduced = nil) ⇒ Symbol
Checks the style.css file for a vulnerable version.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 30 def check_theme_version_from_style(name, fixed = nil, introduced = nil) style_uri = normalize_uri(wordpress_url_themes, name, 'style.css') res = execute_get_request(url: style_uri) # No style.css file present return :unknown if res.nil? || res.code != 200 pattern = _extension_version_pattern(:style) _extract_and_check_version(res.body, pattern, fixed, introduced) end |
#check_version_from_custom_file(url, regex, fixed = nil, introduced = nil) ⇒ Symbol
Checks a custom file for a vulnerable version.
76 77 78 79 80 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 76 def check_version_from_custom_file(url, regex, fixed = nil, introduced = nil) res = execute_get_request(url: url) return :unknown unless res && res.code == 200 _extract_and_check_version(res.body, regex, fixed, introduced) end |
#wordpress_and_online? ⇒ Boolean
Check if the host is online and running WordPress.
7 8 9 10 11 12 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 7 def wordpress_and_online? res = execute_get_request(url: full_uri) return false unless res && res.code == 200 return true if _wordpress_fingerprint_regexes.any? { |r| res.body =~ r } false end |
#wordpress_version ⇒ Version?
Extract the WordPress version information from various sources.
16 17 18 19 20 21 22 23 |
# File 'lib/wpxf/wordpress/fingerprint.rb', line 16 def wordpress_version _wordpress_version_fingerprint_sources.each do |url, pattern| res = execute_get_request(url: url) match = res.body.match(pattern) if res && res.code == 200 return Gem::Version.new(match[1]) if match end nil end |