diff --git a/.github/workflows/opencanary_tests.yml b/.github/workflows/opencanary_tests.yml index a6e0ec8..d4a6f2b 100644 --- a/.github/workflows/opencanary_tests.yml +++ b/.github/workflows/opencanary_tests.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: python-version: ["3.7", "3.8", "3.9", "3.10"] - os: ["ubuntu-18.04", "ubuntu-20.04", "macos-10.15", "macos-11"] + os: ["ubuntu-18.04", "ubuntu-20.04", "macos-11"] fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/bin/honeycred b/bin/honeycred index 53d7628..c7b619a 100755 --- a/bin/honeycred +++ b/bin/honeycred @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import sys @@ -10,6 +9,3 @@ if len(sys.argv) != 2: exit(1) print(cryptcontext.encrypt(sys.argv[1])) - - - diff --git a/bin/opencanaryd b/bin/opencanaryd index 2a94a23..ef032d4 100755 --- a/bin/opencanaryd +++ b/bin/opencanaryd @@ -33,7 +33,7 @@ if [ "${cmd}" == "--start" ]; then elif [ "${cmd}" == "--dev" ]; then sudo -E "${DIR}/twistd" -noy "${DIR}/opencanary.tac" elif [ "${cmd}" == "--usermodule" ]; then - usermodconf=$(python -c "from __future__ import print_function; from pkg_resources import resource_filename; print(resource_filename('opencanary', 'data/settings-usermodule.json'))") + usermodconf=$(python -c "from pkg_resources import resource_filename; print(resource_filename('opencanary', 'data/settings-usermodule.json'))") if [ -f opencanary.conf ]; then if ! diff -q opencanary.conf "${usermodconf}" 2>&1 >/dev/null; then @@ -57,11 +57,7 @@ elif [ "${cmd}" == "--copyconfig" ]; then echo "A config file already exists at /etc/opencanaryd/opencanary.conf, please move it first" exit 1 fi - if [[ -f `which python` ]] ; then - defaultconf=$(python -c "from __future__ import print_function; from pkg_resources import resource_filename; print(resource_filename('opencanary', 'data/settings.json'))") - else - defaultconf=$(python3 -c "from pkg_resources import resource_filename; print(resource_filename('opencanary', 'data/settings.json'))") - fi + defaultconf=$(python3 -c "from pkg_resources import resource_filename; print(resource_filename('opencanary', 'data/settings.json'))") sudo -E mkdir -p /etc/opencanaryd sudo -E cp "${defaultconf}" /etc/opencanaryd/opencanary.conf echo -e "[*] A sample config file is ready /etc/opencanaryd/opencanary.conf\n" diff --git a/opencanary/config.py b/opencanary/config.py index 56b517f..4eb42ae 100644 --- a/opencanary/config.py +++ b/opencanary/config.py @@ -1,4 +1,3 @@ -from __future__ import print_function from six import iteritems import os, sys, json, copy, socket, itertools, string, subprocess from os.path import expanduser @@ -7,24 +6,6 @@ SAMPLE_SETTINGS = resource_filename(__name__, 'data/settings.json') SETTINGS = 'opencanary.conf' -PY3 = sys.version_info > (3,) - -# Only check unicode on Python 2, In Python 3 unicode is the default and we can just return the input. -if sys.version_info[0] < 3: - def byteify(input): - if isinstance(input, dict): - return {byteify(key): byteify(value) - for key, value in iteritems(input)} - elif isinstance(input, list): - return [byteify(element) for element in input] - elif isinstance(input, unicode): - return input.encode('utf-8') - else: - return input -else: - def byteify(input): - return input - def expand_vars(var): """Recursively replace environment variables in a dictionary, list or string with their respective values.""" @@ -51,7 +32,6 @@ def __init__(self, configfile=SETTINGS): with open(fname, "r") as f: print("[-] Using config file: %s" % fname) self.__config = json.load(f) - self.__config = byteify(self.__config) self.__config = expand_vars(self.__config) return except IOError as e: diff --git a/opencanary/logger.py b/opencanary/logger.py index 10caff6..3bbe99e 100644 --- a/opencanary/logger.py +++ b/opencanary/logger.py @@ -1,4 +1,3 @@ -from __future__ import print_function import simplejson as json import logging.config import socket diff --git a/opencanary/modules/mssql.py b/opencanary/modules/mssql.py index de3cc2d..a332f3d 100644 --- a/opencanary/modules/mssql.py +++ b/opencanary/modules/mssql.py @@ -1,4 +1,3 @@ -from __future__ import print_function from opencanary.modules import CanaryService from opencanary.config import ConfigException diff --git a/opencanary/modules/mysql.py b/opencanary/modules/mysql.py index 5ce27fc..21a1539 100644 --- a/opencanary/modules/mysql.py +++ b/opencanary/modules/mysql.py @@ -1,5 +1,5 @@ from opencanary.modules import CanaryService -from opencanary.config import ConfigException, PY3 +from opencanary.config import ConfigException from twisted.protocols.policies import TimeoutMixin from twisted.internet.protocol import Protocol @@ -52,27 +52,18 @@ def parse_auth(data): username = data[offset:i] i += 1 - if PY3: - plen = data[i] - else: - plen = struct.unpack('B', data[i])[0] + plen = data[i] i+=1 if plen == 0: return username, None - if PY3: - password="".join("{:02x}".format(c) for c in data[i:i+plen]) - else: - password="".join("{:02x}".format(ord(c)) for c in data[i:i+plen]) + password="".join("{:02x}".format(c) for c in data[i:i+plen]) return username, password def consume_packet(self): if len(self._buffer) < MySQL.HEADER_LEN: return None, None length = struct.unpack(' (3,) - -# Only check unicode on Python 2, In Python 3 unicode is the default and we can just return the input. -if sys.version_info[0] < 3: - jinja_version = '2.10.1' -else: - jinja_version = '3.0.1' - def read(rel_path): here = os.path.abspath(os.path.dirname(__file__)) @@ -39,14 +31,12 @@ def get_version(rel_path): 'PyPDF2==1.26.0', 'fpdf==1.7.2', 'passlib==1.7.1', - 'Jinja2=={}'.format(jinja_version), + 'Jinja2==3.0.1', 'ntlmlib==0.72', 'bcrypt==3.1.7', 'setuptools==44.0.0', 'hpfeeds==3.0.0'] -if sys.version_info.major < 3: - requirements.append('wsgiref==0.1.2') setup( name='opencanary', @@ -76,7 +66,6 @@ def get_version(rel_path): "Operating System :: Unix", "Operating System :: POSIX :: Linux", "Operating System :: POSIX :: BSD :: FreeBSD", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6",