From 70f6eab7151f5054edae3943a48cf40c80b828ff Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 2 Nov 2010 12:08:28 +0000 Subject: [PATCH] minor update --- lib/core/agent.py | 2 +- lib/core/common.py | 32 +++++++++++++------------- lib/utils/resume.py | 3 ++- plugins/dbms/firebird/fingerprint.py | 6 ++--- plugins/dbms/maxdb/fingerprint.py | 2 +- plugins/dbms/oracle/fingerprint.py | 2 +- plugins/dbms/postgresql/fingerprint.py | 2 +- plugins/dbms/sqlite/fingerprint.py | 2 +- plugins/dbms/sybase/fingerprint.py | 2 +- 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index f5e1becc6..1895755ab 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -528,7 +528,7 @@ class Agent: fromFrom = limitedQuery[fromIndex+1:] orderBy = False - if kb.dbms in ( "MySQL", "PostgreSQL", "SQLite" ): + if kb.dbms in ( DBMS.MYSQL, DBMS.POSTGRESQL, DBMS.SQLITE ): limitStr = queries[kb.dbms].limit.query % (num, 1) limitedQuery += " %s" % limitStr diff --git a/lib/core/common.py b/lib/core/common.py index c842c3663..d5d3857a0 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -711,18 +711,18 @@ def parseTargetDirect(): errMsg += "or 'access://DATABASE_FILEPATH'" raise sqlmapSyntaxException, errMsg - dbmsDict = { "Microsoft SQL Server": [MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"], - "MySQL": [MYSQL_ALIASES, "python-mysqldb", "http://mysql-python.sourceforge.net/"], - "PostgreSQL": [PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"], - "Oracle": [ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"], - "SQLite": [SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"], - "Access": [ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/"], - "Firebird": [FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/"] } + dbmsDict = { DBMS.MSSQL: [MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"], + DBMS.MYSQL: [MYSQL_ALIASES, "python-mysqldb", "http://mysql-python.sourceforge.net/"], + DBMS.POSTGRESQL: [PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"], + DBMS.ORACLE: [ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"], + DBMS.SQLITE: [SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"], + DBMS.ACCESS: [ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/"], + DBMS.FIREBIRD: [FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/"] } for dbmsName, data in dbmsDict.items(): if conf.dbms in data[0]: try: - if dbmsName in ('Access', 'SQLite', 'Firebird'): + if dbmsName in (DBMS.ACCESS, DBMS.SQLITE, DBMS.FIREBIRD): if remote: warnMsg = "direct connection over the network for " warnMsg += "%s DBMS is not supported" % dbmsName @@ -734,7 +734,7 @@ def parseTargetDirect(): errMsg = "missing remote connection details" raise sqlmapSyntaxException, errMsg - if dbmsName == "Microsoft SQL Server": + if dbmsName == DBMS.MSSQL: import _mssql import pymssql @@ -744,17 +744,17 @@ def parseTargetDirect(): errMsg += "http://sourceforge.net/projects/pymssql/files/pymssql/1.0.2/" raise sqlmapMissingDependence, errMsg - elif dbmsName == "MySQL": + elif dbmsName == DBMS.MYSQL: import MySQLdb - elif dbmsName == "PostgreSQL": + elif dbmsName == DBMS.POSTGRESQL: import psycopg2 - elif dbmsName == "Oracle": + elif dbmsName == DBMS.ORACLE: import cx_Oracle - elif dbmsName == "SQLite": + elif dbmsName == DBMS.SQLITE: import sqlite3 - elif dbmsName == "Access": + elif dbmsName == DBMS.ACCESS: import pyodbc - elif dbmsName == "Firebird": + elif dbmsName == DBMS.FIREBIRD: import kinterbasdb except ImportError, _: errMsg = "sqlmap requires '%s' third-party library " % data[1] @@ -904,7 +904,7 @@ def parseUnionPage(output, expression, partial=False, condition=None, sort=True) def getDelayQuery(andCond=False): query = None - if kb.dbms in ("MySQL", "PostgreSQL"): + if kb.dbms in (DBMS.MYSQL, DBMS.POSTGRESQL): if not kb.data.banner: conf.dbmsHandler.getVersionFromBanner() diff --git a/lib/utils/resume.py b/lib/utils/resume.py index 044469025..e78ec2a37 100644 --- a/lib/utils/resume.py +++ b/lib/utils/resume.py @@ -22,6 +22,7 @@ from lib.core.data import logger from lib.core.data import queries from lib.core.unescaper import unescaper from lib.techniques.blind.inference import bisection +from lib.core.settings import DBMS from lib.core.settings import DUMP_START_MARKER from lib.core.settings import DUMP_STOP_MARKER from lib.core.settings import DUMP_DEL_MARKER @@ -58,7 +59,7 @@ def queryOutputLength(expression, payload): if selectDistinctExpr: lengthExpr = "SELECT %s FROM (%s)" % (lengthQuery % regExpr, expression) - if kb.dbms in ( "MySQL", "PostgreSQL" ): + if kb.dbms in ( DBMS.MYSQL, DBMS.POSTGRESQL ): lengthExpr += " AS %s" % randomStr(lowercase=True) elif select: lengthExpr = expression.replace(regExpr, lengthQuery % regExpr, 1) diff --git a/plugins/dbms/firebird/fingerprint.py b/plugins/dbms/firebird/fingerprint.py index 2407443f3..a24dec6a8 100644 --- a/plugins/dbms/firebird/fingerprint.py +++ b/plugins/dbms/firebird/fingerprint.py @@ -44,11 +44,11 @@ class Fingerprint(GenericFingerprint): value += "%s\n" % dbmsOsFp value += "back-end DBMS: " - + if not conf.extensiveFp: - value += "Firebird" + value += DBMS.FIREBIRD return value - + actVer = formatDBMSfp() + " (%s)" % (self.__dialectCheck()) blank = " " * 15 value += "active fingerprint: %s" % actVer diff --git a/plugins/dbms/maxdb/fingerprint.py b/plugins/dbms/maxdb/fingerprint.py index 3930aa867..e105d7125 100644 --- a/plugins/dbms/maxdb/fingerprint.py +++ b/plugins/dbms/maxdb/fingerprint.py @@ -87,7 +87,7 @@ class Fingerprint(GenericFingerprint): value += "back-end DBMS: " if not conf.extensiveFp: - value += "SAP MaxDB" + value += DBMS.MAXDB return value actVer = formatDBMSfp() + " (%s)" % self.__versionCheck() diff --git a/plugins/dbms/oracle/fingerprint.py b/plugins/dbms/oracle/fingerprint.py index 2793b8427..345847542 100644 --- a/plugins/dbms/oracle/fingerprint.py +++ b/plugins/dbms/oracle/fingerprint.py @@ -44,7 +44,7 @@ class Fingerprint(GenericFingerprint): value += "back-end DBMS: " if not conf.extensiveFp: - value += "Oracle" + value += DBMS.ORACLE return value actVer = formatDBMSfp() diff --git a/plugins/dbms/postgresql/fingerprint.py b/plugins/dbms/postgresql/fingerprint.py index 29d598ca9..bbc517bb4 100644 --- a/plugins/dbms/postgresql/fingerprint.py +++ b/plugins/dbms/postgresql/fingerprint.py @@ -47,7 +47,7 @@ class Fingerprint(GenericFingerprint): value += "back-end DBMS: " if not conf.extensiveFp: - value += "PostgreSQL" + value += DBMS.POSTGRESQL return value actVer = formatDBMSfp() diff --git a/plugins/dbms/sqlite/fingerprint.py b/plugins/dbms/sqlite/fingerprint.py index a050509c9..4324e4fda 100644 --- a/plugins/dbms/sqlite/fingerprint.py +++ b/plugins/dbms/sqlite/fingerprint.py @@ -42,7 +42,7 @@ class Fingerprint(GenericFingerprint): value += "back-end DBMS: " if not conf.extensiveFp: - value += "SQLite" + value += DBMS.SQLITE return value actVer = formatDBMSfp() diff --git a/plugins/dbms/sybase/fingerprint.py b/plugins/dbms/sybase/fingerprint.py index 24578249b..a97688742 100644 --- a/plugins/dbms/sybase/fingerprint.py +++ b/plugins/dbms/sybase/fingerprint.py @@ -43,7 +43,7 @@ class Fingerprint(GenericFingerprint): value += "back-end DBMS: " if not conf.extensiveFp: - value += "Sybase" + value += DBMS.SYBASE return value actVer = formatDBMSfp()