mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 12:41:30 +00:00
Added support to directly connect also to Microsoft SQL Server database.
Fixed direct connection to always use the same query as of UNION query SQL injection (= one query with multiple columns/entries output). Minor fixes to Firebird/Access/SQLite connectors to use connector's execute()/fetchall() as wrapper for third-party libraries' methods. Forced conf.timeout to 10 seconds when directly connecting to database. Slightly improved regular expression to parse -d parameter. Added import check for all connectors' third-party libraries. Code refactoring: * Moved conf.direct request to direct() function in lib/request/direct.py (code reused where needed). * Back-delegated to generic connector close() and other methods.
This commit is contained in:
@@ -37,6 +37,7 @@ from lib.core.data import logger
|
||||
from lib.core.data import queries
|
||||
from lib.core.data import temp
|
||||
from lib.request.connect import Connect as Request
|
||||
from lib.request.direct import direct
|
||||
from lib.core.settings import SQL_STATEMENTS
|
||||
from lib.techniques.inband.union.use import unionUse
|
||||
from lib.techniques.blind.inference import bisection
|
||||
@@ -352,33 +353,7 @@ def getValue(expression, blind=True, inband=True, fromUser=False, expected=None,
|
||||
"""
|
||||
|
||||
if conf.direct:
|
||||
expression = agent.payloadDirect(expression)
|
||||
values = None
|
||||
select = False
|
||||
|
||||
if kb.dbms == "Oracle" and expression.startswith("SELECT ") and " FROM " not in expression:
|
||||
expression = "%s FROM DUAL" % expression
|
||||
|
||||
for sqlTitle, sqlStatements in SQL_STATEMENTS.items():
|
||||
for sqlStatement in sqlStatements:
|
||||
if expression.lower().startswith(sqlStatement) and sqlTitle == "SQL SELECT statement":
|
||||
select = True
|
||||
break
|
||||
|
||||
if select:
|
||||
values = conf.dbmsConnector.select(expression)
|
||||
else:
|
||||
values = conf.dbmsConnector.execute(expression)
|
||||
|
||||
if values is None or len(values) == 0:
|
||||
return None
|
||||
elif len(values) == 1:
|
||||
if len(values[0]) == 1:
|
||||
return str(list(values)[0][0])
|
||||
else:
|
||||
return list(values)
|
||||
else:
|
||||
return values
|
||||
return direct(expression)
|
||||
|
||||
expression = cleanQuery(expression)
|
||||
expression = expandAsteriskForColumns(expression)
|
||||
@@ -418,25 +393,7 @@ def goStacked(expression, silent=False):
|
||||
expression = cleanQuery(expression)
|
||||
|
||||
if conf.direct:
|
||||
expression = agent.payloadDirect(expression)
|
||||
values = None
|
||||
select = False
|
||||
|
||||
if kb.dbms == "Oracle" and expression.startswith("SELECT ") and " FROM " not in expression:
|
||||
expression = "%s FROM DUAL" % expression
|
||||
|
||||
for sqlTitle, sqlStatements in SQL_STATEMENTS.items():
|
||||
for sqlStatement in sqlStatements:
|
||||
if expression.lower().startswith(sqlStatement) and sqlTitle == "SQL SELECT statement":
|
||||
select = True
|
||||
break
|
||||
|
||||
if select:
|
||||
values = conf.dbmsConnector.select(expression)
|
||||
else:
|
||||
values = conf.dbmsConnector.execute(expression)
|
||||
|
||||
return None, None
|
||||
return direct(expression), None
|
||||
|
||||
debugMsg = "query: %s" % expression
|
||||
logger.debug(debugMsg)
|
||||
|
||||
Reference in New Issue
Block a user