From 9fa5d7871c601c1183ebd82cc736b29051b263ee Mon Sep 17 00:00:00 2001 From: Lars Kulseng Date: Fri, 7 Feb 2020 10:39:24 +0100 Subject: [PATCH] Fixed Mongodb logging and charset bugs --- plugins-disabled/charset.rb | 24 ++++++++++-------------- whatweb | 12 ++++++------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/plugins-disabled/charset.rb b/plugins-disabled/charset.rb index eedcffe8b..25c8efb72 100644 --- a/plugins-disabled/charset.rb +++ b/plugins-disabled/charset.rb @@ -25,18 +25,9 @@ def startup end passive do - def get_charset(body) - charset = nil - meta_content_tag = body.scan(/]+Content-Type[^>]+>/i)[0] - # puts meta_content_tag - unless meta_content_tag.nil? or not meta_content_tag =~ /charset=['"]?([a-zA-Z0-9_-]+)/i - charset = meta_content_tag.scan(/charset=['"]?([a-zA-Z0-9_-]+)/i)[0][0] - charset.upcase! - end - charset - end - + m = [] + body=@body =begin Arabic (Windows) Windows-1256 @@ -76,10 +67,15 @@ def get_charset(body) trythese = %w| UTF_8 ASCII | # it's stack backwards - charset = get_charset(body) + charset = nil + meta_content_tag = body.scan(/]+Content-Type[^>]+>/i)[0] + # puts meta_content_tag + unless meta_content_tag.nil? or not meta_content_tag =~ /charset=['"]?([a-zA-Z0-9_-]+)/i + charset = meta_content_tag.scan(/charset=['"]?([a-zA-Z0-9_-]+)/i)[0][0] + charset.upcase! + end trythese.push(charset) unless charset.nil? - found=false while trythis = trythese.pop begin @@ -87,7 +83,7 @@ def get_charset(body) found = true m << {:string=> trythis} break - rescue + rescue # end diff --git a/whatweb b/whatweb index 6013b3a72..667fa937e 100755 --- a/whatweb +++ b/whatweb @@ -176,7 +176,7 @@ EXAMPLE USAGE: * Scan the local network for https websites. whatweb --no-errors --url-prefix https:// 192.168.0.0/24 - + * Scan for crossdomain policies in the Alexa Top 1000. ./whatweb -i plugin-development/alexa-top-100.txt \\ --url-suffix /crossdomain.xml -p crossdomain_xml @@ -575,7 +575,7 @@ logging_list << LoggingVerbose.new if $verbose > 0 # full logging if -v ## logging dependencies if mongo[:use_mongo_log] if plugins.map { |a, _b| a }.include?('Charset') - logging_list << OutputMongo.new(mongo) + logging_list << LoggingMongo.new(mongo) else error('MongoDB logging requires the Charset plugin to be activated. The Charset plugin is the slowest whatweb plugin, it not included by default, and resides in the plugins-disabled folder. Use ./whatweb -p +./plugins-disabled/charset.rb to enable it.') exit @@ -618,16 +618,16 @@ end # run scan scanner.scan do | target | - # change so we can call it without Target object and with just Headers, HTML, etc. + # change so we can call it without Target object and with just Headers, HTML, etc. # note this modifies target with redirection info result = WhatWeb::Parser.run_plugins(target, plugins, scanner: scanner) # check for redirection WhatWeb::Redirect.new(target, scanner, max_redirects) - WhatWeb::Parser.parse(target, - result, - logging_list: logging_list, + WhatWeb::Parser.parse(target, + result, + logging_list: logging_list, grep_plugin: use_custom_grep_plugin) end