Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0eb2c40

Browse files
committed
code refactoring
1 parent 7e2984b commit 0eb2c40

11 files changed

Lines changed: 22 additions & 22 deletions

File tree

lib/controller/checks.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,11 @@
4444
from lib.core.exception import sqlmapUserQuitException
4545
from lib.core.session import setString
4646
from lib.core.session import setRegexp
47+
from lib.core.unescaper import unescaper
4748
from lib.request.connect import Connect as Request
4849
from lib.request.templates import getPageTemplate
49-
from plugins.dbms.firebird.syntax import Syntax as Firebird
50-
from plugins.dbms.postgresql.syntax import Syntax as PostgreSQL
51-
from plugins.dbms.mssqlserver.syntax import Syntax as MSSQLServer
52-
from plugins.dbms.oracle.syntax import Syntax as Oracle
53-
from plugins.dbms.mysql.syntax import Syntax as MySQL
54-
from plugins.dbms.access.syntax import Syntax as Access
55-
from plugins.dbms.sybase.syntax import Syntax as Sybase
56-
from plugins.dbms.sqlite.syntax import Syntax as SQLite
57-
from plugins.dbms.maxdb.syntax import Syntax as MaxDB
5850

5951
def unescape(string, dbms):
60-
unescaper = {
61-
"Access": Access.unescape,
62-
"Firebird": Firebird.unescape,
63-
"MaxDB": MaxDB.unescape,
64-
"Microsoft SQL Server": MSSQLServer.unescape,
65-
"MySQL": MySQL.unescape,
66-
"Oracle": Oracle.unescape,
67-
"PostgreSQL": PostgreSQL.unescape,
68-
"SQLite": SQLite.unescape,
69-
"Sybase": Sybase.unescape
70-
}
71-
7252
if dbms in unescaper and "WAITFOR DELAY " not in string:
7353
return unescaper[dbms](string)
7454
else:

lib/core/unescaper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10-
class Unescaper:
10+
from lib.core.datatype import advancedDict
11+
12+
class Unescaper(advancedDict):
1113
def __init__(self):
1214
self.__unescaper = None
1315

plugins/dbms/access/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import ACCESS_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -32,4 +33,5 @@ def __init__(self):
3233
Miscellaneous.__init__(self)
3334
Takeover.__init__(self)
3435

36+
unescaper[DBMS.ACCESS] = AccessMap.unescape
3537
unescaper.setUnescape(AccessMap.unescape)

plugins/dbms/firebird/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import FIREBIRD_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -32,4 +33,5 @@ def __init__(self):
3233
Miscellaneous.__init__(self)
3334
Takeover.__init__(self)
3435

36+
unescaper[DBMS.FIREBIRD] = FirebirdMap.unescape
3537
unescaper.setUnescape(FirebirdMap.unescape)

plugins/dbms/maxdb/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import MAXDB_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -32,4 +33,5 @@ def __init__(self):
3233
Miscellaneous.__init__(self)
3334
Takeover.__init__(self)
3435

36+
unescaper[DBMS.MAXDB] = MaxDBMap.unescape
3537
unescaper.setUnescape(MaxDBMap.unescape)

plugins/dbms/mssqlserver/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import MSSQL_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -33,4 +34,5 @@ def __init__(self):
3334
Miscellaneous.__init__(self)
3435
Takeover.__init__(self)
3536

37+
unescaper[DBMS.MSSQL] = MSSQLServerMap.unescape
3638
unescaper.setUnescape(MSSQLServerMap.unescape)

plugins/dbms/mysql/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import MYSQL_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -38,4 +39,5 @@ def __init__(self):
3839
Miscellaneous.__init__(self)
3940
Takeover.__init__(self)
4041

42+
unescaper[DBMS.MYSQL] = MySQLMap.unescape
4143
unescaper.setUnescape(MySQLMap.unescape)

plugins/dbms/oracle/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import ORACLE_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -32,4 +33,5 @@ def __init__(self):
3233
Miscellaneous.__init__(self)
3334
Takeover.__init__(self)
3435

36+
unescaper[DBMS.ORACLE] = OracleMap.unescape
3537
unescaper.setUnescape(OracleMap.unescape)

plugins/dbms/postgresql/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import PGSQL_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -39,4 +40,5 @@ def __init__(self):
3940
Miscellaneous.__init__(self)
4041
Takeover.__init__(self)
4142

43+
unescaper[DBMS.PGSQL] = PostgreSQLMap.unescape
4244
unescaper.setUnescape(PostgreSQLMap.unescape)

plugins/dbms/sqlite/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.enums import DBMS
1011
from lib.core.settings import SQLITE_SYSTEM_DBS
1112
from lib.core.unescaper import unescaper
1213

@@ -32,4 +33,5 @@ def __init__(self):
3233
Miscellaneous.__init__(self)
3334
Takeover.__init__(self)
3435

36+
unescaper[DBMS.SQLITE] = SQLiteMap.unescape
3537
unescaper.setUnescape(SQLiteMap.unescape)

0 commit comments

Comments
 (0)