(self, dork)
return retVal
This method performs the effective search on Google providing
        the google dork and the Google session cookie
This method performs the effective search on Google providing
        the google dork and the Google session cookie
This method performs the effective search on Google providing the google dork and the Google session cookie
def search(self, dork):
        """
        This method performs the effective search on Google providing
        the google dork and the Google session cookie
        """

        gpage = conf.googlePage if conf.googlePage > 1 else 1
        logger.info("using Google result page #%d" % gpage)

        if not dork:
            return None

        url = "https://www.google.com/search?"
        url += "q=%s&" % urlencode(dork, convall=True)
        url += "num=100&hl=en&complete=0&safe=off&filter=0&btnG=Search"
        url += "&start=%d" % ((gpage - 1) * 100)

        try:
            conn = self.opener.open(url)

            requestMsg = "HTTP request:\nGET %s" % url
            requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str
            logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)

            page = conn.read()
            code = conn.code
            status = conn.msg
            responseHeaders = conn.info()
            page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))

            responseMsg = "HTTP response (%s - %d):\n" % (status, code)

            if conf.verbose <= 4:
                responseMsg += getUnicode(responseHeaders, UNICODE_ENCODING)
            elif conf.verbose > 4:
                responseMsg += "%s\n%s\n" % (responseHeaders, page)

            logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
        except urllib2.HTTPError, e:
            try:
                page = e.read()
            except Exception, ex:
                warnMsg = "problem occurred while trying to get "
                warnMsg += "an error page information (%s)" % getSafeExString(ex)
                logger.critical(warnMsg)
                return None
        except (urllib2.URLError, httplib.error, socket.error, socket.timeout, socks.ProxyError):
            errMsg = "unable to connect to Google"
            raise SqlmapConnectionException(errMsg)

        retVal = [urllib.unquote(match.group(1)) for match in re.finditer(GOOGLE_REGEX, page, re.I | re.S)]

        if not retVal and "detected unusual traffic" in page:
            warnMsg = "Google has detected 'unusual' traffic from "
            warnMsg += "used IP address disabling further searches"
            raise SqlmapGenericException(warnMsg)

        if not retVal:
            message = "no usable links found. What do you want to do?"
            message += "\n[1] (re)try with DuckDuckGo (default)"
            message += "\n[2] (re)try with Disconnect Search"
            message += "\n[3] quit"
            choice = readInput(message, default="1").strip().upper()

            if choice == "Q":
                raise SqlmapUserQuitException
            elif choice == "2":
                url = "https://search.disconnect.me/searchTerms/search?"
                url += "start=nav&option=Web"
                url += "&query=%s" % urlencode(dork, convall=True)
                url += "&ses=Google&location_option=US"
                url += "&nextDDG=%s" % urlencode("/search?q=&num=100&hl=en&start=%d&sa=N" % ((gpage - 1) * 10), convall=True)
                url += "&sa=N&showIcons=false&filterIcons=none&js_enabled=1"
                regex = DISCONNECT_SEARCH_REGEX
            else:
                url = "https://duckduckgo.com/d.js?"
                url += "q=%s&p=%d&s=100" % (urlencode(dork, convall=True), gpage)
                regex = DUCKDUCKGO_REGEX

            if not conf.randomAgent:
                self.opener.addheaders = [_ for _ in self.opener.addheaders if _[0].lower() != HTTP_HEADER.USER_AGENT.lower()]
                self.opener.addheaders.append((HTTP_HEADER.USER_AGENT, DUMMY_SEARCH_USER_AGENT))

            self.opener.addheaders = [_ for _ in self.opener.addheaders if _[0].lower() != HTTP_HEADER.ACCEPT_ENCODING.lower()]
            self.opener.addheaders.append((HTTP_HEADER.ACCEPT_ENCODING, HTTP_ACCEPT_ENCODING_HEADER_VALUE))

            try:
                conn = self.opener.open(url)

                requestMsg = "HTTP request:\nGET %s" % url
                requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str
                logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)

                page = conn.read()
                code = conn.code
                status = conn.msg
                responseHeaders = conn.info()
                page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))

                responseMsg = "HTTP response (%s - %d):\n" % (status, code)

                if conf.verbose <= 4:
                    responseMsg += getUnicode(responseHeaders, UNICODE_ENCODING)
                elif conf.verbose > 4:
                    responseMsg += "%s\n%s\n" % (responseHeaders, page)

                logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
            except urllib2.HTTPError, e:
                try:
                    page = e.read()
                except socket.timeout:
                    warnMsg = "connection timed out while trying "
                    warnMsg += "to get error page information (%d)" % e.code
                    logger.critical(warnMsg)
                    return None
            except:
                errMsg = "unable to connect"
                raise SqlmapConnectionException(errMsg)

            retVal = [urllib.unquote(match.group(1)) for match in re.finditer(regex, page, re.I | re.S)]

        return retVal
def search ( self , dork ) : gpage = conf . googlePage if conf . googlePage > 1 else 1 logger . info ( "using Google result page #%d" % gpage ) if not dork : return None url = "https://www.google.com/search?" url += "q=%s&" % urlencode ( dork , convall = True ) url += "num=100&hl=en&complete=0&safe=off&filter=0&btnG=Search" url += "&start=%d" % ( ( gpage - 1 ) * 100 ) try : conn = self . opener . open ( url ) requestMsg = "HTTP request:\nGET %s" % url requestMsg += " %s" % httplib . HTTPConnection . _http_vsn_str logger . log ( CUSTOM_LOGGING . TRAFFIC_OUT , requestMsg ) page = conn . read ( ) code = conn . code status = conn . msg responseHeaders = conn . info ( ) page = decodePage ( page , responseHeaders . get ( "Content-Encoding" ) , responseHeaders . get ( "Content-Type" ) ) responseMsg = "HTTP response (%s - %d):\n" % ( status , code ) if conf . verbose <= 4 : responseMsg += getUnicode ( responseHeaders , UNICODE_ENCODING ) elif conf . verbose > 4 : responseMsg += "%s\n%s\n" % ( responseHeaders , page ) logger . log ( CUSTOM_LOGGING . TRAFFIC_IN , responseMsg ) except urllib2 . HTTPError , e : try : page = e . read ( ) except Exception , ex : warnMsg = "problem occurred while trying to get " warnMsg += "an error page information (%s)" % getSafeExString ( ex ) logger . critical ( warnMsg ) return None except ( urllib2 . URLError , httplib . error , socket . error , socket . timeout , socks . ProxyError ) : errMsg = "unable to connect to Google" raise SqlmapConnectionException ( errMsg ) retVal = [ urllib . unquote ( match . group ( 1 ) ) for match in re . finditer ( GOOGLE_REGEX , page , re . I | re . S ) ] if not retVal and "detected unusual traffic" in page : warnMsg = "Google has detected 'unusual' traffic from " warnMsg += "used IP address disabling further searches" raise SqlmapGenericException ( warnMsg ) if not retVal : message = "no usable links found. What do you want to do?" message += "\n[1] (re)try with DuckDuckGo (default)" message += "\n[2] (re)try with Disconnect Search" message += "\n[3] quit" choice = readInput ( message , default = "1" ) . strip ( ) . upper ( ) if choice == "Q" : raise SqlmapUserQuitException elif choice == "2" : url = "https://search.disconnect.me/searchTerms/search?" url += "start=nav&option=Web" url += "&query=%s" % urlencode ( dork , convall = True ) url += "&ses=Google&location_option=US" url += "&nextDDG=%s" % urlencode ( "/search?q=&num=100&hl=en&start=%d&sa=N" % ( ( gpage - 1 ) * 10 ) , convall = True ) url += "&sa=N&showIcons=false&filterIcons=none&js_enabled=1" regex = DISCONNECT_SEARCH_REGEX else : url = "https://duckduckgo.com/d.js?" url += "q=%s&p=%d&s=100" % ( urlencode ( dork , convall = True ) , gpage ) regex = DUCKDUCKGO_REGEX if not conf . randomAgent : self . opener . addheaders = [ _ for _ in self . opener . addheaders if _ [ 0 ] . lower ( ) != HTTP_HEADER . USER_AGENT . lower ( ) ] self . opener . addheaders . append ( ( HTTP_HEADER . USER_AGENT , DUMMY_SEARCH_USER_AGENT ) ) self . opener . addheaders = [ _ for _ in self . opener . addheaders if _ [ 0 ] . lower ( ) != HTTP_HEADER . ACCEPT_ENCODING . lower ( ) ] self . opener . addheaders . append ( ( HTTP_HEADER . ACCEPT_ENCODING , HTTP_ACCEPT_ENCODING_HEADER_VALUE ) ) try : conn = self . opener . open ( url ) requestMsg = "HTTP request:\nGET %s" % url requestMsg += " %s" % httplib . HTTPConnection . _http_vsn_str logger . log ( CUSTOM_LOGGING . TRAFFIC_OUT , requestMsg ) page = conn . read ( ) code = conn . code status = conn . msg responseHeaders = conn . info ( ) page = decodePage ( page , responseHeaders . get ( "Content-Encoding" ) , responseHeaders . get ( "Content-Type" ) ) responseMsg = "HTTP response (%s - %d):\n" % ( status , code ) if conf . verbose <= 4 : responseMsg += getUnicode ( responseHeaders , UNICODE_ENCODING ) elif conf . verbose > 4 : responseMsg += "%s\n%s\n" % ( responseHeaders , page ) logger . log ( CUSTOM_LOGGING . TRAFFIC_IN , responseMsg ) except urllib2 . HTTPError , e : try : page = e . read ( ) except socket . timeout : warnMsg = "connection timed out while trying " warnMsg += "to get error page information (%d)" % e . code logger . critical ( warnMsg ) return None except : errMsg = "unable to connect" raise SqlmapConnectionException ( errMsg ) retVal = [ urllib . unquote ( match . group ( 1 ) ) for match in re . finditer ( regex , page , re . I | re . S ) ] return retVal