defparamToDict(place, parameters=None): """ Split the parameters into names and values, check if these parameters are within the testable parameters and return in a dictionary. """
if place == PLACE.COOKIE: splitParams = parameters.split(conf.cookieDel or DEFAULT_COOKIE_DELIMITER) else: splitParams = parameters.split(conf.paramDel or DEFAULT_GET_POST_DELIMITER)
for element in splitParams: element = re.sub(r"%s(.+?)%s" % (PARAMETER_AMP_MARKER, PARAMETER_SEMICOLON_MARKER), r"&\g<1>;", element) # 去除html标签 parts = element.split("=")
if condition: testableParameters[parameter] = "=".join(parts[1:]) ifnot conf.multipleTargets andnot (conf.csrfToken and re.search(conf.csrfToken, parameter, re.I)): _ = urldecode(testableParameters[parameter], convall=True) # url解码 if (_.endswith("'") and _.count("'") == 1or re.search(r'\A9{3,}', _) or re.search(r'\A-\d+\Z', _) or re.search(DUMMY_USER_INJECTION, _)) andnot parameter.upper().startswith(GOOGLE_ANALYTICS_COOKIE_PREFIX): # 正则匹配是否含异常字段 warnMsg = "it appears that you have provided tainted parameter values "# 提示信息 warnMsg += "('%s') with most likely leftover " % element warnMsg += "chars/statements from manual SQL injection test(s). " warnMsg += "Please, always use only valid parameter values " warnMsg += "so sqlmap could be able to run properly" logger.warn(warnMsg)
message = "are you really sure that you want to continue (sqlmap could have problems)? [y/N] "
ifnot readInput(message, default='N', boolean=True): raise SqlmapSilentQuitException elifnot _: warnMsg = "provided value for parameter '%s' is empty. " % parameter warnMsg += "Please, always use only valid parameter values " warnMsg += "so sqlmap could be able to run properly" logger.warn(warnMsg)
are you really sure that you want to continue (sqlmap could have problems)? [y/N]
检验Get、Post参数值
1 2 3 4 5
if place in (PLACE.POST, PLACE.GET): for regex in (r"\A((?:<[^>]+>)+\w+)((?:<[^>]+>)+)\Z", r"\A([^\w]+.*\w+)([^\w]+)\Z"): match = re.search(regex, testableParameters[parameter]) # 正则匹配 if match: # ....
if conf.testParameter: # 通过-p指定可测试参数,如果给了 ifnot testableParameters: # 如果没有可测试参数 paramStr = ", ".join(test for test in conf.testParameter)
iflen(conf.testParameter) > 1: warnMsg = "provided parameters '%s' " % paramStr warnMsg += "are not inside the %s" % place logger.warn(warnMsg) else: parameter = conf.testParameter[0]
ifnot intersect(USER_AGENT_ALIASES + REFERER_ALIASES + HOST_ALIASES, parameter, True): debugMsg = "provided parameter '%s' " % paramStr debugMsg += "is not inside the %s" % place logger.debug(debugMsg)
eliflen(conf.testParameter) != len(testableParameters): for parameter in conf.testParameter: if parameter notin testableParameters: debugMsg = "provided parameter '%s' " % parameter debugMsg += "is not inside the %s" % place logger.debug(debugMsg)
if testableParameters: # 有可测试的参数 for parameter, value in testableParameters.items(): if value andnot value.isdigit(): for encoding in ("hex", "base64"): try: decoded = value.decode(encoding) # 尝试解码 iflen(decoded) > MIN_ENCODED_LEN_CHECK andall(_ in string.printable for _ in decoded): # # MIN_ENCODED_LEN_CHECK:5 warnMsg = "provided parameter '%s' " % parameter warnMsg += "appears to be '%s' encoded" % encoding logger.warn(warnMsg) break except: pass