fix issue #265 - remove base64 images before passive detection

This commit is contained in:
Christian Mehlmauer
2013-08-17 10:54:28 +02:00
parent 086e6e86a5
commit 9015834b15
3 changed files with 26 additions and 0 deletions

View File

@@ -73,6 +73,8 @@ class WpItems < Array
def passive_detection(wp_target, options = {})
results = new(wp_target)
body = Browser.get(wp_target.url).body
# improves speed
body = remove_base64_images_from_html(body)
names = body.scan(passive_detection_pattern(wp_target))
names.flatten.uniq.each { |name| results.add(name) }

View File

@@ -149,3 +149,10 @@ def get_equal_string_end(stringarray = [''])
end
already_found
end
def remove_base64_images_from_html(html)
# remove data:image/png;base64, images
base64regex = %r{(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?}
imageregex = %r{data\s*:\s*image/[^\s;]+\s*;\s*base64\s*,\s*}
html.gsub(/["']\s*#{imageregex}#{base64regex}\s*["']/, '""')
end