コード例 #1
0
ファイル: agent.py プロジェクト: DavisHevin/sqli_benchmark
    def suffixQuery(self, string, comment=None):
        """
        This method appends the DBMS comment to the
        SQL injection request
        """

        if conf.direct:
            return self.payloadDirect(string)

        logic = conf.logic
        case = getInjectionCase(kb.injType)

        if case is None:
            raise sqlmapNoneDataException, "unsupported injection type"

        randInt = randomInt()
        randStr = randomStr()

        if kb.parenthesis is not None:
            parenthesis = kb.parenthesis
        else:
            raise sqlmapNoneDataException, "unable to get the number of parenthesis"

        if comment:
            string += comment

        if conf.suffix:
            string += " %s" % conf.suffix
        else:
            string += case.usage.suffix.format % eval(case.usage.suffix.params)

        return string
コード例 #2
0
ファイル: agent.py プロジェクト: DavisHevin/sqli_benchmark
    def prefixQuery(self, string):
        """
        This method defines how the input string has to be escaped
        to perform the injection depending on the injection type
        identified as valid
        """

        if conf.direct:
            return self.payloadDirect(string)

        logic = conf.logic
        query = str()
        case = getInjectionCase(kb.injType)

        if kb.parenthesis is not None:
            parenthesis = kb.parenthesis
        else:
            raise sqlmapNoneDataException, "unable to get the number of parenthesis"

        if case is None:
            raise sqlmapNoneDataException, "unsupported injection type"

        if conf.prefix:
            query = "%s " % conf.prefix.strip()
        else:
            query = case.usage.prefix.format % eval(case.usage.prefix.params)

        query += string

        return query
コード例 #3
0
def checkForParenthesis():
    """
    This method checks if the SQL injection affected parameter
    is within the parenthesis.
    """

    logMsg = "testing for parenthesis on injectable parameter"
    logger.info(logMsg)

    logic = conf.logic
    count = 0
    case = getInjectionCase(kb.injType)

    if case is None:
        raise sqlmapNoneDataException, "unsupported injection type"

    if kb.parenthesis is not None:
        return

    if conf.prefix or conf.suffix:
        kb.parenthesis = 0
        return

    for parenthesis in range(1, 4):
        randInt = randomInt()
        randStr = randomStr()

        query = case.usage.prefix.format % eval(case.usage.prefix.params)
        query = query[:-1] + case.usage.suffix.format % eval(case.usage.suffix.params)

        payload = agent.payload(newValue=query)
        result = Request.queryPage(payload)

        if result:
            count = parenthesis

    logMsg = "the injectable parameter requires %d parenthesis" % count
    logger.info(logMsg)

    setParenthesis(count)