MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / readInput

Function readInput

lib/core/common.py:1127–1216  ·  view source on GitHub ↗

Reads input from terminal

(message, default=None, checkBatch=True, boolean=False)

Source from the content-addressed store, hash-verified

1125 return retVal
1126
1127def readInput(message, default=None, checkBatch=True, boolean=False):
1128 """
1129 Reads input from terminal
1130 """
1131
1132 retVal = None
1133
1134 message = getUnicode(message)
1135
1136 if "\n" in message:
1137 message += "%s> " % ("\n" if message.count("\n") > 1 else "")
1138 elif message[-1] == ']':
1139 message += " "
1140
1141 if kb.get("prependFlag"):
1142 message = "\n%s" % message
1143 kb.prependFlag = False
1144
1145 if conf.get("answers"):
1146 if not any(_ in conf.answers for _ in ",="):
1147 return conf.answers
1148
1149 for item in conf.answers.split(','):
1150 question = item.split('=')[0].strip()
1151 answer = item.split('=')[1] if len(item.split('=')) > 1 else None
1152 if answer and question.lower() in message.lower():
1153 retVal = getUnicode(answer, UNICODE_ENCODING)
1154 elif answer is None and retVal:
1155 retVal = "%s,%s" % (retVal, getUnicode(item, UNICODE_ENCODING))
1156
1157 if message and IS_TTY:
1158 message = "\r%s" % message
1159
1160 if retVal:
1161 dataToStdout("%s%s\n" % (message, retVal), forceOutput=not kb.wizardMode, bold=True)
1162
1163 debugMsg = "used the given answer"
1164 logger.debug(debugMsg)
1165
1166 if retVal is None:
1167 if checkBatch and conf.get("batch") or any(conf.get(_) for _ in ("api", "nonInteractive")):
1168 if isListLike(default):
1169 options = ','.join(getUnicode(opt, UNICODE_ENCODING) for opt in default)
1170 elif default:
1171 options = getUnicode(default, UNICODE_ENCODING)
1172 else:
1173 options = six.text_type()
1174
1175 dataToStdout("%s%s\n" % (message, options), forceOutput=not kb.wizardMode, bold=True)
1176
1177 debugMsg = "used the default behavior, running in batch mode"
1178 logger.debug(debugMsg)
1179
1180 retVal = default
1181 else:
1182 try:
1183 logging._acquireLock()
1184

Callers 15

storeHashesToFileFunction · 0.90
attackDumpedTableFunction · 0.90
dictionaryAttackFunction · 0.90
crawlFunction · 0.90
storeResultsToFileFunction · 0.90
tableExistsFunction · 0.90
columnExistsFunction · 0.90
fileExistsFunction · 0.90
_searchFunction · 0.90
_selectInjectionFunction · 0.90
_randomFillBlankFieldsFunction · 0.90
startFunction · 0.90

Calls 6

getUnicodeFunction · 0.90
beepFunction · 0.90
dataToStdoutFunction · 0.85
debugMethod · 0.80
isListLikeFunction · 0.70
getMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…