mirror of
https://github.com/Ekultek/Zeus-Scanner.git
synced 2026-03-11 08:55:51 +00:00
patch for an issue where to many sessions would be open, will now auto clean the sessions (issue #92)
This commit is contained in:
parent
b380c6e7c4
commit
6383abf69a
4 changed files with 61 additions and 2 deletions
3
etc/scripts/cleanup.sh
Normal file
3
etc/scripts/cleanup.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
for pid in $(ps -ef | grep "firefox" | awk '{print $2}'); do kill -9 ${pid}; done > /dev/null 2>&1
|
||||
|
|
@ -22,7 +22,7 @@ except NameError:
|
|||
# clone link
|
||||
CLONE = "https://github.com/ekultek/zeus-scanner.git"
|
||||
# current version <major.minor.commit.patch ID>
|
||||
VERSION = "1.0.42.49ab"
|
||||
VERSION = "1.0.42.6ad5"
|
||||
# colors to output depending on the version
|
||||
VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30}
|
||||
# version string formatting
|
||||
|
|
@ -51,8 +51,11 @@ DEFAULT_USER_AGENT = "Zeus-Scanner(v{})::Python->v{}.{}".format(
|
|||
URL_QUERY_REGEX = re.compile(r"(.*)[?|#](.*){1}\=(.*)")
|
||||
# regex to recognize a URL
|
||||
URL_REGEX = re.compile(r"((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)")
|
||||
# path to the auto clean tool
|
||||
CLEANUP_TOOL_PATH = "{}/etc/scripts/cleanup.sh".format(os.getcwd())
|
||||
# paths to sqlmap and nmap
|
||||
TOOL_PATHS = "{}/bin/paths/path_config.ini".format(os.getcwd())
|
||||
# path to store robot.txt page in
|
||||
ROBOTS_PAGE_PATH = "{}/log/robots".format(os.getcwd())
|
||||
# URL's that are extracted from Google's ban URL
|
||||
EXTRACTED_URL_LOG = "{}/log/extracted-url-log".format(os.getcwd())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
try:
|
||||
import urllib2 # python 2
|
||||
|
|
@ -6,6 +7,7 @@ except ImportError:
|
|||
import urllib.request as urllib2 # python 3
|
||||
import json
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
from base64 import b64decode
|
||||
|
||||
|
|
@ -21,6 +23,24 @@ from lib.core.settings import (
|
|||
)
|
||||
|
||||
|
||||
def get_browser_version():
|
||||
try:
|
||||
output = subprocess.check_output(['firefox', '--version'])
|
||||
except Exception:
|
||||
logger.error(set_color(
|
||||
"failed to run forefox...", level=50
|
||||
))
|
||||
return "failed to start"
|
||||
try:
|
||||
major, minor = map(int, re.search(r"(\d+).(\d+)", output).groups())
|
||||
except Exception:
|
||||
logger.error(set_color(
|
||||
"failed to parse '{}' for version number...".format(output), level=50
|
||||
))
|
||||
return "failed to gather"
|
||||
return "Version: ({}.{})".format(major, minor)
|
||||
|
||||
|
||||
def __get_encoded_string(filename="{}/var/auto_issue/oauth"):
|
||||
with open(filename.format(os.getcwd())) as data:
|
||||
return data.read()
|
||||
|
|
@ -86,11 +106,13 @@ def request_issue_creation():
|
|||
issue_data = {
|
||||
"title": issue_title,
|
||||
"body": "Zeus version:\n`{}`\n\n"
|
||||
"Firefox version:\n`{}`\n\n"
|
||||
"Error info:\n```{}````\n\n"
|
||||
"Running details:\n`{}`\n\n"
|
||||
"Commands used:\n`{}`\n\n"
|
||||
"Log file info:\n```{}```".format(
|
||||
VERSION,
|
||||
get_browser_version(),
|
||||
str(stacktrace),
|
||||
str(platform.platform()),
|
||||
" ".join(sys.argv),
|
||||
|
|
|
|||
33
zeus.py
33
zeus.py
|
|
@ -10,6 +10,7 @@ try:
|
|||
import http.client as http_client # Python 3
|
||||
except ImportError:
|
||||
import httplib as http_client # Python 2
|
||||
from selenium.webdriver.remote.errorhandler import WebDriverException
|
||||
|
||||
from var import blackwidow
|
||||
from var.google_search import search
|
||||
|
|
@ -48,7 +49,8 @@ from lib.core.settings import (
|
|||
get_true_url,
|
||||
fix_log_file,
|
||||
DEFAULT_USER_AGENT,
|
||||
SPIDER_LOG_PATH
|
||||
SPIDER_LOG_PATH,
|
||||
CLEANUP_TOOL_PATH
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
@ -644,6 +646,35 @@ if __name__ == "__main__":
|
|||
"do not interrupt the browser when selenium is running, "
|
||||
"it will cause Zeus to crash...", level=30
|
||||
))
|
||||
except WebDriverException as e:
|
||||
if "connection refused" in str(e):
|
||||
logger.fatal(set_color(
|
||||
"there are to many sessions of firefox opened and selenium cannot "
|
||||
"create a new one...", level=50
|
||||
))
|
||||
do_autoclean = prompt(
|
||||
"would you like to attempt auto clean", opts="yN"
|
||||
)
|
||||
if do_autoclean.lower().startswith("y"):
|
||||
logger.warning(set_color(
|
||||
"this will kill all instances of the firefox web browser...", level=30
|
||||
))
|
||||
subprocess.call(["sudo", "sh", CLEANUP_TOOL_PATH])
|
||||
logger.info(set_color(
|
||||
"all open sessions of firefox killed, it should be safe to re-run "
|
||||
"Zeus..."
|
||||
))
|
||||
else:
|
||||
logger.info(set_color(
|
||||
"kill off the open sessions of firefox and re-run Zeus..."
|
||||
))
|
||||
shutdown()
|
||||
else:
|
||||
logger.exception(set_color(
|
||||
"Zeus has run into an unexpected error from selenium webdriver and cannot continue "
|
||||
"error info '{}'...".format(str(e))
|
||||
))
|
||||
request_issue_creation()
|
||||
except Exception as e:
|
||||
if "url did not match a true url" in str(e).lower():
|
||||
logger.error(set_color(
|
||||
|
|
|
|||
Loading…
Reference in a new issue