From 307751e14fa6687e4eaddea8dcbf4c64568ce3db Mon Sep 17 00:00:00 2001 From: ekultek Date: Thu, 12 Oct 2017 17:53:45 -0500 Subject: [PATCH] patch for an issue where the current URL could not be pulled due to a present alert (issue #81) --- lib/core/settings.py | 2 +- var/google_search/search.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/core/settings.py b/lib/core/settings.py index 6de9b6b..1f11291 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -22,7 +22,7 @@ except NameError: # clone link CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.0.41" +VERSION = "1.0.42.aeb1" # colors to output depending on the version VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30} # version string formatting diff --git a/var/google_search/search.py b/var/google_search/search.py index 68bf75f..9cebfba 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -17,6 +17,7 @@ from selenium import webdriver from pyvirtualdisplay import Display from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.proxy import * +from selenium.webdriver.remote.errorhandler import UnexpectedAlertPresentException from var.auto_issue.github import request_issue_creation from lib.core.settings import ( @@ -140,7 +141,15 @@ def get_urls(query, url, verbose=False, warning=True, **kwargs): logger.debug(set_color( "obtaining URL from selenium..." )) - retval = browser.current_url + try: + retval = browser.current_url + except UnexpectedAlertPresentException: + logger.warning(set_color( + "alert present, closing...", level=30 + )) + alert = browser.switch_to.alert + alert.accept() + retval = browser.current_url ban_url_schema = ["http://ipv6.google.com", "http://ipv4.google.com"] if any(u in retval for u in ban_url_schema): # if you got IP banned logger.warning(set_color(