From f38ec5f65fa510fc7426769e95028d85b03b84f2 Mon Sep 17 00:00:00 2001 From: ekultek Date: Fri, 29 Sep 2017 14:28:53 -0500 Subject: [PATCH] adding support for python 3 (issue #7) if you find any issues with python3 please make an issue there --- lib/attacks/sqlmap_scan/__init__.py | 5 ++++- lib/attacks/xss_scan/__init__.py | 5 ++++- lib/settings.py | 2 +- var/google_search/search.py | 29 ++++++++++++++++++++++------- zeus.py | 1 + 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lib/attacks/sqlmap_scan/__init__.py b/lib/attacks/sqlmap_scan/__init__.py index 7699a9e..f6ba744 100644 --- a/lib/attacks/sqlmap_scan/__init__.py +++ b/lib/attacks/sqlmap_scan/__init__.py @@ -1,6 +1,9 @@ import re import json -import urllib2 +try: + import urllib2 # python 2 +except ImportError: + import urllib as urllib2 # python 3 import subprocess import requests diff --git a/lib/attacks/xss_scan/__init__.py b/lib/attacks/xss_scan/__init__.py index c8340f3..d3a47f1 100644 --- a/lib/attacks/xss_scan/__init__.py +++ b/lib/attacks/xss_scan/__init__.py @@ -1,6 +1,9 @@ import os import re -import urlparse +try: + import urlparse # python 2 +except ImportError: + import urllib.parse as urlparse # python 3 import tempfile import requests diff --git a/lib/settings.py b/lib/settings.py index db1e559..8858665 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -22,7 +22,7 @@ except NameError: # clone link CLONE = "https://github.com/ekultek/zeus-scanner.git" # current version -VERSION = "1.0.21.6ea5" +VERSION = "1.0.22" # 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 8a6ecb5..5c395ea 100644 --- a/var/google_search/search.py +++ b/var/google_search/search.py @@ -1,7 +1,10 @@ import os import re import time -import urllib +try: + from urllib import unquote +except ImportError: + from urllib.parse import unquote import requests from selenium import webdriver @@ -20,6 +23,11 @@ from lib.settings import ( create_dir, ) +try: + unicode +except NameError: + unicode = str + def bypass_ip_block(url, content_sep=("continue=", "Fid", "%")): """ @@ -157,6 +165,7 @@ def parse_search_results( Parse a webpage from Google for URL's with a GET(query) parameter """ exclude = "google" or "webcache" or "youtube" + splitter = "&" create_dir(dirname.format(os.getcwd())) full_file_path = "{}/{}".format( @@ -201,7 +210,8 @@ def parse_search_results( proxy_string_info = "setting proxy to {}..." if proxy_string is not None: - proxy_string_info = proxy_string_info.format(''.join(proxy_string.keys()) + "://" + ''.join(proxy_string.values())) + proxy_string_info = proxy_string_info.format( + ''.join(proxy_string.keys()) + "://" + ''.join(proxy_string.values())) else: proxy_string_info = "no proxy configuration detected..." @@ -239,14 +249,19 @@ def parse_search_results( retval = set() for urls in list(found_urls): for url in list(urls): - url = urllib.unquote(url) + url = unquote(url) if URL_QUERY_REGEX.match(url) and exclude not in url: - if type(url) is unicode: + if isinstance(url, unicode): url = str(url).encode("utf-8") if verbose: - logger.debug(set_color( - "found '{}'...".format(url.split("&")[0]), level=10 - )) + try: + logger.debug(set_color( + "found '{}'...".format(url.split(splitter)[0]), level=10 + )) + except TypeError: + logger.debug(set_color( + "found '{}'...".format(str(url).split(splitter)[0]), level=10 + )) retval.add(url.split("&")[0]) logger.info(set_color( "found a total of {} URL's with a GET parameter...".format(len(retval)) diff --git a/zeus.py b/zeus.py index 7c7e85e..c724ddf 100755 --- a/zeus.py +++ b/zeus.py @@ -9,6 +9,7 @@ try: import http.client as http_client # Python 3 except ImportError: import httplib as http_client # Python 2 + from var import blackwidow from var.google_search import search from lib.errors import InvalidInputProvided