From 74b83f1101358771375ab2862b3ed353a2813eb7 Mon Sep 17 00:00:00 2001 From: Mehtab Zafar Date: Wed, 18 Mar 2020 21:09:22 +0530 Subject: [PATCH 1/2] Use YAML format for tanner configuration (#371) * Use YAML format for tanner configuration * Add pyyaml to requirements.txt * remove usage of self in TannerConfig class Since the old config was using staticmethod decorator I decided to use those * Fix the format of YAML config * Use metaclass to setup default values * Update config test * place default config file under tanner/data This has to be done so TravisCI can include a file ## To make a commit, type your commit message and press CTRL-ENTER. ## To cancel the commit, close the window. To sign off on the commit, ## press CTRL-S. ## ## You may also reference or close a GitHub issue with this commit. ## To do so, type `#` followed by the `tab` key. You will be shown a ## list of issues related to the current repo. You may also type ## `owner/repo#` plus the `tab` key to reference an issue in a ## different GitHub repo. setup.py | 3 ++- tanner/config.py | 4 ++-- tanner/{ => data}/config.yaml | 0 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index edcecad..01aa755 100644 --- a/setup.py +++ b/setup.py @@ -12,5 +12,6 @@ setup(name='Tanner', scripts=['bin/tanner', 'bin/tannerweb', 'bin/tannerapi'], data_files=[('/opt/tanner/db/', ['tanner/data/db_config.json', 'tanner/data/GeoLite2-City.mmdb']), ('/opt/tanner/data/', ['tanner/data/dorks.pickle', 'tanner/data/crawler_user_agents.txt', - 'tanner/files/engines/mako.py', 'tanner/files/engines/tornado.py'])] + 'tanner/files/engines/mako.py', 'tanner/files/engines/tornado.py', + 'tanner/data/config.yamls'])] ) diff --git a/tanner/config.py b/tanner/config.py index c5aa423..788a56e 100644 --- a/tanner/config.py +++ b/tanner/config.py @@ -18,7 +18,7 @@ class Meta(type): def parse_default_configs(path): return read_config(path) - default_config = parse_default_configs("/opt/tanner/config.yaml") + default_config = parse_default_configs("/opt/tanner/data/config.yaml") attribs.update({ 'default_config': default_config, 'parse_default_configs': parse_default_configs @@ -32,7 +32,7 @@ class TannerConfig(metaclass=Meta): @staticmethod def set_default_config(default_config_path): - TannerConfig.default_config = read_config("/opt/tanner/config.yaml") + TannerConfig.default_config = read_config(default_config_path) @staticmethod def set_config(config_path): diff --git a/tanner/config.yaml b/tanner/data/config.yaml similarity index 100% rename from tanner/config.yaml rename to tanner/data/config.yaml * Use global variable instead of Meta class * Make read_config function a static method under ReadConfig class * Move read_config function under TannerConfig class * removed get_section() and used get() in its place Also added a check for old config format * Update config docs * catch exception while reading the config file. Also added some comment for config docs. And removed a comma from a config --- docs/source/config.rst | 128 +++++++++++++++++++++++++++++------- requirements.txt | 1 + setup.py | 11 ++-- tanner/config.py | 91 ++++++------------------- tanner/data/config.yaml | 92 ++++++++++++++++++++++++++ tanner/emulators/base.py | 13 +++- tanner/tests/test_config.py | 21 +----- 7 files changed, 237 insertions(+), 120 deletions(-) create mode 100644 tanner/data/config.yaml diff --git a/docs/source/config.rst b/docs/source/config.rst index e03d2fec..6c7eee79 100644 --- a/docs/source/config.rst +++ b/docs/source/config.rst @@ -1,10 +1,12 @@ Configuration file ================== -Tanner uses ``INI`` like format for configuration file. It's value can specified by using ``config`` flag +Tanner uses ``YAML`` like format for configuration file. It's value can specified by using ``config`` flag. + +The use of ``INI`` configuration file is obsolete now. There are 8 different sections : * **DATA** - + # Data configuration :db_config: Location of SQLI database configuration :dorks: Location of dorks :user_dorks: Location of user dorks @@ -13,11 +15,11 @@ There are 8 different sections : :host: The host at which Tanner is running :port: The port at which Tanner is running * **WEB** - + # Tanner web configuration :host: The host at which Tanner Web UI is running :port: The port at which Tanner Web UI is running * **API** - + # Tanner API configuration :Host: The host at which Tanner API is running :Port: The port at which Tanner API is running * **PHPOX** @@ -25,17 +27,18 @@ There are 8 different sections : :Host: The host at which PHPOX is running :Port: The port at which PHPOX is running * **REDIS** - + # Configure redis if it's running on some different port or network. + :host: The host address at which redis is running :port: The port at which which redis is running :poolsize: The poolsize of redis server :timeout: The duration of timeout for redis server * **EMULATORS** - + :root_dir: The root directory for emulators that need data storing such as SQLI and LFI. Data will be stored in this directory * **EMULATOR_ENABLED** - + # Enable or disable emulators by setting value true or false respectively. :sqli: True if this emulator is enabled else False :rfi: True if this emulator is enabled else False :lfi: True if this emulator is enabled else False @@ -73,23 +76,100 @@ There are 8 different sections : :enabled: Check local(temporary) logging is enabled :PATH: Location of file for local(temporary) logging -If no file is specified, following json will be used as default: +If no file is specified, following YAML will be used as default: .. code-block:: python - {'DATA': {'db_config': '/opt/tanner/db/db_config.json', 'dorks': '/opt/tanner/data/dorks.pickle', - 'user_dorks': '/opt/tanner/data/user_dorks.pickle', - 'TANNER': {'host': '0.0.0.0', 'port': 8090}, - 'WEB': {'host': '0.0.0.0', 'port': 8091}, - 'API': {'host': '0.0.0.0', 'port': 8092}, - 'PHPOX': {'host': '0.0.0.0', 'port': 8088}, - 'REDIS': {'host': 'localhost', 'port': 6379, 'poolsize': 80, 'timeout': 1}, - 'EMULATORS': {'root_dir': '/opt/tanner'}, - 'EMULATOR_ENABLED': {'sqli': 'True', 'rfi': 'True', 'lfi': 'True', 'xss': 'True', 'cmd_exec': 'True'}, - 'SQLI': {'type':'SQLITE', 'db_name': 'tanner_db', 'host':'localhost', 'user':'root', 'password':'user_pass'}, - 'DOCKER': {'host_image': 'busybox:latest'}, - 'LOGGER': {'log_file': '/opt/tanner/tanner.log'}, - 'MONGO': {'enabled': 'False', 'URI': 'mongodb://localhost'}, - 'LOCALLOG': {'enabled': 'False', 'PATH': '/tmp/tanner_report.json'}, - 'CLEANLOG': {'enabled': 'False'} - } + DATA: + db_config: /opt/tanner/db/db_config.json + dorks: /opt/tanner/data/dorks.pickle + user_dorks: /opt/tanner/data/user_dorks.pickle + crawler_stats: /opt/tanner/data/crawler_user_agents.txt + geo_db: /opt/tanner/db/GeoLite2-City.mmdb + tornado: /opt/tanner/data/tornado.py + mako: /opt/tanner/data/mako.py + + TANNER: + host: 0.0.0.0 + port: 8090 + + WEB: + host: 0.0.0.0 + port: 8091, + + API: + host: 0.0.0.0 + port: 8092 + auth: False + auth_signature: tanner_api_auth + + PHPOX: + host: 0.0.0.0 + port: 8088 + + REDIS: + host: localhost + port: 6379 + poolsize: 80 + timeout: 1 + + EMULATORS: + root_dir: /opt/tanner + + EMULATOR_ENABLED: + sqli: True + rfi: True + lfi: True + xss: True + cmd_exec: True + php_code_injection: True + php_object_injection: True + crlf: True + xxe_injection: True + template_injection: True + + SQLI: + type: SQLITE + db_name: tanner_db + host: localhost + user: root + password: user_pass + + XXE_INJECTION: + OUT_OF_BAND: False + + RFI: + allow_insecure: False + + DOCKER: + host_image: busybox:latest + + LOGGER: + log_debug: /opt/tanner/tanner.log + log_err: /opt/tanner/tanner.err + + MONGO: + enabled: False + URI: mongodb://localhost + + HPFEEDS: + enabled: False + HOST: localhost + PORT: 10000 + IDENT: '' + SECRET: '' + CHANNEL: tanner.events + + LOCALLOG: + enabled: False + PATH: /tmp/tanner_report.json + + CLEANLOG: + enabled: False + + REMOTE_DOCKERFILE: + GITHUB: "https://raw.githubusercontent.com/mushorg/tanner/master/docker/tanner/template_injection/Dockerfile" + + SESSIONS: + delete_timeout: 300 + diff --git a/requirements.txt b/requirements.txt index 390d62d0..b7423b88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,3 +16,4 @@ aiodocker tornado mako pyjwt +pyyaml diff --git a/setup.py b/setup.py index e49d70b2..20fb49b9 100644 --- a/setup.py +++ b/setup.py @@ -9,11 +9,8 @@ url='https://github.com/mushorg/tanner', packages=find_packages(exclude=['*.pyc']), scripts=['bin/tanner', 'bin/tannerweb', 'bin/tannerapi'], - data_files=[('/opt/tanner/db/', ['tanner/data/db_config.json', - 'tanner/data/GeoLite2-City.mmdb']), - ('/opt/tanner/data/', ['tanner/data/dorks.pickle', - 'tanner/data/crawler_user_agents.txt', - 'tanner/files/engines/mako.py', - 'tanner/files/engines/tornado.py'] - )] + data_files=[('/opt/tanner/db/', ['tanner/data/db_config.json', 'tanner/data/GeoLite2-City.mmdb']), + ('/opt/tanner/data/', ['tanner/data/dorks.pickle', 'tanner/data/crawler_user_agents.txt', + 'tanner/files/engines/mako.py', 'tanner/files/engines/tornado.py', + 'tanner/data/config.yaml'])] ) diff --git a/tanner/config.py b/tanner/config.py index 3b015fe6..08ac19e1 100644 --- a/tanner/config.py +++ b/tanner/config.py @@ -1,92 +1,43 @@ -import configparser import logging import os import sys -LOGGER = logging.getLogger(__name__) +import yaml -config_template = {'DATA': {'db_config': '/opt/tanner/db/db_config.json', - 'dorks': '/opt/tanner/data/dorks.pickle', - 'user_dorks': '/opt/tanner/data/user_dorks.pickle', - 'crawler_stats': '/opt/tanner/data/crawler_user_agents.txt', - 'geo_db': '/opt/tanner/db/GeoLite2-City.mmdb', - 'tornado': '/opt/tanner/data/tornado.py', - 'mako': '/opt/tanner/data/mako.py' - }, - 'TANNER': {'host': '0.0.0.0', 'port': 8090}, - 'WEB': {'host': '0.0.0.0', 'port': 8091}, - 'API': {'host': '0.0.0.0', 'port': 8092, 'auth': False, 'auth_signature': 'tanner_api_auth'}, - 'PHPOX': {'host': '0.0.0.0', 'port': 8088}, - 'REDIS': {'host': 'localhost', 'port': 6379, 'poolsize': 80, 'timeout': 1}, - 'EMULATORS': {'root_dir': '/opt/tanner'}, - 'EMULATOR_ENABLED': {'sqli': True, 'rfi': True, 'lfi': True, 'xss': True, 'cmd_exec': True, - 'php_code_injection': True, 'php_object_injection': True, "crlf": True, - "xxe_injection": True, "template_injection": True}, - 'SQLI': {'type': 'SQLITE', 'db_name': 'tanner_db', 'host': 'localhost', 'user': 'root', - 'password': 'user_pass'}, - 'XXE_INJECTION': {'OUT_OF_BAND': False}, - 'RFI': {"allow_insecure": False}, - 'DOCKER': {'host_image': 'busybox:latest'}, - 'LOGGER': {'log_debug': '/opt/tanner/tanner.log', 'log_err': '/opt/tanner/tanner.err'}, - 'MONGO': {'enabled': False, 'URI': 'mongodb://localhost'}, - 'HPFEEDS': {'enabled': False, 'HOST': 'localhost', 'PORT': 10000, 'IDENT': '', 'SECRET': '', - 'CHANNEL': 'tanner.events'}, - 'LOCALLOG': {'enabled': False, 'PATH': '/tmp/tanner_report.json'}, - 'CLEANLOG': {'enabled': False}, - 'REMOTE_DOCKERFILE': {'GITHUB': "https://raw.githubusercontent.com/mushorg/tanner/master/docker/" - "tanner/template_injection/Dockerfile"}, - 'SESSIONS': {"delete_timeout": 300} - } +LOGGER = logging.getLogger(__name__) class TannerConfig(): config = None + @staticmethod + def read_config(path): + config_values = {} + try: + with open(path, 'r') as f: + config_values = yaml.load(f, Loader=yaml.FullLoader) + except yaml.parser.ParserError as e: + print("Couldn't properly parse the config file. Please use properly formatted YAML config.") + sys.exit(1) + return config_values + @staticmethod def set_config(config_path): - cfg = configparser.ConfigParser() if not os.path.exists(config_path): - print("Config file {} doesn't exist. Check the config path or use default".format(config_path)) + print("Config file {} doesn't exist. Check the config path or use default".format( + config_path)) sys.exit(1) - cfg.read(config_path) - TannerConfig.config = cfg + TannerConfig.config = TannerConfig.read_config(config_path) @staticmethod def get(section, value): - res = None - if TannerConfig.config is not None: - try: - convert_type = type(config_template[section][value]) - if convert_type is bool: - res = TannerConfig.config.getboolean(section, value) - else: - res = convert_type(TannerConfig.config.get(section, value)) - except (configparser.NoOptionError, configparser.NoSectionError): - LOGGER.warning("Error in config, default value will be used. Section: %s Value: %s", section, value) - res = config_template[section][value] + try: + res = TannerConfig.config[section][value] + except (KeyError, TypeError): + res = DEFAULT_CONFIG[section][value] - else: - res = config_template[section][value] return res - @staticmethod - def get_section(section): - res = {} - if TannerConfig.config is not None: - try: - sec = TannerConfig.config[section] - for k, v in sec.items(): - convert_type = type(config_template[section][k]) - if convert_type is bool: - res[k] = TannerConfig.config[section].getboolean(k) - else: - res[k] = convert_type(v) - except (configparser.NoOptionError, configparser.NoSectionError): - LOGGER.warning("Error in config, default value will be used. Section: %s Value: %s", section) - res = config_template[section] - - else: - res = config_template[section] - return res +DEFAULT_CONFIG = TannerConfig.read_config("/opt/tanner/data/config.yaml") diff --git a/tanner/data/config.yaml b/tanner/data/config.yaml new file mode 100644 index 00000000..ad3a2443 --- /dev/null +++ b/tanner/data/config.yaml @@ -0,0 +1,92 @@ +DATA: + db_config: /opt/tanner/db/db_config.json + dorks: /opt/tanner/data/dorks.pickle + user_dorks: /opt/tanner/data/user_dorks.pickle + crawler_stats: /opt/tanner/data/crawler_user_agents.txt + geo_db: /opt/tanner/db/GeoLite2-City.mmdb + tornado: /opt/tanner/data/tornado.py + mako: /opt/tanner/data/mako.py + +TANNER: + host: 0.0.0.0 + port: 8090 + +WEB: + host: 0.0.0.0 + port: 8091 + +API: + host: 0.0.0.0 + port: 8092 + auth: False + auth_signature: tanner_api_auth + +PHPOX: + host: 0.0.0.0 + port: 8088 + +REDIS: + host: localhost + port: 6379 + poolsize: 80 + timeout: 1 + +EMULATORS: + root_dir: /opt/tanner + +EMULATOR_ENABLED: + sqli: True + rfi: True + lfi: True + xss: True + cmd_exec: True + php_code_injection: True + php_object_injection: True + crlf: True + xxe_injection: True + template_injection: True + +SQLI: + type: SQLITE + db_name: tanner_db + host: localhost + user: root + password: user_pass + +XXE_INJECTION: + OUT_OF_BAND: False + +RFI: + allow_insecure: False + +DOCKER: + host_image: busybox:latest + +LOGGER: + log_debug: /opt/tanner/tanner.log + log_err: /opt/tanner/tanner.err + +MONGO: + enabled: False + URI: mongodb://localhost + +HPFEEDS: + enabled: False + HOST: localhost + PORT: 10000 + IDENT: '' + SECRET: '' + CHANNEL: tanner.events + +LOCALLOG: + enabled: False + PATH: /tmp/tanner_report.json + +CLEANLOG: + enabled: False + +REMOTE_DOCKERFILE: + GITHUB: "https://raw.githubusercontent.com/mushorg/tanner/master/docker/tanner/template_injection/Dockerfile" + +SESSIONS: + delete_timeout: 300 diff --git a/tanner/emulators/base.py b/tanner/emulators/base.py index 895b2840..9a141e0f 100644 --- a/tanner/emulators/base.py +++ b/tanner/emulators/base.py @@ -12,7 +12,18 @@ class BaseHandler: def __init__(self, base_dir, db_name, loop=None): - self.emulator_enabled = TannerConfig.get_section('EMULATOR_ENABLED') + self.emulator_enabled = { + 'rfi': TannerConfig.get('EMULATOR_ENABLED', 'rfi'), + 'sqli': TannerConfig.get('EMULATOR_ENABLED', 'sqli'), + 'lfi': TannerConfig.get('EMULATOR_ENABLED', 'lfi'), + 'xss': TannerConfig.get('EMULATOR_ENABLED', 'xss'), + 'cmd_exec': TannerConfig.get('EMULATOR_ENABLED', 'cmd_exec'), + 'php_code_injection': TannerConfig.get('EMULATOR_ENABLED', 'php_code_injection'), + 'php_object_injection': TannerConfig.get('EMULATOR_ENABLED', 'php_object_injection'), + 'crlf': TannerConfig.get('EMULATOR_ENABLED', 'crlf'), + 'xxe_injection': TannerConfig.get('EMULATOR_ENABLED', 'xxe_injection'), + 'template_injection': TannerConfig.get('EMULATOR_ENABLED', 'template_injection') + } self.emulators = { 'rfi': rfi.RfiEmulator(base_dir, loop=loop, allow_insecure=TannerConfig.get("RFI", 'allow_insecure')) diff --git a/tanner/tests/test_config.py b/tanner/tests/test_config.py index b862c9f4..b0274490 100644 --- a/tanner/tests/test_config.py +++ b/tanner/tests/test_config.py @@ -1,6 +1,7 @@ import configparser import os import unittest +import yaml from unittest import mock from tanner import config @@ -65,24 +66,8 @@ def test_get_when_file_exists(self): self.assertEqual(data, convert_type(assertion_data)) def test_get_when_file_dont_exists(self): - config_template = { - 'DATA': {'db_config': '/opt/tanner/db/db_config.json', 'dorks': '/opt/tanner/data/dorks.pickle', - 'user_dorks': '/opt/tanner/data/user_dorks.pickle'}, - 'TANNER': {'host': '0.0.0.0', 'port': 8090}, - 'WEB': {'host': '0.0.0.0', 'port': 8091}, - 'API': {'host': '0.0.0.0', 'port': 8092}, - 'PHPOX': {'host': '0.0.0.0', 'port': 8088}, - 'REDIS': {'host': 'localhost', 'port': 6379, 'poolsize': 80, 'timeout': 1}, - 'EMULATORS': {'root_dir': '/opt/tanner'}, - 'EMULATOR_ENABLED': {'sqli': True, 'rfi': True, 'lfi': True, 'xss': True, 'cmd_exec': True}, - 'SQLI': {'type': 'SQLITE', 'db_name': 'tanner_db', 'host': 'localhost', 'user': 'root', - 'password': 'user_pass'}, - 'DOCKER': {'host_image': 'busybox:latest'}, - 'LOGGER': {'log_debug': '/opt/tanner/tanner.log', 'log_err': '/opt/tanner/tanner.err'}, - 'MONGO': {'enabled': False, 'URI': 'mongodb://localhost'}, - 'LOCALLOG': {'enabled': False, 'PATH': '/tmp/tanner_report.json'}, - 'CLEANLOG': {'enabled': False} - } + with open("/opt/tanner/data/config.yaml", 'r') as f: + config_template = yaml.load(f, Loader=yaml.FullLoader) for section in config_template: for value, assertion_data in config_template[section].items(): From 71095303770a9d55a3c06b8dff9314c0ddabb507 Mon Sep 17 00:00:00 2001 From: Marco Ochse Date: Tue, 31 Mar 2020 11:34:36 +0200 Subject: [PATCH 2/2] Prepare for new config.yaml (#382) * new config.yaml * add switch for config * fix docker error --- docker/tanner/Dockerfile | 6 +-- docker/tanner/dist/config.py | 92 ---------------------------------- docker/tanner/dist/config.yaml | 92 ++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 docker/tanner/dist/config.py create mode 100644 docker/tanner/dist/config.yaml diff --git a/docker/tanner/Dockerfile b/docker/tanner/Dockerfile index 9437109a..f06420f0 100644 --- a/docker/tanner/Dockerfile +++ b/docker/tanner/Dockerfile @@ -16,8 +16,8 @@ RUN sed -i 's/dl-cdn/dl-2/g' /etc/apk/repositories && \ python3 \ python3-dev && \ # Setup Tanner - git clone --depth=1 https://github.com/mushorg/tanner /opt/tanner && \ - cp /root/dist/config.py /opt/tanner/tanner/ && \ + git clone --depth=1 https://github.com/mushorg/tanner -b develop /opt/tanner && \ + cp /root/dist/config.yaml /opt/tanner/tanner/data/ && \ cd /opt/tanner/ && \ pip3 install --no-cache-dir setuptools && \ pip3 install --no-cache-dir -r requirements.txt && \ @@ -37,4 +37,4 @@ RUN sed -i 's/dl-cdn/dl-2/g' /etc/apk/repositories && \ # Start tanner USER nobody:nobody WORKDIR /opt/tanner -CMD tanner +CMD tanner --config /opt/tanner/tanner/data/config.yaml diff --git a/docker/tanner/dist/config.py b/docker/tanner/dist/config.py deleted file mode 100644 index 51b3a46c..00000000 --- a/docker/tanner/dist/config.py +++ /dev/null @@ -1,92 +0,0 @@ -import configparser -import logging -import os -import sys - -LOGGER = logging.getLogger(__name__) - -config_template = {'DATA': {'db_config': '/opt/tanner/db/db_config.json', - 'dorks': '/opt/tanner/data/dorks.pickle', - 'user_dorks': '/opt/tanner/data/user_dorks.pickle', - 'crawler_stats': '/opt/tanner/data/crawler_user_agents.txt', - 'geo_db': '/opt/tanner/db/GeoLite2-City.mmdb', - 'tornado': '/opt/tanner/data/tornado.py', - 'mako': '/opt/tanner/data/mako.py' - }, - 'TANNER': {'host': 'tanner', 'port': 8090}, - 'WEB': {'host': 'tanner_web', 'port': 8091}, - 'API': {'host': 'tanner_api', 'port': 8092, 'auth': False, 'auth_signature': 'tanner_api_auth'}, - 'PHPOX': {'host': 'tanner_phpox', 'port': 8088}, - 'REDIS': {'host': 'tanner_redis', 'port': 6379, 'poolsize': 80, 'timeout': 1}, - 'EMULATORS': {'root_dir': '/tmp/tanner/emulators'}, - 'EMULATOR_ENABLED': {'sqli': True, 'rfi': True, 'lfi': False, 'xss': True, 'cmd_exec': False, - 'php_code_injection': True, 'php_object_injection': True, "crlf": True, - 'xxe_injection': True, 'template_injection': False}, - 'SQLI': {'type': 'SQLITE', 'db_name': 'tanner_db', 'host': 'localhost', 'user': 'root', - 'password': 'user_pass'}, - 'XXE_INJECTION': {'OUT_OF_BAND': False}, - 'RFI': {"allow_insecure": True}, - 'DOCKER': {'host_image': 'busybox:latest'}, - 'LOGGER': {'log_debug': '/tmp/tanner/tanner.log', 'log_err': '/tmp/tanner/tanner.err'}, - 'MONGO': {'enabled': False, 'URI': 'mongodb://localhost'}, - 'HPFEEDS': {'enabled': False, 'HOST': 'localhost', 'PORT': 10000, 'IDENT': '', 'SECRET': '', - 'CHANNEL': 'tanner.events'}, - 'LOCALLOG': {'enabled': False, 'PATH': '/tmp/tanner_report.json'}, - 'CLEANLOG': {'enabled': False}, - 'REMOTE_DOCKERFILE': {'GITHUB': "https://raw.githubusercontent.com/mushorg/tanner/master/docker/" - "tanner/template_injection/Dockerfile"}, - 'SESSIONS': {"delete_timeout": 300} - } - - -class TannerConfig(): - config = None - - @staticmethod - def set_config(config_path): - cfg = configparser.ConfigParser() - if not os.path.exists(config_path): - print("Config file {} doesn't exist. Check the config path or use default".format(config_path)) - sys.exit(1) - - cfg.read(config_path) - TannerConfig.config = cfg - - @staticmethod - def get(section, value): - res = None - if TannerConfig.config is not None: - try: - convert_type = type(config_template[section][value]) - if convert_type is bool: - res = TannerConfig.config.getboolean(section, value) - else: - res = convert_type(TannerConfig.config.get(section, value)) - except (configparser.NoOptionError, configparser.NoSectionError): - LOGGER.warning("Error in config, default value will be used. Section: %s Value: %s", section, value) - res = config_template[section][value] - - else: - res = config_template[section][value] - return res - - @staticmethod - def get_section(section): - res = {} - if TannerConfig.config is not None: - try: - sec = TannerConfig.config[section] - for k, v in sec.items(): - convert_type = type(config_template[section][k]) - if convert_type is bool: - res[k] = TannerConfig.config[section].getboolean(k) - else: - res[k] = convert_type(v) - except (configparser.NoOptionError, configparser.NoSectionError): - LOGGER.warning("Error in config, default value will be used. Section: %s Value: %s", section) - res = config_template[section] - - else: - res = config_template[section] - - return res diff --git a/docker/tanner/dist/config.yaml b/docker/tanner/dist/config.yaml new file mode 100644 index 00000000..9452df11 --- /dev/null +++ b/docker/tanner/dist/config.yaml @@ -0,0 +1,92 @@ +DATA: + db_config: /opt/tanner/db/db_config.json + dorks: /opt/tanner/data/dorks.pickle + user_dorks: /opt/tanner/data/user_dorks.pickle + crawler_stats: /opt/tanner/data/crawler_user_agents.txt + geo_db: /opt/tanner/db/GeoLite2-City.mmdb + tornado: /opt/tanner/data/tornado.py + mako: /opt/tanner/data/mako.py + +TANNER: + host: tanner + port: 8090 + +WEB: + host: tanner_web + port: 8091 + +API: + host: tanner_api + port: 8092 + auth: False + auth_signature: tanner_api_auth + +PHPOX: + host: tanner_phpox + port: 8088 + +REDIS: + host: tanner_redis + port: 6379 + poolsize: 80 + timeout: 1 + +EMULATORS: + root_dir: /tmp/tanner/emulators + +EMULATOR_ENABLED: + sqli: True + rfi: True + lfi: False + xss: True + cmd_exec: False + php_code_injection: True + php_object_injection: True + crlf: True + xxe_injection: True + template_injection: False + +SQLI: + type: SQLITE + db_name: tanner_db + host: localhost + user: root + password: user_pass + +XXE_INJECTION: + OUT_OF_BAND: False + +RFI: + allow_insecure: True + +DOCKER: + host_image: busybox:latest + +LOGGER: + log_debug: /tmp/tanner/tanner.log + log_err: /tmp/tanner/tanner.err + +MONGO: + enabled: False + URI: mongodb://localhost + +HPFEEDS: + enabled: False + HOST: localhost + PORT: 10000 + IDENT: '' + SECRET: '' + CHANNEL: tanner.events + +LOCALLOG: + enabled: True + PATH: /tmp/tanner/tanner_report.json + +CLEANLOG: + enabled: False + +REMOTE_DOCKERFILE: + GITHUB: "https://raw.githubusercontent.com/mushorg/tanner/master/docker/tanner/template_injection/Dockerfile" + +SESSIONS: + delete_timeout: 300