Skip to content

Commit 4e8b41b

Browse files
committed
Patch for an Issue sqlmapproject#688
1 parent 3a29167 commit 4e8b41b

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

lib/core/option.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
16061606
kb.chars.stop = "%s%s%s" % (KB_CHARS_BOUNDARY_CHAR, randomStr(length=3, lowercase=True), KB_CHARS_BOUNDARY_CHAR)
16071607
kb.chars.at, kb.chars.space, kb.chars.dollar, kb.chars.hash_ = ("%s%s%s" % (KB_CHARS_BOUNDARY_CHAR, _, KB_CHARS_BOUNDARY_CHAR) for _ in randomStr(length=4, lowercase=True))
16081608

1609+
kb.columnExistsChoice = None
16091610
kb.commonOutputs = None
16101611
kb.counters = {}
16111612
kb.data = AttribDict()
@@ -1704,6 +1705,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
17041705
kb.testQueryCount = 0
17051706
kb.threadContinue = True
17061707
kb.threadException = False
1708+
kb.tableExistsChoice = None
17071709
kb.timeValidCharsRun = 0
17081710
kb.uChar = NULL
17091711
kb.unionDuplicates = False

lib/techniques/brute/use.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from lib.core.common import hashDBWrite
1717
from lib.core.common import randomInt
1818
from lib.core.common import randomStr
19+
from lib.core.common import readInput
1920
from lib.core.common import safeStringFormat
2021
from lib.core.common import safeSQLIdentificatorNaming
2122
from lib.core.common import unsafeSQLIdentificatorNaming
@@ -24,6 +25,7 @@
2425
from lib.core.data import logger
2526
from lib.core.enums import DBMS
2627
from lib.core.enums import HASHDB_KEYS
28+
from lib.core.enums import PAYLOAD
2729
from lib.core.exception import SqlmapDataException
2830
from lib.core.exception import SqlmapMissingMandatoryOptionException
2931
from lib.core.settings import METADB_SUFFIX
@@ -49,6 +51,18 @@ def _addPageTextWords():
4951
return wordsList
5052

5153
def tableExists(tableFile, regex=None):
54+
if kb.tableExistsChoice is None and any(_ not in kb.injection.data for _ in (PAYLOAD.TECHNIQUE.TIME, PAYLOAD.TECHNIQUE.STACKED)):
55+
warnMsg = "it's not recommended to use '%s' and/or '%s' " % (PAYLOAD.SQLINJECTION[PAYLOAD.TECHNIQUE.TIME], PAYLOAD.SQLINJECTION[PAYLOAD.TECHNIQUE.STACKED])
56+
warnMsg += "for common table existence check"
57+
logger.warn(warnMsg)
58+
59+
message = "are you sure you want to continue? [y/N] "
60+
test = readInput(message, default="N")
61+
kb.tableExistsChoice = test[0] in ("y", "Y")
62+
63+
if not kb.tableExistsChoice:
64+
return None
65+
5266
result = inject.checkBooleanExpression("%s" % safeStringFormat(BRUTE_TABLE_EXISTS_TEMPLATE, (randomInt(1), randomStr())))
5367

5468
if conf.db and Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
@@ -141,6 +155,18 @@ def tableExistsThread():
141155
return kb.data.cachedTables
142156

143157
def columnExists(columnFile, regex=None):
158+
if kb.columnExistsChoice is None and any(_ not in kb.injection.data for _ in (PAYLOAD.TECHNIQUE.TIME, PAYLOAD.TECHNIQUE.STACKED)):
159+
warnMsg = "it's not recommended to use '%s' and/or '%s' " % (PAYLOAD.SQLINJECTION[PAYLOAD.TECHNIQUE.TIME], PAYLOAD.SQLINJECTION[PAYLOAD.TECHNIQUE.STACKED])
160+
warnMsg += "for common column existence check"
161+
logger.warn(warnMsg)
162+
163+
message = "are you sure you want to continue? [y/N] "
164+
test = readInput(message, default="N")
165+
kb.columnExistsChoice = test[0] in ("y", "Y")
166+
167+
if not kb.columnExistsChoice:
168+
return None
169+
144170
if not conf.tbl:
145171
errMsg = "missing table parameter"
146172
raise SqlmapMissingMandatoryOptionException(errMsg)

0 commit comments

Comments
 (0)