From facd0d398a21b52f01d79622ebde2c7cbed77350 Mon Sep 17 00:00:00 2001 From: erwanlr Date: Sat, 5 Apr 2014 13:12:57 +0200 Subject: [PATCH] Fix #439 - Detect if the target goes down during the scan --- lib/common/common_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/common/common_helper.rb b/lib/common/common_helper.rb index cd3fa6bc..e6ad22e6 100644 --- a/lib/common/common_helper.rb +++ b/lib/common/common_helper.rb @@ -64,6 +64,14 @@ end require_files_from_directory(COMMON_LIB_DIR, '**/*.rb') +# Hook to check if the target if down during the scan +# The target is considered down after 10 request with status = 0 +down = 0 +Typhoeus.on_complete do |response| + down += 1 if response.code == 0 + fail 'The target seems to be down' if down >= 10 +end + # Add protocol def add_http_protocol(url) url =~ /^https?:/ ? url : "http://#{url}"