Permalink
Browse files

Merge remote branch 'upstream/master'

  • Loading branch information...
bcoles committed Oct 7, 2012
2 parents 7ce313c + 796472d commit ce25b84ffb521e8fbe98a3b3d684ce1228311f49
Showing with 2,989 additions and 511 deletions.
  1. +2 −2 lib/output.rb
  2. +66 −0 lib/version_class.rb
  3. +2 −2 plugins-disabled/Charset.rb
  4. +238 −73 plugins/Centreon.rb
  5. +78 −12 plugins/concrete5.rb
  6. +1,300 −134 plugins/drupal.rb
  7. +317 −107 plugins/joomla.rb
  8. +230 −31 plugins/modx-cms.rb
  9. +755 −149 plugins/wordpress.rb
  10. +1 −1 whatweb
View
@@ -565,7 +565,7 @@ def utf8_elements!(obj)
#pp @charset
#pp obj.encoding
# read this - http://blog.grayproductions.net/articles/ruby_19s_string
- obj=obj.gsub!(/^.*$/,Iconv.iconv("UTF-8",@charset,obj).join) # this is a bad way to do this but it works
+ obj = obj.force_encoding('UTF-8')
# obj=obj.force_encoding("ASCII-8BIT")
#puts obj.encoding.name
@@ -677,7 +677,7 @@ def utf8_elements!(obj)
if obj.class == String
# obj=obj.upcase!
# obj=Iconv.iconv("UTF-8",@charset,obj).join
- obj=obj.gsub!(/^.*$/,Iconv.iconv("UTF-8",@charset,obj).join) # this is a bad way to do this but it works
+ obj = obj.force_encoding('UTF-8')
end
end
View
@@ -0,0 +1,66 @@
+class Version
+ def initialize(name_product = nil, versions = nil, url = nil)
+ @name = name_product
+ @versions = versions
+ @files = Hash["filenames" => [], "files" => [], "md5" => []]
+ @url = url
+ @got_best_versions = false
+ @best_versions = []
+
+ if @name == nil
+ raise "You must specify the name of the product"
+ elsif @versions == nil
+ raise "You must specify the available versions of the product"
+ elsif @url == nil
+ raise "You must specify the available url of the website"
+ end
+
+ versions.each do |version|
+ version[1].each do |file|
+ if not @files["filenames"].include? file[0]
+ @files["filenames"].push(file[0])
+ @files["files"].push(URI.join(@url.to_s, file[0]).to_s)
+ status, url, ip, body, headers = open_target(@files["files"].last)
+ @files["md5"].push(Digest::MD5.hexdigest(body))
+ end
+ end
+ end
+ end
+
+ def best_matches
+ if @got_best_versions == true
+ return @best_versions
+ end
+
+ @versions.each do |version|
+ count = 0
+ version[1].each do |file|
+ i = @files["filenames"].index(file[0])
+ if @files["md5"][i] == file[1]
+ count += 1
+ end
+ end
+ while not @best_versions.empty? and @best_versions[0][1] < count
+ @best_versions.delete_at(0)
+ end
+ if count != 0 and (@best_versions.empty? or @best_versions[0][1] == count) and \
+ not @best_versions.include? [version[0], count]
+ @best_versions.insert(0, [version[0], count])
+ end
+ end
+
+ @got_best_versions = true
+ @best_versions.flatten!
+
+ @best_versions.each_index{|i| @best_versions.delete_at(i + 1)}.sort!
+
+ @best_versions
+ end
+
+ def matches_format
+ if @got_best_versions == false
+ self.best_matches
+ end
+ @best_versions
+ end
+end
@@ -84,7 +84,7 @@ def passive
found=false
while trythis = trythese.pop
begin
- d=Iconv.iconv("UTF-8",trythis,body).join
+ d = body.force_encoding('UTF-8')
found=true
m << {:string=> trythis}
break
@@ -97,7 +97,7 @@ def passive
begin
cd = CharDet.detect(body)
encoding = cd['encoding'].upcase
- d=Iconv.iconv("UTF-8",encoding,body).join
+ d = body.force_encoding('UTF-8')
found=true
m << {:string=> encoding, :module=> "CharDet"}
rescue
Oops, something went wrong.

0 comments on commit ce25b84

Please sign in to comment.