()
Check and set the safe visit options.
Check and set the safe visit options.
Check and set the safe visit options .
def _setSafeVisit():
    """
    Check and set the safe visit options.
    """
    if not any ((conf.safeUrl, conf.safeReqFile)):
        return

    if conf.safeReqFile:
        checkFile(conf.safeReqFile)

        raw = readCachedFileContent(conf.safeReqFile)
        match = re.search(r"\A([A-Z]+) ([^ ]+) HTTP/[0-9.]+\Z", raw[:raw.find('\n')])

        if match:
            kb.safeReq.method = match.group(1)
            kb.safeReq.url = match.group(2)
            kb.safeReq.headers = {}

            for line in raw[raw.find('\n') + 1:].split('\n'):
                line = line.strip()
                if line and ':' in line:
                    key, value = line.split(':', 1)
                    value = value.strip()
                    kb.safeReq.headers[key] = value
                    if key == HTTP_HEADER.HOST:
                        if not value.startswith("http"):
                            scheme = "http"
                            if value.endswith(":443"):
                                scheme = "https"
                            value = "%s://%s" % (scheme, value)
                        kb.safeReq.url = urlparse.urljoin(value, kb.safeReq.url)
                else:
                    break

            post = None

            if '\r\n\r\n' in raw:
                post = raw[raw.find('\r\n\r\n') + 4:]
            elif '\n\n' in raw:
                post = raw[raw.find('\n\n') + 2:]

            if post and post.strip():
                kb.safeReq.post = post
            else:
                kb.safeReq.post = None
        else:
            errMsg = "invalid format of a safe request file"
            raise SqlmapSyntaxException, errMsg
    else:
        if not re.search("^http[s]*://", conf.safeUrl):
            if ":443/" in conf.safeUrl:
                conf.safeUrl = "https://" + conf.safeUrl
            else:
                conf.safeUrl = "http://" + conf.safeUrl

    if conf.safeFreq <= 0:
        errMsg = "please provide a valid value (>0) for safe frequency (--safe-freq) while using safe visit features"
        raise SqlmapSyntaxException(errMsg)
def _setSafeVisit ( ) : if not any ( ( conf . safeUrl , conf . safeReqFile ) ) : return if conf . safeReqFile : checkFile ( conf . safeReqFile ) raw = readCachedFileContent ( conf . safeReqFile ) match = re . search ( r"\A([A-Z]+) ([^ ]+) HTTP/[0-9.]+\Z" , raw [ : raw . find ( '\n' ) ] ) if match : kb . safeReq . method = match . group ( 1 ) kb . safeReq . url = match . group ( 2 ) kb . safeReq . headers = { } for line in raw [ raw . find ( '\n' ) + 1 : ] . split ( '\n' ) : line = line . strip ( ) if line and ':' in line : key , value = line . split ( ':' , 1 ) value = value . strip ( ) kb . safeReq . headers [ key ] = value if key == HTTP_HEADER . HOST : if not value . startswith ( "http" ) : scheme = "http" if value . endswith ( ":443" ) : scheme = "https" value = "%s://%s" % ( scheme , value ) kb . safeReq . url = urlparse . urljoin ( value , kb . safeReq . url ) else : break post = None if '\r\n\r\n' in raw : post = raw [ raw . find ( '\r\n\r\n' ) + 4 : ] elif '\n\n' in raw : post = raw [ raw . find ( '\n\n' ) + 2 : ] if post and post . strip ( ) : kb . safeReq . post = post else : kb . safeReq . post = None else : errMsg = "invalid format of a safe request file" raise SqlmapSyntaxException , errMsg else : if not re . search ( "^http[s]*://" , conf . safeUrl ) : if ":443/" in conf . safeUrl : conf . safeUrl = "https://" + conf . safeUrl else : conf . safeUrl = "http://" + conf . safeUrl if conf . safeFreq <= 0 : errMsg = "please provide a valid value (>0) for safe frequency (--safe-freq) while using safe visit features" raise SqlmapSyntaxException ( errMsg )