mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-24 00:04:23 +03:00
Implementation for an Issue #253
This commit is contained in:
parent
c40dded28c
commit
ef2038f1c8
|
@ -759,6 +759,7 @@ def readInput(message, default=None, checkBatch=True):
|
|||
Reads input from terminal
|
||||
"""
|
||||
|
||||
retVal = None
|
||||
kb.stickyLevel = None
|
||||
|
||||
if "\n" in message:
|
||||
|
@ -766,36 +767,52 @@ def readInput(message, default=None, checkBatch=True):
|
|||
elif message[-1] == ']':
|
||||
message += " "
|
||||
|
||||
if checkBatch and conf.batch:
|
||||
if isListLike(default):
|
||||
options = ",".join(getUnicode(opt, UNICODE_ENCODING) for opt in default)
|
||||
elif default:
|
||||
options = getUnicode(default, UNICODE_ENCODING)
|
||||
if conf.answers:
|
||||
for item in conf.answers.split(','):
|
||||
question = item.split('=')[0].strip()
|
||||
answer = item.split('=')[1] if len(item.split('=')) > 1 else None
|
||||
if answer and question.lower() in message.lower():
|
||||
retVal = getUnicode(answer, UNICODE_ENCODING)
|
||||
|
||||
infoMsg = "%s%s" % (getUnicode(message), retVal)
|
||||
logger.info(infoMsg)
|
||||
|
||||
debugMsg = "used the given answer"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
break
|
||||
|
||||
if retVal is None:
|
||||
if checkBatch and conf.batch:
|
||||
if isListLike(default):
|
||||
options = ",".join(getUnicode(opt, UNICODE_ENCODING) for opt in default)
|
||||
elif default:
|
||||
options = getUnicode(default, UNICODE_ENCODING)
|
||||
else:
|
||||
options = unicode()
|
||||
|
||||
infoMsg = "%s%s" % (getUnicode(message), options)
|
||||
logger.info(infoMsg)
|
||||
|
||||
debugMsg = "used the default behaviour, running in batch mode"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
retVal = default
|
||||
else:
|
||||
options = unicode()
|
||||
logging._acquireLock()
|
||||
dataToStdout("\r%s" % message, forceOutput=True, bold=True)
|
||||
kb.prependFlag = False
|
||||
try:
|
||||
retVal = raw_input() or default
|
||||
retVal = getUnicode(retVal, system=True) if retVal else retVal
|
||||
except:
|
||||
time.sleep(0.05) # Reference: http://www.gossamer-threads.com/lists/python/python/781893
|
||||
kb.prependFlag = True
|
||||
raise sqlmapUserQuitException
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
|
||||
infoMsg = "%s%s" % (getUnicode(message), options)
|
||||
logger.info(infoMsg)
|
||||
|
||||
debugMsg = "used the default behaviour, running in batch mode"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
data = default
|
||||
else:
|
||||
logging._acquireLock()
|
||||
dataToStdout("\r%s" % message, forceOutput=True, bold=True)
|
||||
kb.prependFlag = False
|
||||
try:
|
||||
data = raw_input() or default
|
||||
data = getUnicode(data, system=True) if data else data
|
||||
except:
|
||||
time.sleep(0.05) # Reference: http://www.gossamer-threads.com/lists/python/python/781893
|
||||
kb.prependFlag = True
|
||||
raise sqlmapUserQuitException
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
|
||||
return data
|
||||
return retVal
|
||||
|
||||
def randomRange(start=0, stop=1000):
|
||||
"""
|
||||
|
|
|
@ -190,6 +190,8 @@ optDict = {
|
|||
},
|
||||
|
||||
"Miscellaneous": {
|
||||
"mnemonics": "string",
|
||||
"answers": "string",
|
||||
"checkPayload": "boolean",
|
||||
"cleanup": "boolean",
|
||||
"dependencies": "boolean",
|
||||
|
|
|
@ -604,6 +604,9 @@ def cmdLineParser():
|
|||
miscellaneous.add_option("-z", dest="mnemonics",
|
||||
help="Use short mnemonics (e.g. \"flu,bat,ban,tec=EU\")")
|
||||
|
||||
miscellaneous.add_option("--answers", dest="answers",
|
||||
help="Set question answers (e.g. \"quit=N,follow=N\")")
|
||||
|
||||
miscellaneous.add_option("--check-payload", dest="checkPayload",
|
||||
action="store_true",
|
||||
help="Offline WAF/IPS/IDS payload detection testing")
|
||||
|
|
|
@ -650,6 +650,12 @@ updateAll = False
|
|||
|
||||
[Miscellaneous]
|
||||
|
||||
# Use short mnemonics (e.g. "flu,bat,ban,tec=EU")
|
||||
mnemonics =
|
||||
|
||||
# Set question answers (e.g. "quit=N,follow=N")
|
||||
answers =
|
||||
|
||||
# Offline WAF/IPS/IDS payload detection testing.
|
||||
checkPayload = False
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user