From 715d3d4ad6431391483614941081d74b6b6eb271 Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Mon, 14 May 2018 16:35:41 +0100 Subject: [PATCH] Moved http response to a function --- lib/common/common_helper.rb | 5 +++++ lib/wpscan/web_site/robots_txt.rb | 6 ------ wpscan.rb | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/common/common_helper.rb b/lib/common/common_helper.rb index 37a134f2..d564c8d5 100644 --- a/lib/common/common_helper.rb +++ b/lib/common/common_helper.rb @@ -326,4 +326,9 @@ def valid_json?(json) return true rescue JSON::ParserError => e return false +end + +# Get the HTTP response code +def get_http_status(url) + Browser.get(url.to_s).code end \ No newline at end of file diff --git a/lib/wpscan/web_site/robots_txt.rb b/lib/wpscan/web_site/robots_txt.rb index 2a10893d..d8d52cfb 100644 --- a/lib/wpscan/web_site/robots_txt.rb +++ b/lib/wpscan/web_site/robots_txt.rb @@ -15,12 +15,6 @@ class WebSite @uri.clone.merge('robots.txt').to_s end - # Check status code for each robots.txt entry - def header_robots_txt(url) - code = Browser.get(url).code - puts info("Interesting entry from robots.txt: #{url} [HTTP #{code}]") - end - # Parse robots.txt # @return [ Array ] URLs generated from robots.txt def parse_robots_txt diff --git a/wpscan.rb b/wpscan.rb index f9b40364..67f7bc90 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -237,16 +237,29 @@ def main spacer() if wp_target.has_robots? - puts info("robots.txt available under: #{wp_target.robots_url}") + code = get_http_status(wp_target.robots_url) + puts info("robots.txt available under: #{wp_target.robots_url} [HTTP #{code}]") wp_target.parse_robots_txt.each do |dir| - wp_target.header_robots_txt(dir) + code = get_http_status(dir) + puts info("Interesting entry from robots.txt: #{dir} [HTTP #{code}]") + end + spacer() + end + + if wp_target.has_sitemap? + puts info("Sitemap found: #{wp_target.sitemap_url}") + + wp_target.parse_sitemap.each do |dir| + code = get_http_status(dir) + puts info("Sitemap entry: #{dir} [HTTP #{code}]") end spacer() end if wp_target.has_humans? - puts info("humans.txt available under: #{wp_target.humans_url}") + code = get_http_status(wp_target.humans_url) + puts info("humans.txt available under: #{wp_target.humans_url} [HTTP #{code}]") wp_target.parse_humans_txt.each do |dir| puts info("Interesting entry from humans.txt: #{dir}") @@ -315,8 +328,10 @@ def main # Get RSS rss = wp_target.rss_url if rss + code = get_http_status(rss) + # Feedback - puts info("RSS Feed: #{rss}") + puts info("Found an RSS Feed: #{rss} [HTTP #{code}]") # Print users from RSS feed wp_target.rss_authors(rss)