From 0eb2c408a912e8941d1b3d2c766523d57ba96705 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 9 Dec 2010 16:49:02 +0000 Subject: [PATCH] code refactoring --- lib/controller/checks.py | 22 +--------------------- lib/core/unescaper.py | 4 +++- plugins/dbms/access/__init__.py | 2 ++ plugins/dbms/firebird/__init__.py | 2 ++ plugins/dbms/maxdb/__init__.py | 2 ++ plugins/dbms/mssqlserver/__init__.py | 2 ++ plugins/dbms/mysql/__init__.py | 2 ++ plugins/dbms/oracle/__init__.py | 2 ++ plugins/dbms/postgresql/__init__.py | 2 ++ plugins/dbms/sqlite/__init__.py | 2 ++ plugins/dbms/sybase/__init__.py | 2 ++ 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index c520af1d4..5470d7906 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -44,31 +44,11 @@ from lib.core.exception import sqlmapSiteTooDynamic from lib.core.exception import sqlmapUserQuitException from lib.core.session import setString from lib.core.session import setRegexp +from lib.core.unescaper import unescaper from lib.request.connect import Connect as Request from lib.request.templates import getPageTemplate -from plugins.dbms.firebird.syntax import Syntax as Firebird -from plugins.dbms.postgresql.syntax import Syntax as PostgreSQL -from plugins.dbms.mssqlserver.syntax import Syntax as MSSQLServer -from plugins.dbms.oracle.syntax import Syntax as Oracle -from plugins.dbms.mysql.syntax import Syntax as MySQL -from plugins.dbms.access.syntax import Syntax as Access -from plugins.dbms.sybase.syntax import Syntax as Sybase -from plugins.dbms.sqlite.syntax import Syntax as SQLite -from plugins.dbms.maxdb.syntax import Syntax as MaxDB def unescape(string, dbms): - unescaper = { - "Access": Access.unescape, - "Firebird": Firebird.unescape, - "MaxDB": MaxDB.unescape, - "Microsoft SQL Server": MSSQLServer.unescape, - "MySQL": MySQL.unescape, - "Oracle": Oracle.unescape, - "PostgreSQL": PostgreSQL.unescape, - "SQLite": SQLite.unescape, - "Sybase": Sybase.unescape - } - if dbms in unescaper and "WAITFOR DELAY " not in string: return unescaper[dbms](string) else: diff --git a/lib/core/unescaper.py b/lib/core/unescaper.py index 5d1216ff0..8b9169396 100644 --- a/lib/core/unescaper.py +++ b/lib/core/unescaper.py @@ -7,7 +7,9 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ -class Unescaper: +from lib.core.datatype import advancedDict + +class Unescaper(advancedDict): def __init__(self): self.__unescaper = None diff --git a/plugins/dbms/access/__init__.py b/plugins/dbms/access/__init__.py index 87a993a05..c74d3d868 100644 --- a/plugins/dbms/access/__init__.py +++ b/plugins/dbms/access/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import ACCESS_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -32,4 +33,5 @@ class AccessMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Tak Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.ACCESS] = AccessMap.unescape unescaper.setUnescape(AccessMap.unescape) diff --git a/plugins/dbms/firebird/__init__.py b/plugins/dbms/firebird/__init__.py index dc0ddedc7..887ef2955 100644 --- a/plugins/dbms/firebird/__init__.py +++ b/plugins/dbms/firebird/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import FIREBIRD_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -32,4 +33,5 @@ class FirebirdMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, T Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.FIREBIRD] = FirebirdMap.unescape unescaper.setUnescape(FirebirdMap.unescape) diff --git a/plugins/dbms/maxdb/__init__.py b/plugins/dbms/maxdb/__init__.py index 6f23727d2..89d790cb9 100644 --- a/plugins/dbms/maxdb/__init__.py +++ b/plugins/dbms/maxdb/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import MAXDB_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -32,4 +33,5 @@ class MaxDBMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Take Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.MAXDB] = MaxDBMap.unescape unescaper.setUnescape(MaxDBMap.unescape) diff --git a/plugins/dbms/mssqlserver/__init__.py b/plugins/dbms/mssqlserver/__init__.py index eb64cb7d8..b01f5ccf9 100644 --- a/plugins/dbms/mssqlserver/__init__.py +++ b/plugins/dbms/mssqlserver/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import MSSQL_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -33,4 +34,5 @@ class MSSQLServerMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.MSSQL] = MSSQLServerMap.unescape unescaper.setUnescape(MSSQLServerMap.unescape) diff --git a/plugins/dbms/mysql/__init__.py b/plugins/dbms/mysql/__init__.py index 914d3de34..6373c2faa 100644 --- a/plugins/dbms/mysql/__init__.py +++ b/plugins/dbms/mysql/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import MYSQL_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -38,4 +39,5 @@ class MySQLMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Take Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.MYSQL] = MySQLMap.unescape unescaper.setUnescape(MySQLMap.unescape) diff --git a/plugins/dbms/oracle/__init__.py b/plugins/dbms/oracle/__init__.py index 07268ad60..a1d98e810 100644 --- a/plugins/dbms/oracle/__init__.py +++ b/plugins/dbms/oracle/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import ORACLE_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -32,4 +33,5 @@ class OracleMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Tak Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.ORACLE] = OracleMap.unescape unescaper.setUnescape(OracleMap.unescape) diff --git a/plugins/dbms/postgresql/__init__.py b/plugins/dbms/postgresql/__init__.py index c497ca1eb..ed25ca692 100644 --- a/plugins/dbms/postgresql/__init__.py +++ b/plugins/dbms/postgresql/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import PGSQL_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -39,4 +40,5 @@ class PostgreSQLMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.PGSQL] = PostgreSQLMap.unescape unescaper.setUnescape(PostgreSQLMap.unescape) diff --git a/plugins/dbms/sqlite/__init__.py b/plugins/dbms/sqlite/__init__.py index ce21fdad1..d9240e1d0 100644 --- a/plugins/dbms/sqlite/__init__.py +++ b/plugins/dbms/sqlite/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import SQLITE_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -32,4 +33,5 @@ class SQLiteMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Tak Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.SQLITE] = SQLiteMap.unescape unescaper.setUnescape(SQLiteMap.unescape) diff --git a/plugins/dbms/sybase/__init__.py b/plugins/dbms/sybase/__init__.py index 8cf43df21..afb2cee50 100644 --- a/plugins/dbms/sybase/__init__.py +++ b/plugins/dbms/sybase/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.enums import DBMS from lib.core.settings import SYBASE_SYSTEM_DBS from lib.core.unescaper import unescaper @@ -32,4 +33,5 @@ class SybaseMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Tak Miscellaneous.__init__(self) Takeover.__init__(self) + unescaper[DBMS.SYBASE] = SybaseMap.unescape unescaper.setUnescape(SybaseMap.unescape)