Removes the source code updaters

This commit is contained in:
erwanlr
2014-09-17 16:01:41 +02:00
parent ea36c79c26
commit c31a06e255
12 changed files with 6 additions and 364 deletions

View File

@@ -73,20 +73,6 @@ def add_trailing_slash(url)
url =~ /\/$/ ? url : "#{url}/"
end
# loading the updater
require_files_from_directory(UPDATER_LIB_DIR)
@updater = UpdaterFactory.get_updater(ROOT_DIR)
if @updater
REVISION = @updater.local_revision_number()
else
REVISION = nil
end
def version
REVISION ? "v#{WPSCAN_VERSION}r#{REVISION}" : "v#{WPSCAN_VERSION}"
end
def missing_db_file?
DbUpdater::FILES.each do |db_file|
return true unless File.exist?(File.join(DATA_DIR, db_file))
@@ -134,12 +120,7 @@ def banner
puts ' \\/ \\/ |_| |_____/ \\___|\\__,_|_| |_|'
puts
puts ' WordPress Security Scanner by the WPScan Team '
# Alignment of the version (w & w/o the Revision)
if REVISION
puts " Version #{version}"
else
puts " Version #{version}"
end
puts " Version #{WPSCAN_VERSION}"
puts ' Sponsored by the RandomStorm Open Source Initiative'
puts ' @_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_'
puts '_______________________________________________________________'

View File

@@ -1,9 +1,7 @@
# encoding: UTF-8
require 'common/updater/updater'
# Updater for the Database (currently only 3 .json)
class DbUpdater < Updater
# DB Updater
class DbUpdater
FILES = %w(
local_vulnerable_files.xml local_vulnerable_files.xsd malwares.txt
plugins_full.txt plugins.txt themes_full.txt themes.txt

View File

@@ -1,37 +0,0 @@
# encoding: UTF-8
require 'common/updater/updater'
class GitUpdater < Updater
def is_installed?
%x[git #{repo_directory_arguments()} status 2>&1] =~ /On branch/ ? true : false
end
# Git has not a revsion number like SVN,
# so we will take the 7 first chars of the last commit hash
def local_revision_number
git_log = %x[git #{repo_directory_arguments()} log -1 2>&1]
git_log[/commit ([0-9a-z]{7})/i, 1].to_s
end
def update
%x[git #{repo_directory_arguments()} pull]
end
def has_local_changes?
%x[git #{repo_directory_arguments()} diff --exit-code 2>&1] =~ /diff/ ? true : false
end
def reset_head
%x[git #{repo_directory_arguments()} reset --hard HEAD]
end
protected
def repo_directory_arguments
if @repo_directory
return "--git-dir=\"#{@repo_directory}/.git\" --work-tree=\"#{@repo_directory}\""
end
end
end

View File

@@ -1,23 +0,0 @@
# encoding: UTF-8
require 'common/updater/updater'
class SvnUpdater < Updater
REVISION_PATTERN = /revision="(\d+)"/i
TRUNK_URL = 'https://github.com/wpscanteam/wpscan'
def is_installed?
%x[svn info "#@repo_directory" --xml 2>&1] =~ /revision=/ ? true : false
end
def local_revision_number
local_revision = %x[svn info "#@repo_directory" --xml 2>&1]
local_revision[REVISION_PATTERN, 1].to_s
end
def update
%x[svn up "#@repo_directory"]
end
end

View File

@@ -1,25 +0,0 @@
# encoding: UTF-8
# This class act as an absract one
class Updater
attr_reader :repo_directory
# TODO : add a last '/ to repo_directory if it's not present
def initialize(repo_directory = nil)
@repo_directory = repo_directory
end
def is_installed?
raise NotImplementedError
end
def local_revision_number
raise NotImplementedError
end
def update
raise NotImplementedError
end
end

View File

@@ -1,20 +0,0 @@
# encoding: UTF-8
# Factory
class UpdaterFactory
def self.get_updater(repo_directory)
available_updaters_classes.each do |updater_symbol|
updater = Object.const_get(updater_symbol).new(repo_directory)
return updater if updater.is_installed?
end
nil
end
protected
# @return [ Array<Symbol> ] The symbols related to code updaters
def self.available_updaters_classes
Object.constants.grep(/^(?:Svn|Git|Test)Updater$/)
end
end

View File

@@ -46,7 +46,7 @@ def usage
puts '-Use custom plugins directory ...'
puts "ruby #{script_name} -u www.example.com --wp-plugins-dir wp-content/custom-plugins"
puts
puts '-Update ...'
puts '-Update the DB ...'
puts "ruby #{script_name} --update"
puts
puts '-Debug output ...'
@@ -62,7 +62,7 @@ def help
puts
puts 'Some values are settable in a config file, see the example.conf.json'
puts
puts '--update Update to the latest revision.'
puts '--update Update to the database to the latest version.'
puts '--url | -u <target url> The WordPress URL/domain to scan.'
puts '--force | -f Forces WPScan to not check if the remote site is running WordPress.'
puts '--enumerate | -e [option(s)] Enumeration.'