From 7e1ff1bb8eef6173ec11a8247de722a413c9c975 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 4 Feb 2013 15:26:44 +0100 Subject: [PATCH] Same refactoring as the last commit --- lib/core/common.py | 1 - plugins/dbms/access/fingerprint.py | 7 ++----- plugins/dbms/db2/fingerprint.py | 4 +--- plugins/dbms/firebird/fingerprint.py | 4 +--- plugins/dbms/mssqlserver/fingerprint.py | 4 +--- plugins/dbms/mysql/fingerprint.py | 1 - plugins/dbms/postgresql/fingerprint.py | 7 ++----- 7 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 50acbfedf..8de427906 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -125,7 +125,6 @@ from lib.core.settings import SUPPORTED_DBMS from lib.core.settings import TEXT_TAG_REGEX from lib.core.settings import TIME_STDEV_COEFF from lib.core.settings import UNICODE_ENCODING -from lib.core.settings import UNKNOWN_DBMS from lib.core.settings import UNKNOWN_DBMS_VERSION from lib.core.settings import URI_QUESTION_MARKER from lib.core.settings import URLENCODE_CHAR_LIMIT diff --git a/plugins/dbms/access/fingerprint.py b/plugins/dbms/access/fingerprint.py index 3e5a784f7..057c61bd3 100644 --- a/plugins/dbms/access/fingerprint.py +++ b/plugins/dbms/access/fingerprint.py @@ -10,7 +10,6 @@ import re from lib.core.common import Backend from lib.core.common import Format from lib.core.common import getCurrentThreadData -from lib.core.common import randomInt from lib.core.common import randomStr from lib.core.common import wasLastResponseDBMSError from lib.core.data import conf @@ -67,8 +66,7 @@ class Fingerprint(GenericFingerprint): negate = True table = table[1:] - randInt = randomInt() - result = inject.checkBooleanExpression("EXISTS(SELECT * FROM %s WHERE %d=%d)" % (table, randInt, randInt)) + result = inject.checkBooleanExpression("EXISTS(SELECT * FROM %s WHERE [RANDNUM]=[RANDNUM])" % table) if result is None: result = False @@ -91,9 +89,8 @@ class Fingerprint(GenericFingerprint): infoMsg = "searching for database directory" logger.info(infoMsg) - randInt = randomInt() randStr = randomStr() - inject.checkBooleanExpression("EXISTS(SELECT * FROM %s.%s WHERE %d=%d)" % (randStr, randStr, randInt, randInt)) + inject.checkBooleanExpression("EXISTS(SELECT * FROM %s.%s WHERE [RANDNUM]=[RANDNUM])" % (randStr, randStr)) if wasLastResponseDBMSError(): threadData = getCurrentThreadData() diff --git a/plugins/dbms/db2/fingerprint.py b/plugins/dbms/db2/fingerprint.py index 997b31902..65755745f 100644 --- a/plugins/dbms/db2/fingerprint.py +++ b/plugins/dbms/db2/fingerprint.py @@ -8,7 +8,6 @@ See the file 'doc/COPYING' for copying permission from lib.core.common import Backend from lib.core.common import Format -from lib.core.common import randomInt from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -90,8 +89,7 @@ class Fingerprint(GenericFingerprint): logMsg = "testing %s" % DBMS.DB2 logger.info(logMsg) - randInt = randomInt() - result = inject.checkBooleanExpression("%d=(SELECT %d FROM SYSIBM.SYSDUMMY1)" % (randInt, randInt)) + result = inject.checkBooleanExpression("[RANDNUM]=(SELECT [RANDNUM] FROM SYSIBM.SYSDUMMY1)") if result: logMsg = "confirming %s" % DBMS.DB2 diff --git a/plugins/dbms/firebird/fingerprint.py b/plugins/dbms/firebird/fingerprint.py index 8d192d3cb..cc027c601 100644 --- a/plugins/dbms/firebird/fingerprint.py +++ b/plugins/dbms/firebird/fingerprint.py @@ -10,7 +10,6 @@ import re from lib.core.common import Backend from lib.core.common import Format from lib.core.common import getUnicode -from lib.core.common import randomInt from lib.core.common import randomRange from lib.core.data import conf from lib.core.data import kb @@ -122,8 +121,7 @@ class Fingerprint(GenericFingerprint): infoMsg = "testing %s" % DBMS.FIREBIRD logger.info(infoMsg) - randInt = randomInt() - result = inject.checkBooleanExpression("(SELECT COUNT(*) FROM RDB$DATABASE WHERE %d=%d)>0" % (randInt, randInt)) + result = inject.checkBooleanExpression("(SELECT COUNT(*) FROM RDB$DATABASE WHERE [RANDNUM]=[RANDNUM])>0") if result: infoMsg = "confirming %s" % DBMS.FIREBIRD diff --git a/plugins/dbms/mssqlserver/fingerprint.py b/plugins/dbms/mssqlserver/fingerprint.py index 1e3ba250a..fc249b689 100644 --- a/plugins/dbms/mssqlserver/fingerprint.py +++ b/plugins/dbms/mssqlserver/fingerprint.py @@ -8,7 +8,6 @@ See the file 'doc/COPYING' for copying permission from lib.core.common import Backend from lib.core.common import Format from lib.core.common import getUnicode -from lib.core.common import randomInt from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -85,8 +84,7 @@ class Fingerprint(GenericFingerprint): if conf.direct: result = True else: - randInt = randomInt() - result = inject.checkBooleanExpression("BINARY_CHECKSUM(%d)=BINARY_CHECKSUM(%d)" % (randInt, randInt)) + result = inject.checkBooleanExpression("BINARY_CHECKSUM([RANDNUM])=BINARY_CHECKSUM([RANDNUM])") if result: infoMsg = "confirming %s" % DBMS.MSSQL diff --git a/plugins/dbms/mysql/fingerprint.py b/plugins/dbms/mysql/fingerprint.py index 14b5a997c..f4cdc1a11 100644 --- a/plugins/dbms/mysql/fingerprint.py +++ b/plugins/dbms/mysql/fingerprint.py @@ -10,7 +10,6 @@ import re from lib.core.common import Backend from lib.core.common import Format from lib.core.common import getUnicode -from lib.core.common import randomInt from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger diff --git a/plugins/dbms/postgresql/fingerprint.py b/plugins/dbms/postgresql/fingerprint.py index d92dfcfbd..5f6e83017 100644 --- a/plugins/dbms/postgresql/fingerprint.py +++ b/plugins/dbms/postgresql/fingerprint.py @@ -7,8 +7,6 @@ See the file 'doc/COPYING' for copying permission from lib.core.common import Backend from lib.core.common import Format -from lib.core.common import getUnicode -from lib.core.common import randomInt from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -76,14 +74,13 @@ class Fingerprint(GenericFingerprint): infoMsg = "testing %s" % DBMS.PGSQL logger.info(infoMsg) - randInt = getUnicode(randomInt(1)) - result = inject.checkBooleanExpression("%s::int=%s" % (randInt, randInt)) + result = inject.checkBooleanExpression("[RANDNUM]::int=[RANDNUM]") if result: infoMsg = "confirming %s" % DBMS.PGSQL logger.info(infoMsg) - result = inject.checkBooleanExpression("COALESCE(%s, NULL)=%s" % (randInt, randInt)) + result = inject.checkBooleanExpression("COALESCE([RANDNUM], NULL)=[RANDNUM]") if not result: warnMsg = "the back-end DBMS is not %s" % DBMS.PGSQL