moved to wpstools
This commit is contained in:
@@ -17,37 +17,61 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#++
|
||||
|
||||
class WpscanStats
|
||||
require_files_from_directory(WPSCAN_LIB_DIR, '**/*.rb')
|
||||
|
||||
def self.vuln_plugin_count(file=PLUGINS_VULNS_FILE)
|
||||
class StatsPlugin < Plugin
|
||||
|
||||
def initialize
|
||||
super(author: 'WPScanTeam - Christian Mehlmauer')
|
||||
|
||||
register_options(
|
||||
['--stats', '--s', 'Show WpScan Database statistics']
|
||||
)
|
||||
end
|
||||
|
||||
def run(options = {})
|
||||
if options[:stats]
|
||||
puts "Wpscan Databse Statistics:"
|
||||
puts "--------------------------"
|
||||
puts "[#] Total vulnerable plugins: #{vuln_plugin_count}"
|
||||
puts "[#] Total vulnerable themes: #{vuln_theme_count}"
|
||||
puts "[#] Total plugin vulnerabilities: #{plugin_vulns_count}"
|
||||
puts "[#] Total theme vulnerabilities: #{theme_vulns_count}"
|
||||
puts "[#] Total plugins to enumerate: #{total_plugins}"
|
||||
puts "[#] Total themes to enumerate: #{total_themes}"
|
||||
puts
|
||||
end
|
||||
end
|
||||
|
||||
def vuln_plugin_count(file=PLUGINS_VULNS_FILE)
|
||||
xml = Nokogiri::XML(File.open(file)) do |config|
|
||||
config.noblanks
|
||||
end
|
||||
xml.xpath("count(//plugin)").to_i
|
||||
end
|
||||
|
||||
def self.vuln_theme_count(file=THEMES_VULNS_FILE)
|
||||
def vuln_theme_count(file=THEMES_VULNS_FILE)
|
||||
xml = Nokogiri::XML(File.open(file)) do |config|
|
||||
config.noblanks
|
||||
end
|
||||
xml.xpath("count(//theme)").to_i
|
||||
end
|
||||
|
||||
def self.plugin_vulns_count(file=PLUGINS_VULNS_FILE)
|
||||
def plugin_vulns_count(file=PLUGINS_VULNS_FILE)
|
||||
xml = Nokogiri::XML(File.open(file)) do |config|
|
||||
config.noblanks
|
||||
end
|
||||
xml.xpath("count(//vulnerability)").to_i
|
||||
end
|
||||
|
||||
def self.theme_vulns_count(file=THEMES_VULNS_FILE)
|
||||
def theme_vulns_count(file=THEMES_VULNS_FILE)
|
||||
xml = Nokogiri::XML(File.open(file)) do |config|
|
||||
config.noblanks
|
||||
end
|
||||
xml.xpath("count(//vulnerability)").to_i
|
||||
end
|
||||
|
||||
def self.total_plugins(file=PLUGINS_FULL_FILE, xml=PLUGINS_VULNS_FILE)
|
||||
def total_plugins(file=PLUGINS_FULL_FILE, xml=PLUGINS_VULNS_FILE)
|
||||
options = {}
|
||||
options[:only_vulnerable_ones] = false
|
||||
options[:file] = file
|
||||
@@ -57,7 +81,7 @@ class WpscanStats
|
||||
WpEnumerator.generate_items(options).count
|
||||
end
|
||||
|
||||
def self.total_themes(file=THEMES_FULL_FILE, xml=THEMES_VULNS_FILE)
|
||||
def total_themes(file=THEMES_FULL_FILE, xml=THEMES_VULNS_FILE)
|
||||
options = {}
|
||||
options[:only_vulnerable_ones] = false
|
||||
options[:file] = file
|
||||
@@ -17,46 +17,54 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#++
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/wpscan_helper')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../wpstools_helper')
|
||||
|
||||
describe 'StatsPlugin' do
|
||||
before :each do
|
||||
@stats = StatsPlugin.new()
|
||||
end
|
||||
|
||||
describe 'WpscanStats' do
|
||||
describe '#vuln_plugin_count' do
|
||||
it 'should return the correct number' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml"
|
||||
WpscanStats.vuln_plugin_count(xml).should == 2
|
||||
@stats.vuln_plugin_count(xml).should == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe '#vuln_theme_count' do
|
||||
it 'should return the correct number' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml"
|
||||
WpscanStats.vuln_theme_count(xml).should == 2
|
||||
@stats.vuln_theme_count(xml).should == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe '#plugin_vulns_count' do
|
||||
it 'should return the correct number' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml"
|
||||
WpscanStats.plugin_vulns_count(xml).should == 3
|
||||
@stats.plugin_vulns_count(xml).should == 3
|
||||
end
|
||||
end
|
||||
|
||||
describe '#theme_vulns_count' do
|
||||
it 'should return the correct number' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml"
|
||||
WpscanStats.theme_vulns_count(xml).should == 3
|
||||
@stats.theme_vulns_count(xml).should == 3
|
||||
end
|
||||
end
|
||||
|
||||
describe '#total_plugins' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml"
|
||||
file = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/plugins.txt"
|
||||
WpscanStats.total_plugins(file, xml).should == 4
|
||||
it 'should return the correct numer' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml"
|
||||
file = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/plugins.txt"
|
||||
@stats.total_plugins(file, xml).should == 4
|
||||
end
|
||||
end
|
||||
|
||||
describe '#total_themes' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml"
|
||||
file = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/themes.txt"
|
||||
WpscanStats.total_themes(file, xml).should == 5
|
||||
it 'should return the correct numer' do
|
||||
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml"
|
||||
file = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/themes.txt"
|
||||
@stats.total_themes(file, xml).should == 5
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -55,15 +55,6 @@ end
|
||||
File.delete(LOG_FILE) if File.exist?(LOG_FILE) and !File.symlink?(LOG_FILE)
|
||||
|
||||
banner()
|
||||
# Stats
|
||||
puts "Wpscan Database Statistics:"
|
||||
puts "\tTotal vulnerable plugins: #{WpscanStats.vuln_plugin_count}"
|
||||
puts "\tTotal vulnerable themes: #{WpscanStats.vuln_theme_count}"
|
||||
puts "\tTotal plugin vulnerabilities: #{WpscanStats.plugin_vulns_count}"
|
||||
puts "\tTotal theme vulnerabilities: #{WpscanStats.theme_vulns_count}"
|
||||
puts "\tTotal plugins to enumerate: #{WpscanStats.total_plugins}"
|
||||
puts "\tTotal themes to enumerate: #{WpscanStats.total_themes}"
|
||||
puts
|
||||
|
||||
begin
|
||||
wpscan_options = WpscanOptions.load_from_arguments
|
||||
|
||||
@@ -33,7 +33,8 @@ begin
|
||||
plugins = Plugins.new(option_parser)
|
||||
plugins.register(
|
||||
CheckerPlugin.new,
|
||||
ListGeneratorPlugin.new
|
||||
ListGeneratorPlugin.new,
|
||||
StatsPlugin.new
|
||||
)
|
||||
|
||||
options = option_parser.results
|
||||
|
||||
Reference in New Issue
Block a user