moved to wpstools

This commit is contained in:
Christian Mehlmauer
2013-02-08 12:53:01 +01:00
parent e1cd332b06
commit eeb459ce67
4 changed files with 53 additions and 29 deletions

View File

@@ -17,37 +17,61 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # 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| xml = Nokogiri::XML(File.open(file)) do |config|
config.noblanks config.noblanks
end end
xml.xpath("count(//plugin)").to_i xml.xpath("count(//plugin)").to_i
end 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| xml = Nokogiri::XML(File.open(file)) do |config|
config.noblanks config.noblanks
end end
xml.xpath("count(//theme)").to_i xml.xpath("count(//theme)").to_i
end 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| xml = Nokogiri::XML(File.open(file)) do |config|
config.noblanks config.noblanks
end end
xml.xpath("count(//vulnerability)").to_i xml.xpath("count(//vulnerability)").to_i
end 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| xml = Nokogiri::XML(File.open(file)) do |config|
config.noblanks config.noblanks
end end
xml.xpath("count(//vulnerability)").to_i xml.xpath("count(//vulnerability)").to_i
end 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 = {}
options[:only_vulnerable_ones] = false options[:only_vulnerable_ones] = false
options[:file] = file options[:file] = file
@@ -57,7 +81,7 @@ class WpscanStats
WpEnumerator.generate_items(options).count WpEnumerator.generate_items(options).count
end 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 = {}
options[:only_vulnerable_ones] = false options[:only_vulnerable_ones] = false
options[:file] = file options[:file] = file

View File

@@ -17,46 +17,54 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # 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 describe '#vuln_plugin_count' do
it 'should return the correct number' do it 'should return the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml" 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
end end
describe '#vuln_theme_count' do describe '#vuln_theme_count' do
it 'should return the correct number' do it 'should return the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml" 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
end end
describe '#plugin_vulns_count' do describe '#plugin_vulns_count' do
it 'should return the correct number' do it 'should return the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml" 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
end end
describe '#theme_vulns_count' do describe '#theme_vulns_count' do
it 'should return the correct number' do it 'should return the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml" 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
end end
describe '#total_plugins' do describe '#total_plugins' do
it 'should return the correct numer' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml" xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml"
file = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/plugins.txt" file = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/plugins.txt"
WpscanStats.total_plugins(file, xml).should == 4 @stats.total_plugins(file, xml).should == 4
end
end end
describe '#total_themes' do describe '#total_themes' do
it 'should return the correct numer' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml" xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml"
file = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/themes.txt" file = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/themes.txt"
WpscanStats.total_themes(file, xml).should == 5 @stats.total_themes(file, xml).should == 5
end
end end
end end

View File

@@ -55,15 +55,6 @@ end
File.delete(LOG_FILE) if File.exist?(LOG_FILE) and !File.symlink?(LOG_FILE) File.delete(LOG_FILE) if File.exist?(LOG_FILE) and !File.symlink?(LOG_FILE)
banner() 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 begin
wpscan_options = WpscanOptions.load_from_arguments wpscan_options = WpscanOptions.load_from_arguments

View File

@@ -33,7 +33,8 @@ begin
plugins = Plugins.new(option_parser) plugins = Plugins.new(option_parser)
plugins.register( plugins.register(
CheckerPlugin.new, CheckerPlugin.new,
ListGeneratorPlugin.new ListGeneratorPlugin.new,
StatsPlugin.new
) )
options = option_parser.results options = option_parser.results