From b6dec2138e0459afb68d51be3d71890282ee0b8f Mon Sep 17 00:00:00 2001 From: David McKennirey Date: Fri, 15 Jan 2021 07:42:47 -0500 Subject: [PATCH] Add error handling for refused connections. This will allow the tool to continue testing if one or more of the target urls refuses connections. Previously, this would cause the tool to stop once it encoutered a URL that refused a connection. --- corsy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/corsy.py b/corsy.py index b0a3ace..28d5a3b 100644 --- a/corsy.py +++ b/corsy.py @@ -4,6 +4,7 @@ import sys import json import argparse +from requests.exceptions import ConnectionError from core.tests import active_tests from core.utils import host, prompt, format_result, extractHeaders, create_url_list @@ -63,7 +64,10 @@ def cors(target, header_dict, delay): netloc = parsed.netloc scheme = parsed.scheme url = scheme + '://' + netloc - return active_tests(url, root, scheme, header_dict, delay) + try: + return active_tests(url, root, scheme, header_dict, delay) + except ConnectionError as exc: + print(f'[WARNING] Unable to connect to {target}: {exc}') if urls: