Example #1
0
    def validate_proxy(self):
        if (self.verbose):
            print("[*]Validating proxy...")
        try:
            ip = self.get_ip()
            ips = self.get_ip(True)
        except Exception as e:
            bcolors.printFail(
                ("[-]Error occured while validating proxy!\n" + str(e)))
            print("Press enter to continue, or ctrl+c to interrupt...")
            input()
            ip = "Unknown"
            ips = "Unknown"

        if (self.verbose):
            print("[*]Your IP is: " + str(self.myip) +
                  "\n[*]Proxy(HTTP) ip is: " + str(ip) +
                  "\n[*]Proxy(HTTPS) ip is: " + str(ips))

        if (ip == self.myip):
            bcolors.printWarning(
                "[-]HTTP proxy error detected! Press enter to continue, or Ctrl+C to interrupt..."
            )
            input()

        if (ips == self.myip):
            bcolors.printWarning(
                "[-]HTTP proxy error detected! Press enter to continue, or Ctrl+C to interrupt..."
            )
            input()
    def get_html(self, url):
        if (self.useproxy):
            self.proxyhandler.validate_proxy()
        req = urllib.request.Request(url, None, data.headers)
        tries = 0
        while (self.retries == None or tries < self.retries):
            try:
                res = urllib.request.urlopen(req)
                self.cookie_jar.extract_cookies(res, req)
                src = res.read()
                break
            except urllib.error.HTTPError as e:
                if (e.code != 503):
                    bcolors.printFail("[-]HTTP Error " + str(e) +
                                      " was raised!")
                    return None
                if (self.useproxy):
                    if (self.verbose):
                        bcolors.printWarning(
                            "[*]503 Error raised when acquiring search results! Updating proxy..."
                        )
                    self.update_proxy()

                # If we have to retry, append current proxy to blacklist
            if (self.useproxy):
                # blacklists both proxies if error occured!
                self.proxyhandler.blacklist_current_proxy(True)
            tries += 1

        return html.fromstring(str(src))
 def get_html(self, url) :
     if (self.useproxy) :
         self.proxyhandler.validate_proxy()
     req = urllib.request.Request(url, None, data.headers)
     tries = 0
     while (self.retries == None or tries < self.retries):
         try :
             res = urllib.request.urlopen(req)
             self.cookie_jar.extract_cookies(res, req)
             src = res.read()
             break
         except urllib.error.HTTPError as e:
             if (e.code != 503) :
                 bcolors.printFail("[-]HTTP Error " + str(e) + " was raised!")
                 return None
             if (self.useproxy) :
                 if (self.verbose) :
                     bcolors.printWarning("[*]503 Error raised when acquiring search results! Updating proxy...")
                 self.update_proxy()
         
             # If we have to retry, append current proxy to blacklist
         if (self.useproxy) :
             # blacklists both proxies if error occured!
             self.proxyhandler.blacklist_current_proxy(True)
         tries += 1
             
     return html.fromstring(str(src))
Example #4
0
    def validate_proxy(self) :
        if (self.verbose) :
            print("[*]Validating proxy...")
        try :
            ip = self.get_ip()
            ips = self.get_ip(True)
        except Exception as e:
            bcolors.printFail(("[-]Error occured while validating proxy!\n" + str(e)))
            print("Press enter to continue, or ctrl+c to interrupt...")
            input()
            ip = "Unknown"
            ips = "Unknown"
		
        if (self.verbose) :
            print("[*]Your IP is: " + str(self.myip) + "\n[*]Proxy(HTTP) ip is: " + str(ip) + "\n[*]Proxy(HTTPS) ip is: " + str(ips))

        if (ip == self.myip) :
            bcolors.printWarning("[-]HTTP proxy error detected! Press enter to continue, or Ctrl+C to interrupt...")
            input()
            
        if (ips == self.myip) :
            bcolors.printWarning("[-]HTTP proxy error detected! Press enter to continue, or Ctrl+C to interrupt...")
            input()