From 3779531540288840ca9b98c9f83d8f435e346117 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 23 Jan 2020 23:27:33 +0100 Subject: [PATCH] Adding support for TiDB --- lib/core/agent.py | 2 +- lib/core/enums.py | 1 + lib/core/settings.py | 2 +- plugins/dbms/mysql/fingerprint.py | 8 +++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index 301118201..d3f4eedc7 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -385,7 +385,7 @@ class Agent(object): for _ in set(re.findall(r"\[RANDSTR(?:\d+)?\]", payload, re.I)): payload = payload.replace(_, randomStr()) - if hashDBRetrieve(HASHDB_KEYS.DBMS_FORK) == FORK.MEMSQL: + if hashDBRetrieve(HASHDB_KEYS.DBMS_FORK) in (FORK.MEMSQL, FORK.TIDB): payload = re.sub(r"(?i)\bORD\(", "ASCII(", payload) payload = re.sub(r"(?i)\bMID\(", "SUBSTR(", payload) payload = re.sub(r"(?i)\bNCHAR\b", "CHAR", payload) diff --git a/lib/core/enums.py b/lib/core/enums.py index 76d0760af..6b37ee1da 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -75,6 +75,7 @@ class FORK(object): MARIADB = "MariaDB" MEMSQL = "MemSQL" COCKROACHDB = "CockroachDB" + TIDB = "TiDB" class CUSTOM_LOGGING(object): PAYLOAD = 9 diff --git a/lib/core/settings.py b/lib/core/settings.py index b36d22d6c..498ac3d2f 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.4.1.44" +VERSION = "1.4.1.45" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/plugins/dbms/mysql/fingerprint.py b/plugins/dbms/mysql/fingerprint.py index e6ea36765..b8c35dfbf 100644 --- a/plugins/dbms/mysql/fingerprint.py +++ b/plugins/dbms/mysql/fingerprint.py @@ -99,7 +99,13 @@ class Fingerprint(GenericFingerprint): fork = hashDBRetrieve(HASHDB_KEYS.DBMS_FORK) if fork is None: - fork = inject.checkBooleanExpression("VERSION() LIKE '%MariaDB%'") and FORK.MARIADB or "" + if inject.checkBooleanExpression("VERSION() LIKE '%MariaDB%'"): + fork = FORK.MARIADB + elif inject.checkBooleanExpression("VERSION() LIKE '%TiDB%'"): + fork = FORK.TIDB + else: + fork = "" + hashDBWrite(HASHDB_KEYS.DBMS_FORK, fork) value = ""