From 22d69a1bf99b86103f26f39b9c1ad7c64a51f074 Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Fri, 12 Aug 2016 20:54:24 +0200 Subject: [PATCH] more detailed update exception --- lib/common/db_updater.rb | 11 ++++++++++- lib/common/errors.rb | 9 +++++++++ wpscan.rb | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/common/db_updater.rb b/lib/common/db_updater.rb index e04a3075..9e9703b4 100644 --- a/lib/common/db_updater.rb +++ b/lib/common/db_updater.rb @@ -80,6 +80,15 @@ class DbUpdater local_file_checksum(filename) end + def get_cloudflare_info + begin + res = Browser.get(remote_file_url('/cdn-cgi/trace'), request_params) + res.body + rescue + nil + end + end + def update(verbose = false) FILES.each do |filename| begin @@ -101,7 +110,7 @@ class DbUpdater puts " [i] Database File Checksum : #{db_checksum}" if verbose unless dl_checksum == db_checksum - fail "#{filename}: checksums do not match (local: #{dl_checksum} remote: #{db_checksum})" + raise ChecksumError.new(File.read(local_file_path(filename)), get_cloudflare_info), "#{filename}: checksums do not match (local: #{dl_checksum} remote: #{db_checksum})" end rescue => e puts ' [i] Restoring Backup due to error' if verbose diff --git a/lib/common/errors.rb b/lib/common/errors.rb index d014c362..be111b85 100644 --- a/lib/common/errors.rb +++ b/lib/common/errors.rb @@ -31,3 +31,12 @@ class DownloadError < HttpError "Unable to get #{failure_details}" end end + +class ChecksumError < StandardError + attr_reader :file, :cloudflare_info + + def initialize(file, cloudflare_info) + @file = file + @cloudflare_info = cloudflare_info + end +end diff --git a/wpscan.rb b/wpscan.rb index d89cb198..afc53f72 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -454,6 +454,17 @@ def main rescue Interrupt # do nothing on interrupt + # Error on Updating + rescue ChecksumError => e + puts critical(e.message) + puts critical('Downloaded File Content:') + puts e.file[0..500] + puts '.........' + puts + puts critical('Cloudflare Info:') + puts e.cloudflare_info + puts + puts critical('Please submit this info as an Github issue') rescue => e puts puts critical(e.message)