()
This function checks if the way to request testable hosts is through
    Google dorking then requests to Google the search parameter, parses
    the results and save the testable hosts into the knowledge base.
This function checks if the way to request testable hosts is through
    Google dorking then requests to Google the search parameter, parses
    the results and save the testable hosts into the knowledge base.
This function checks if the way to request testable hosts is through Google dorking then requests to Google the search parameter parses the results and save the testable hosts into the knowledge base .
def _setGoogleDorking():
    """
    This function checks if the way to request testable hosts is through
    Google dorking then requests to Google the search parameter, parses
    the results and save the testable hosts into the knowledge base.
    """

    if not conf.googleDork:
        return

    global keepAliveHandler
    global proxyHandler

    debugMsg = "initializing Google dorking requests"
    logger.debug(debugMsg)

    infoMsg = "first request to Google to get the session cookie"
    logger.info(infoMsg)

    handlers = [proxyHandler]

    # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
    if conf.keepAlive:
        if conf.proxy:
            warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
            warnMsg += "been disabled because of its incompatibility "
            warnMsg += "with HTTP(s) proxy"
            logger.warn(warnMsg)
        else:
            handlers.append(keepAliveHandler)

    googleObj = Google(handlers)
    kb.data.onlyGETs = None

    def retrieve():
        links = googleObj.search(conf.googleDork)

        if not links:
            errMsg = "unable to find results for your "
            errMsg += "Google dork expression"
            raise SqlmapGenericException(errMsg)

        for link in links:
            link = urldecode(link)
            if re.search(r"(.*?)\?(.+)", link):
                kb.targets.add((link, conf.method, conf.data, conf.cookie, None))
            elif re.search(URI_INJECTABLE_REGEX, link, re.I):
                if kb.data.onlyGETs is None and conf.data is None and not conf.googleDork:
                    message = "do you want to scan only results containing GET parameters? [Y/n] "
                    test = readInput(message, default="Y")
                    kb.data.onlyGETs = test.lower() != 'n'
                if not kb.data.onlyGETs or conf.googleDork:
                    kb.targets.add((link, conf.method, conf.data, conf.cookie, None))

        return links

    while True:
        links = retrieve()

        if kb.targets:
            infoMsg = "sqlmap got %d results for your " % len(links)
            infoMsg += "Google dork expression, "

            if len(links) == len(kb.targets):
                infoMsg += "all "
            else:
                infoMsg += "%d " % len(kb.targets)

            infoMsg += "of them are testable targets"
            logger.info(infoMsg)
            break

        else:
            message = "sqlmap got %d results " % len(links)
            message += "for your Google dork expression, but none of them "
            message += "have GET parameters to test for SQL injection. "
            message += "Do you want to skip to the next result page? [Y/n]"
            test = readInput(message, default="Y")

            if test[0] in ("n", "N"):
                raise SqlmapSilentQuitException
            else:
                conf.googlePage += 1
def _setGoogleDorking ( ) : if not conf . googleDork : return global keepAliveHandler global proxyHandler debugMsg = "initializing Google dorking requests" logger . debug ( debugMsg ) infoMsg = "first request to Google to get the session cookie" logger . info ( infoMsg ) handlers = [ proxyHandler ] # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html if conf . keepAlive : if conf . proxy : warnMsg = "persistent HTTP(s) connections, Keep-Alive, has " warnMsg += "been disabled because of its incompatibility " warnMsg += "with HTTP(s) proxy" logger . warn ( warnMsg ) else : handlers . append ( keepAliveHandler ) googleObj = Google ( handlers ) kb . data . onlyGETs = None def retrieve ( ) : links = googleObj . search ( conf . googleDork ) if not links : errMsg = "unable to find results for your " errMsg += "Google dork expression" raise SqlmapGenericException ( errMsg ) for link in links : link = urldecode ( link ) if re . search ( r"(.*?)\?(.+)" , link ) : kb . targets . add ( ( link , conf . method , conf . data , conf . cookie , None ) ) elif re . search ( URI_INJECTABLE_REGEX , link , re . I ) : if kb . data . onlyGETs is None and conf . data is None and not conf . googleDork : message = "do you want to scan only results containing GET parameters? [Y/n] " test = readInput ( message , default = "Y" ) kb . data . onlyGETs = test . lower ( ) != 'n' if not kb . data . onlyGETs or conf . googleDork : kb . targets . add ( ( link , conf . method , conf . data , conf . cookie , None ) ) return links while True : links = retrieve ( ) if kb . targets : infoMsg = "sqlmap got %d results for your " % len ( links ) infoMsg += "Google dork expression, " if len ( links ) == len ( kb . targets ) : infoMsg += "all " else : infoMsg += "%d " % len ( kb . targets ) infoMsg += "of them are testable targets" logger . info ( infoMsg ) break else : message = "sqlmap got %d results " % len ( links ) message += "for your Google dork expression, but none of them " message += "have GET parameters to test for SQL injection. " message += "Do you want to skip to the next result page? [Y/n]" test = readInput ( message , default = "Y" ) if test [ 0 ] in ( "n" , "N" ) : raise SqlmapSilentQuitException else : conf . googlePage += 1