()
return retVal
Reference: http://seclists.org/nmap-dev/2011/q2/att-1005/http-waf-detect.nse
Reference: http://seclists.org/nmap-dev/2011/q2/att-1005/http-waf-detect.nse
Reference : http : // seclists . org / nmap - dev / 2011 / q2 / att - 1005 / http - waf - detect . nse
def checkWaf():
    """
    Reference: http://seclists.org/nmap-dev/2011/q2/att-1005/http-waf-detect.nse
    """

    if any((conf.string, conf.notString, conf.regexp, conf.dummy, conf.offline, conf.skipWaf)):
        return None

    infoMsg = "checking if the target is protected by "
    infoMsg += "some kind of WAF/IPS/IDS"
    logger.info(infoMsg)

    retVal = False
    payload = "%d %s" % (randomInt(), IDS_WAF_CHECK_PAYLOAD)

    value = "" if not conf.parameters.get(PLACE.GET) else conf.parameters[PLACE.GET] + DEFAULT_GET_POST_DELIMITER
    value += agent.addPayloadDelimiters("%s=%s" % (randomStr(), payload))

    pushValue(conf.timeout)
    conf.timeout = IDS_WAF_CHECK_TIMEOUT

    try:
        retVal = Request.queryPage(place=PLACE.GET, value=value, getRatioValue=True, noteResponseTime=False, silent=True)[1] < IDS_WAF_CHECK_RATIO
    except SqlmapConnectionException:
        retVal = True
    finally:
        kb.matchRatio = None
        conf.timeout = popValue()

    if retVal:
        warnMsg = "heuristics detected that the target "
        warnMsg += "is protected by some kind of WAF/IPS/IDS"
        logger.critical(warnMsg)

        if not conf.identifyWaf:
            message = "do you want sqlmap to try to detect backend "
            message += "WAF/IPS/IDS? [y/N] "
            output = readInput(message, default="N")

            if output and output[0] in ("Y", "y"):
                conf.identifyWaf = True

        if conf.timeout == defaults.timeout:
            logger.warning("dropping timeout to %d seconds (i.e. '--timeout=%d')" % (IDS_WAF_CHECK_TIMEOUT, IDS_WAF_CHECK_TIMEOUT))
            conf.timeout = IDS_WAF_CHECK_TIMEOUT

    return retVal
def checkWaf ( ) : if any ( ( conf . string , conf . notString , conf . regexp , conf . dummy , conf . offline , conf . skipWaf ) ) : return None infoMsg = "checking if the target is protected by " infoMsg += "some kind of WAF/IPS/IDS" logger . info ( infoMsg ) retVal = False payload = "%d %s" % ( randomInt ( ) , IDS_WAF_CHECK_PAYLOAD ) value = "" if not conf . parameters . get ( PLACE . GET ) else conf . parameters [ PLACE . GET ] + DEFAULT_GET_POST_DELIMITER value += agent . addPayloadDelimiters ( "%s=%s" % ( randomStr ( ) , payload ) ) pushValue ( conf . timeout ) conf . timeout = IDS_WAF_CHECK_TIMEOUT try : retVal = Request . queryPage ( place = PLACE . GET , value = value , getRatioValue = True , noteResponseTime = False , silent = True ) [ 1 ] < IDS_WAF_CHECK_RATIO except SqlmapConnectionException : retVal = True finally : kb . matchRatio = None conf . timeout = popValue ( ) if retVal : warnMsg = "heuristics detected that the target " warnMsg += "is protected by some kind of WAF/IPS/IDS" logger . critical ( warnMsg ) if not conf . identifyWaf : message = "do you want sqlmap to try to detect backend " message += "WAF/IPS/IDS? [y/N] " output = readInput ( message , default = "N" ) if output and output [ 0 ] in ( "Y" , "y" ) : conf . identifyWaf = True if conf . timeout == defaults . timeout : logger . warning ( "dropping timeout to %d seconds (i.e. '--timeout=%d')" % ( IDS_WAF_CHECK_TIMEOUT , IDS_WAF_CHECK_TIMEOUT ) ) conf . timeout = IDS_WAF_CHECK_TIMEOUT return retVal