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

Skip to content

Commit b2dc443

Browse files
committed
Fixes #1559
1 parent 4d57692 commit b2dc443

1 file changed

Lines changed: 29 additions & 24 deletions

File tree

plugins/generic/custom.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from lib.core.data import logger
1818
from lib.core.dicts import SQL_STATEMENTS
1919
from lib.core.enums import AUTOCOMPLETE_TYPE
20+
from lib.core.exception import SqlmapNoneDataException
2021
from lib.core.settings import NULL
2122
from lib.core.settings import PARAMETER_SPLITTING_REGEX
2223
from lib.core.shell import autoCompletion
@@ -35,38 +36,42 @@ def sqlQuery(self, query):
3536
sqlType = None
3637
query = query.rstrip(';')
3738

38-
for sqlTitle, sqlStatements in SQL_STATEMENTS.items():
39-
for sqlStatement in sqlStatements:
40-
if query.lower().startswith(sqlStatement):
41-
sqlType = sqlTitle
42-
break
39+
try:
40+
for sqlTitle, sqlStatements in SQL_STATEMENTS.items():
41+
for sqlStatement in sqlStatements:
42+
if query.lower().startswith(sqlStatement):
43+
sqlType = sqlTitle
44+
break
4345

44-
if not any(_ in query.upper() for _ in ("OPENROWSET", "INTO")) and (not sqlType or "SELECT" in sqlType):
45-
infoMsg = "fetching %s query output: '%s'" % (sqlType if sqlType is not None else "SQL", query)
46-
logger.info(infoMsg)
46+
if not any(_ in query.upper() for _ in ("OPENROWSET", "INTO")) and (not sqlType or "SELECT" in sqlType):
47+
infoMsg = "fetching %s query output: '%s'" % (sqlType if sqlType is not None else "SQL", query)
48+
logger.info(infoMsg)
4749

48-
output = inject.getValue(query, fromUser=True)
50+
output = inject.getValue(query, fromUser=True)
4951

50-
return output
51-
elif not isStackingAvailable() and not conf.direct:
52-
warnMsg = "execution of custom SQL queries is only "
53-
warnMsg += "available when stacked queries are supported"
54-
logger.warn(warnMsg)
52+
return output
53+
elif not isStackingAvailable() and not conf.direct:
54+
warnMsg = "execution of custom SQL queries is only "
55+
warnMsg += "available when stacked queries are supported"
56+
logger.warn(warnMsg)
5557

56-
return None
57-
else:
58-
if sqlType:
59-
debugMsg = "executing %s query: '%s'" % (sqlType if sqlType is not None else "SQL", query)
58+
return None
6059
else:
61-
debugMsg = "executing unknown SQL type query: '%s'" % query
62-
logger.debug(debugMsg)
60+
if sqlType:
61+
debugMsg = "executing %s query: '%s'" % (sqlType if sqlType is not None else "SQL", query)
62+
else:
63+
debugMsg = "executing unknown SQL type query: '%s'" % query
64+
logger.debug(debugMsg)
6365

64-
inject.goStacked(query)
66+
inject.goStacked(query)
6567

66-
debugMsg = "done"
67-
logger.debug(debugMsg)
68+
debugMsg = "done"
69+
logger.debug(debugMsg)
6870

69-
output = NULL
71+
output = NULL
72+
73+
except SqlmapNoneDataException, ex:
74+
logger.warn(ex)
7075

7176
return output
7277

0 commit comments

Comments
 (0)