Skip to content

Commit

Permalink
Merge pull request #293 from helsecert/mongodb-fix
Browse files Browse the repository at this point in the history
Fixed Mongodb logging and charset bugs
  • Loading branch information
urbanadventurer authored Feb 7, 2020
2 parents ec03b78 + 9fa5d78 commit 9b97e67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
24 changes: 10 additions & 14 deletions plugins-disabled/charset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,9 @@ def startup
end

passive do
def get_charset(body)
charset = nil
meta_content_tag = body.scan(/<meta[^>]+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
Expand Down Expand Up @@ -76,18 +67,23 @@ def get_charset(body)

trythese = %w| UTF_8 ASCII | # it's stack backwards

charset = get_charset(body)
charset = nil
meta_content_tag = body.scan(/<meta[^>]+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
d = body.force_encoding('UTF-8')
found = true
m << {:string=> trythis}
break
rescue
rescue
#
end

Expand Down
12 changes: 6 additions & 6 deletions whatweb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9b97e67

Please sign in to comment.