From 3a3376ec41235d4c3e72d346efce16b714d93328 Mon Sep 17 00:00:00 2001 From: ethicalhack3r Date: Mon, 15 Dec 2014 15:39:14 +0100 Subject: [PATCH] Disable logging by default. Implement log option. #703 #336 --- README | 2 ++ README.md | 2 ++ lib/common/browser.rb | 2 +- lib/common/hacks.rb | 10 ++++++---- lib/wpscan/wpscan_options.rb | 4 +++- wpscan.rb | 6 ++++-- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README b/README index cc50a01a..10cdd63c 100644 --- a/README +++ b/README @@ -222,6 +222,8 @@ You should have received a copy of the GNU General Public License along with thi --no-color Do not use colors in the output. +--log Save STDOUT to log.txt + ==WPSCAN EXAMPLES== Do 'non-intrusive' checks... diff --git a/README.md b/README.md index ec932c22..7c08d28c 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,8 @@ Apple Xcode, Command Line Tools and the libffi are needed (to be able to install --no-color Do not use colors in the output. + --log Save STDOUT to log.txt + #### WPSCAN EXAMPLES Do 'non-intrusive' checks... diff --git a/lib/common/browser.rb b/lib/common/browser.rb index 763bb02f..f1cddb4f 100644 --- a/lib/common/browser.rb +++ b/lib/common/browser.rb @@ -30,7 +30,7 @@ class Browser # # @return [ Browser ] def initialize(options = {}) - @cache_dir = options[:cache_dir] || CACHE_DIR + '/browser' + @cache_dir = options[:cache_dir] || CACHE_DIR + '/browser' # sets browser defaults browser_defaults diff --git a/lib/common/hacks.rb b/lib/common/hacks.rb index 9db7e88e..66febe01 100644 --- a/lib/common/hacks.rb +++ b/lib/common/hacks.rb @@ -49,11 +49,13 @@ end # Override for puts to enable logging def puts(o = '') - # remove color for logging - if o.respond_to?(:gsub) - temp = o.gsub(/\e\[\d+m/, '') - File.open(LOG_FILE, 'a+') { |f| f.puts(temp) } + if @log + if o.respond_to?(:gsub) + temp = o.gsub(/\e\[\d+m/, '') # remove color for logging + File.open(LOG_FILE, 'a+') { |f| f.puts(temp) } + end end + super(o) end diff --git a/lib/wpscan/wpscan_options.rb b/lib/wpscan/wpscan_options.rb index 4c2cceda..cd2e9f48 100644 --- a/lib/wpscan/wpscan_options.rb +++ b/lib/wpscan/wpscan_options.rb @@ -14,6 +14,7 @@ class WpscanOptions :enumerate_usernames, :enumerate_usernames_range, :no_color, + :log, :proxy, :proxy_auth, :threads, @@ -269,7 +270,8 @@ class WpscanOptions ['--max-threads', GetoptLong::REQUIRED_ARGUMENT], ['--batch', GetoptLong::NO_ARGUMENT], ['--no-color', GetoptLong::NO_ARGUMENT], - ['--cookie', GetoptLong::REQUIRED_ARGUMENT] + ['--cookie', GetoptLong::REQUIRED_ARGUMENT], + ['--log', GetoptLong::NO_ARGUMENT] ) end diff --git a/wpscan.rb b/wpscan.rb index d00272ed..38ab6550 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -8,11 +8,13 @@ def main # delete old logfile, check if it is a symlink first. File.delete(LOG_FILE) if File.exist?(LOG_FILE) and !File.symlink?(LOG_FILE) - banner() - begin wpscan_options = WpscanOptions.load_from_arguments + @log = wpscan_options.log + + banner() # called after @log instance variable set + unless wpscan_options.has_options? # first parameter only url? if ARGV.length == 1