Esempio n. 1
0
    def handleFree(self):
        ukey = re.match(self.__pattern__, self.pyfile.url).group(1)
        json_url = 'http://ifile.it/new_download-request.json'
        post_data = {"ukey": ukey, "ab": "0"}

        json_response = json_loads(self.load(json_url, post=post_data))
        self.logDebug(json_response)
        if json_response['status'] == 3:
            self.offline()

        if json_response["captcha"]:
            captcha_key = re.search(self.RECAPTCHA_KEY_PATTERN,
                                    self.html).group(1)
            recaptcha = ReCaptcha(self)
            post_data["ctype"] = "recaptcha"

            for _ in xrange(5):
                post_data["recaptcha_challenge"], post_data[
                    "recaptcha_response"] = recaptcha.challenge(captcha_key)
                json_response = json_loads(self.load(json_url, post=post_data))
                self.logDebug(json_response)

                if json_response["retry"]:
                    self.invalidCaptcha()
                else:
                    self.correctCaptcha()
                    break
            else:
                self.fail("Incorrect captcha")

        if not "ticket_url" in json_response:
            self.parseError("Download URL")

        self.download(json_response["ticket_url"])
Esempio n. 2
0
    def handleFree(self, pyfile):
        self.req.http.lastURL = pyfile.url
        self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"])

        jsvars = self.getJsonResponse("https://rapidu.net/ajax.php",
                                      get={'a': "getLoadTimeToDownload"},
                                      post={'_go': ""},
                                      decode=True)

        if str(jsvars['timeToDownload']) is "stop":
            t = (24 * 60 * 60) - (int(time.time()) % (24 * 60 * 60)) + time.altzone

            self.logInfo("You've reach your daily download transfer")

            self.retry(10, 10 if t < 1 else None, _("Try tomorrow again"))  #@NOTE: check t in case of not synchronised clock

        else:
            self.wait(int(jsvars['timeToDownload']) - int(time.time()))

        recaptcha = ReCaptcha(self)
        response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY)

        jsvars = self.getJsonResponse("https://rapidu.net/ajax.php",
                                      get={'a': "getCheckCaptcha"},
                                      post={'_go'     : "",
                                            'captcha1': challenge,
                                            'captcha2': response,
                                            'fileId'  : self.info['pattern']['ID']},
                                      decode=True)

        if jsvars['message'] == 'success':
            self.link = jsvars['url']
Esempio n. 3
0
    def handleFree(self, pyfile):
        rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + self.info['pattern']['ID'], decode=True)

        self.logDebug("JSON: " + rep)

        json = self.parseJson(rep)
        self.wait(int(json['time']))

        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = recaptcha.challenge()
            rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" %
                            (challenge, response, json['hash']), decode=True)
            self.logDebug("JSON: " + rep)
            if 'link' in rep:
                json.update(self.parseJson(rep))
                self.correctCaptcha()
                break
            elif 'Verification failed' in rep:
                self.invalidCaptcha()
            else:
                self.error(_("Unable to get downlaod link"))

        if not json['link']:
            self.fail(_("No Download url retrieved/all captcha attempts failed"))

        self.download(json['link'])
Esempio n. 4
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url, decode=True)

        if 'var free_enabled = false;' in self.html:
            self.logError("Free-download capacities exhausted.")
            self.retry(24, 300)

        found = re.search(r"Current waiting period: <span>(\d+)</span> seconds", self.html)
        if not found:
            self.fail("File not downloadable for free users")
        self.setWait(int(found.group(1)))

        js = self.load("http://uploaded.net/js/download.js", decode=True)

        challengeId = re.search(r'Recaptcha\.create\("([^"]+)', js)

        url = "http://uploaded.net/io/ticket/captcha/%s" % self.fileID
        downloadURL = ""

        for i in range(5):
            #self.req.lastURL = str(self.url)
            re_captcha = ReCaptcha(self)
            challenge, result = re_captcha.challenge(challengeId.group(1))
            options = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": result}
            self.wait()

            result = self.load(url, post=options)
            self.logDebug("result: %s" % result)

            if "limit-size" in result:
                self.fail("File too big for free download")
            elif "limit-slot" in result:  # Temporary restriction so just wait a bit
                self.setWait(30 * 60, True)
                self.wait()
                self.retry()
            elif "limit-parallel" in result:
                self.fail("Cannot download in parallel")
            elif self.DL_LIMIT_PATTERN in result:  # limit-dl
                self.setWait(3 * 60 * 60, True)
                self.wait()
                self.retry()
            elif 'err:"captcha"' in result:
                self.logError("ul.net captcha is disabled")
                self.invalidCaptcha()
            elif "type:'download'" in result:
                self.correctCaptcha()
                downloadURL = re.search("url:'([^']+)", result).group(1)
                break
            else:
                self.fail("Unknown error '%s'")

        if not downloadURL:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.download(downloadURL, disposition=True)
        check = self.checkDownload({"limit-dl": self.DL_LIMIT_PATTERN})
        if check == "limit-dl":
            self.setWait(3 * 60 * 60, True)
            self.wait()
            self.retry()
Esempio n. 5
0
    def handleFree(self):
        file_id = re.match(self.__pattern__, self.pyfile.url).group('ID')
        self.logDebug('File ID: ' + file_id)
        rep = self.load(
            r"http://luckyshare.net/download/request/type/time/file/" +
            file_id,
            decode=True)
        self.logDebug('JSON: ' + rep)
        json = self.parseJson(rep)

        self.wait(int(json['time']))

        recaptcha = ReCaptcha(self)
        for _ in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            rep = self.load(
                r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s"
                % (challenge, response, json['hash']),
                decode=True)
            self.logDebug('JSON: ' + rep)
            if 'link' in rep:
                json.update(self.parseJson(rep))
                self.correctCaptcha()
                break
            elif 'Verification failed' in rep:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
            else:
                self.parseError('Unable to get downlaod link')

        if not json['link']:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.logDebug('Direct URL: ' + json['link'])
        self.download(json['link'])
Esempio n. 6
0
    def get_download_options(self):
        re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>",
                                self.html).group(0)  # get the whole request
        to_sort = re.findall(r"<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>", re_envelope)
        request_options = dict((n, v) for (v, n) in to_sort)

        herewego = self.load(self.pyfile.url, None, request_options)  # the actual download-Page

        # comment this in, when it doesnt work
        # with open("DUMP__FS_.HTML", "w") as fp:
        # fp.write(herewego)

        to_sort = re.findall(r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>", herewego)
        request_options = dict((n, v) for (v, n) in to_sort)

        # comment this in, when it doesnt work as well
        #print "\n\n%s\n\n" % ";".join(["%s=%s" % x for x in to_sort])

        challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", herewego)

        if challenge:
            re_captcha = ReCaptcha(self)
            (request_options["recaptcha_challenge_field"], 
             request_options["recaptcha_response_field"]) = re_captcha.challenge(challenge.group(1))

        return request_options
Esempio n. 7
0
    def freeDownload(self):

        form_content = re.search(r"<form style=.*(\n<.*>\s*)*?[\n\t]?<tr>", self.html[0])
        if form_content is None:
            print self.html[0]
            self.fail("Form not found in HTML. Can not proceed.")

        form_content = form_content.group(0)
        form_posts = dict(re.findall(r"<input\stype=hidden\sname=(\S*)\svalue=(\S*)>", form_content))

        self.html[1] = self.load(self.pyfile.url, post=form_posts)

        challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", self.html[1])

        if challenge:
            re_captcha = ReCaptcha(self)
            challenge, result = re_captcha.challenge(challenge.group(1))

            url = re.search(r'<form action="(/dl/[^"]+)', self.html[1])

            self.html[1] = self.load("http://hotfile.com" + url.group(1), post={"action": "checkcaptcha",
                                                                                "recaptcha_challenge_field": challenge,
                                                                                "recaptcha_response_field": result})

            if "Wrong Code. Please try again." in self.html[1]:
                self.freeDownload()
                return

        file_url = re.search(r'a href="(http://hotfile\.com/get/\S*)"', self.html[1]).group(1)
        self.download(file_url)
Esempio n. 8
0
    def handleFree(self, pyfile):
        inputs = self.parseHtmlForm(input_names={'token': re.compile(r'.+')})[1]
        if 'token' not in inputs:
            self.error(_("Unable to detect token"))

        self.html = self.load(pyfile.url, post={'token': inputs['token']}, decode=True)

        inputs = self.parseHtmlForm(input_names={'hash': re.compile(r'.+')})[1]
        if 'hash' not in inputs:
            self.error(_("Unable to detect hash"))

        recaptcha           = ReCaptcha(self)
        response, challenge = recaptcha.challenge()

        #@NOTE: Work-around for v0.4.9 just_header issue
        #@TODO: Check for v0.4.10
        self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0)
        self.load(pyfile.url, post={'recaptcha_challenge_field': challenge,
                                    'recaptcha_response_field' : response,
                                    'hash'                     : inputs['hash']})
        self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1)

        if 'location' in self.req.http.header.lower():
            self.link = re.search(r'location: (\S+)', self.req.http.header, re.I).group(1)
            self.correctCaptcha()
        else:
            self.invalidCaptcha()
Esempio n. 9
0
    def freeDownload(self):

        form_content = re.search(r"<form style=.*(\n<.*>\s*)*?[\n\t]?<tr>", self.html[0])
        if form_content is None:
            print self.html[0]
            self.fail("Form not found in HTML. Can not proceed.")

        form_content = form_content.group(0)
        form_posts = dict(re.findall(r"<input\stype=hidden\sname=(\S*)\svalue=(\S*)>", form_content))

        self.html[1] = self.load(self.pyfile.url, post=form_posts)

        challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", self.html[1])

        if challenge:
            re_captcha = ReCaptcha(self)
            challenge, result = re_captcha.challenge(challenge.group(1))

            url = re.search(r'<form action="(/dl/[^"]+)', self.html[1])

            self.html[1] = self.load("http://hotfile.com" + url.group(1), post={"action": "checkcaptcha",
                                                                                "recaptcha_challenge_field": challenge,
                                                                                "recaptcha_response_field": result})

            if "Wrong Code. Please try again." in self.html[1]:
                self.freeDownload()
                return

        file_url = re.search(r'a href="(http://hotfile\.com/get/\S*)"', self.html[1]).group(1)
        self.download(file_url)
Esempio n. 10
0
    def handleFree(self):
        ukey = re.match(self.__pattern__, self.pyfile.url).group(1)
        json_url = 'http://ifile.it/new_download-request.json'
        post_data = {"ukey": ukey, "ab": "0"}

        json_response = json_loads(self.load(json_url, post=post_data))
        self.logDebug(json_response)
        if json_response['status'] == 3:
            self.offline()

        if json_response["captcha"]:
            captcha_key = re.search(self.RECAPTCHA_KEY_PATTERN, self.html).group(1)
            recaptcha = ReCaptcha(self)
            post_data["ctype"] = "recaptcha"

            for _ in xrange(5):
                post_data["recaptcha_challenge"], post_data["recaptcha_response"] = recaptcha.challenge(captcha_key)
                json_response = json_loads(self.load(json_url, post=post_data))
                self.logDebug(json_response)

                if json_response["retry"]:
                    self.invalidCaptcha()
                else:
                    self.correctCaptcha()
                    break
            else:
                self.fail("Incorrect captcha")

        if not "ticket_url" in json_response:
            self.parseError("Download URL")

        self.download(json_response["ticket_url"])
Esempio n. 11
0
    def decrypt(self, pyfile):
        html = self.req.load(self.pyfile.url, cookies=True)

        m = re.search(
            r"src=\"http://www.google.com/recaptcha/api/challenge\?k=(.*?)\"></script>",
            html)
        if not m:
            self.offline()

        recaptcha = ReCaptcha(self)
        challenge, code = recaptcha.challenge(m.group(1))

        resultHTML = self.req.load(self.pyfile.url,
                                   post={
                                       "recaptcha_challenge_field": challenge,
                                       "recaptcha_response_field": code
                                   },
                                   cookies=True)

        if re.search("class=\"error\"", resultHTML):
            self.retry()

        self.correctCaptcha()

        dlc = self.req.load(self.pyfile.url + "/dlc", cookies=True)

        name = re.search(self.__pattern__, self.pyfile.url).group(1) + ".dlc"

        dlcFile = join(self.config["general"]["download_folder"], name)
        f = open(dlcFile, "wb")
        f.write(dlc)
        f.close()

        self.packages.append((self.pyfile.package().name, [dlcFile],
                              self.pyfile.package().folder))
Esempio n. 12
0
    def handleFree(self, pyfile):
        self.html = self.load(pyfile.url, post={'gateway_result': "1"})

        self.checkErrors()

        m = re.search(r"var fid = '(\w+)';", self.html)
        if m is None:
            self.retry(wait_time=5)
        params = {'fid': m.group(1)}
        self.logDebug("FID: %s" % params['fid'])

        self.checkErrors()

        recaptcha = ReCaptcha(self)
        captcha_key = recaptcha.detect_key()
        if captcha_key is None:
            return

        self.html = self.load("https://dfiles.eu/get_file.php", get=params)

        if '<input type=button value="Continue" onclick="check_recaptcha' in self.html:
            params['response'], params['challenge'] = recaptcha.challenge(captcha_key)
            self.html = self.load("https://dfiles.eu/get_file.php", get=params)

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            self.link = unquote(m.group(1))
Esempio n. 13
0
    def do_recaptcha(self):
        self.logDebug('Trying to solve captcha')
        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)
        shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN, self.html).group(1)
        url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1)

        recaptcha = ReCaptcha(self)

        for i in range(5):
            challenge, code = recaptcha.challenge(captcha_key)

            response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test',
                                            post={'challenge': challenge,
                                                  'response': code,
                                                  'shortencode': shortencode}))
            self.logDebug("reCaptcha response : %s" % response)
            if response == True:
                self.correctCaptcha()
                break
            else:
                self.invalidCaptcha()
        else:
            self.fail("Invalid captcha")

        return url
Esempio n. 14
0
    def get_download_options(self):
        re_envelope = re.search(
            r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>",
            self.html).group(0)  # get the whole request
        to_sort = re.findall(
            r"<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>",
            re_envelope)
        request_options = dict((n, v) for (v, n) in to_sort)

        herewego = self.load(self.pyfile.url, None,
                             request_options)  # the actual download-Page

        # comment this in, when it doesnt work
        # with open("DUMP__FS_.HTML", "w") as fp:
        # fp.write(herewego)

        to_sort = re.findall(
            r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>",
            herewego)
        request_options = dict((n, v) for (v, n) in to_sort)

        # comment this in, when it doesnt work as well
        #print "\n\n%s\n\n" % ";".join(["%s=%s" % x for x in to_sort])

        challenge = re.search(
            r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)",
            herewego)

        if challenge:
            re_captcha = ReCaptcha(self)
            (request_options["recaptcha_challenge_field"],
             request_options["recaptcha_response_field"]
             ) = re_captcha.challenge(challenge.group(1))

        return request_options
Esempio n. 15
0
    def handleFree(self):
        file_id = re.match(self.__pattern__, self.pyfile.url).group('ID')
        self.logDebug('File ID: ' + file_id)
        rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + file_id, decode=True)
        self.logDebug('JSON: ' + rep)
        json = self.parseJson(rep)

        self.wait(int(json['time']))

        recaptcha = ReCaptcha(self)
        for _ in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" %
                            (challenge, response, json['hash']), decode=True)
            self.logDebug('JSON: ' + rep)
            if 'link' in rep:
                json.update(self.parseJson(rep))
                self.correctCaptcha()
                break
            elif 'Verification failed' in rep:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
            else:
                self.parseError('Unable to get downlaod link')

        if not json['link']:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.logDebug('Direct URL: ' + json['link'])
        self.download(json['link'])
Esempio n. 16
0
    def do_recaptcha(self):
        self.logDebug('Trying to solve captcha')
        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)
        shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN,
                                self.html).group(1)
        url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1)

        recaptcha = ReCaptcha(self)

        for i in range(5):
            challenge, code = recaptcha.challenge(captcha_key)

            response = json_loads(
                self.load(self.file_info['HOST'] + '/rest/captcha/test',
                          post={
                              'challenge': challenge,
                              'response': code,
                              'shortencode': shortencode
                          }))
            self.logDebug("reCaptcha response : %s" % response)
            if response == True:
                self.correctCaptcha()
                break
            else:
                self.invalidCaptcha()
        else:
            self.fail("Invalid captcha")

        return url
Esempio n. 17
0
 def handleCaptcha(self, inputs):
     found = re.search(self.RECAPTCHA_URL_PATTERN, self.html)
     if found:
         recaptcha_key = unquote(found.group(1))
         self.logDebug("RECAPTCHA KEY: %s" % recaptcha_key)
         recaptcha = ReCaptcha(self)
         inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key)
         return 1
     else:
         found = re.search(self.CAPTCHA_URL_PATTERN, self.html)
         if found:
             captcha_url = found.group(1)
             inputs['code'] = self.decryptCaptcha(captcha_url)
             return 2
         else:
             found = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S)
             if found:
                 captcha_div = found.group(1)
                 self.logDebug(captcha_div)
                 numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div))
                 inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))])
                 self.logDebug("CAPTCHA", inputs['code'], numerals)
                 return 3
             else:
                 found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
                 if found:
                     captcha_key = found.group(1)
                     captcha = SolveMedia(self)
                     inputs['adcopy_challenge'], inputs['adcopy_response'] = captcha.challenge(captcha_key)
                     return 4
     return 0
Esempio n. 18
0
    def decrypt(self, pyfile):
        html = self.req.load(self.pyfile.url, cookies=True)

        m = re.search(r"src=\"http://www.google.com/recaptcha/api/challenge\?k=(.*?)\"></script>", html)
        if not m:
            self.offline()

        recaptcha = ReCaptcha(self)
        challenge, code = recaptcha.challenge(m.group(1))

        resultHTML = self.req.load(self.pyfile.url,
                                   post={"recaptcha_challenge_field": challenge, "recaptcha_response_field": code},
                                   cookies=True)

        if re.search("class=\"error\"", resultHTML):
            self.retry()

        self.correctCaptcha()

        dlc = self.req.load(self.pyfile.url + "/dlc", cookies=True)

        name = re.search(self.__pattern__, self.pyfile.url).group(1) + ".dlc"

        dlcFile = join(self.config["general"]["download_folder"], name)
        f = open(dlcFile, "wb")
        f.write(dlc)
        f.close()

        self.packages.append((self.pyfile.package().name, [dlcFile], self.pyfile.package().folder))
Esempio n. 19
0
    def solveCaptcha(self):
        recaptcha = ReCaptcha(self)
        for _ in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            apiUrl = "https://www.oboom.com/1.0/download/ticket"
            params = {"recaptcha_challenge_field": challenge,
                      "recaptcha_response_field": response,
                      "download_id": self.fileId,
                      "token": self.sessionToken}
            result = self.loadUrl(apiUrl, params)

            if result[0] == 200:
                self.downloadToken = result[1]
                self.downloadAuth = result[2]
                self.correctCaptcha()
                self.setWait(30)
                self.wait()
                break
            elif result[0] == 400:
                if result[1] == "incorrect-captcha-sol":
                    self.invalidCaptcha()
                elif result[1] == "captcha-timeout":
                    self.invalidCaptcha()
                elif result[1] == "forbidden":
                    self.retry(5, 15 * 60, "Service unavailable")
            elif result[0] == 403:
                if result[1] == -1:  # another download is running
                    self.setWait(15 * 60)
                else:
                    self.setWait(result[1], reconnect=True)
                self.wait()
                self.retry(5)
        else:
            self.invalidCaptcha()
            self.fail("Received invalid captcha 5 times")
Esempio n. 20
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url, decode=True)
        self.getFileInfo()

        # Wait time between free downloads
        if 'For next free download you have to wait' in self.html:
            m = re.search(self.WAIT_TIME_PATTERN, self.html).groupdict('0')
            waittime = int(m['m']) * 60 + int(m['s'])
            self.setWait(waittime, True)
            self.wait()

        downloadURL = ''
        recaptcha = ReCaptcha(self)
        for i in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {'recaptcha_challenge_field': challenge,
                         'recaptcha_response_field': response}
            self.html = self.load(self.pyfile.url, post=post_data, decode=True)
            m = re.search(self.DIRECT_LINK_PATTERN, self.html)
            if not m:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
            elif hasattr(m, 'group'):
                downloadURL = m.group('link')
                self.correctCaptcha()
                break
            else:
                self.fail('Unknown error - Plugin may be out of date')

        if not downloadURL:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.download(downloadURL, disposition=True)
Esempio n. 21
0
    def handleFree(self):
        found = re.search(self.WAIT_PATTERN, self.html)
        seconds = int(found.group(1))
        self.logDebug("Found wait", seconds)
        self.setWait(seconds + 1)
        self.wait()
        response = self.load('http://cloudzer.net/io/ticket/slot/%s' % self.file_info['ID'], post=' ', cookies=True)
        self.logDebug("Download slot request response", response)
        response = json_loads(response)
        if response["succ"] is not True:
            self.fail("Unable to get a download slot")

        recaptcha = ReCaptcha(self)
        challenge, response = recaptcha.challenge(self.CAPTCHA_KEY)
        post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response}
        response = json_loads(self.load('http://cloudzer.net/io/ticket/captcha/%s' % self.file_info['ID'],
                                        post=post_data, cookies=True))
        self.logDebug("Captcha check response", response)
        self.logDebug("First check")

        if "err" in response:
            if response["err"] == "captcha":
                self.logDebug("Wrong captcha")
                self.invalidCaptcha()
                self.retry()
            elif "Sie haben die max" in response["err"] or "You have reached the max" in response["err"]:
                self.logDebug("Download limit reached, waiting an hour")
                self.setWait(3600, True)
                self.wait()
        if "type" in response:
            if response["type"] == "download":
                url = response["url"]
                self.logDebug("Download link", url)
                self.download(url, disposition=True)
Esempio n. 22
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url, decode=True)
        self.getFileInfo()

        # Wait time between free downloads
        if 'For next free download you have to wait' in self.html:
            m = re.search(self.WAIT_TIME_PATTERN, self.html).groupdict('0')
            waittime = int(m['m']) * 60 + int(m['s'])
            self.setWait(waittime, True)
            self.wait()

        downloadURL = ''
        recaptcha = ReCaptcha(self)
        for i in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {
                'recaptcha_challenge_field': challenge,
                'recaptcha_response_field': response
            }
            self.html = self.load(self.pyfile.url, post=post_data, decode=True)
            m = re.search(self.DIRECT_LINK_PATTERN, self.html)
            if not m:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
            elif hasattr(m, 'group'):
                downloadURL = m.group('link')
                self.correctCaptcha()
                break
            else:
                self.fail('Unknown error - Plugin may be out of date')

        if not downloadURL:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.download(downloadURL, disposition=True)
Esempio n. 23
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url, decode=True)

        if 'var free_enabled = false;' in self.html:
            self.logError("Free-download capacities exhausted.")
            self.retry(24, 300)

        found = re.search(r"Current waiting period: <span>(\d+)</span> seconds", self.html)
        if not found:
            self.fail("File not downloadable for free users")
        self.setWait(int(found.group(1)))

        js = self.load("http://uploaded.net/js/download.js", decode=True)

        challengeId = re.search(r'Recaptcha\.create\("([^"]+)', js)

        url = "http://uploaded.net/io/ticket/captcha/%s" % self.fileID
        downloadURL = ""

        for i in range(5):
            re_captcha = ReCaptcha(self)
            challenge, result = re_captcha.challenge(challengeId.group(1))
            options = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": result}
            self.wait()

            result = self.load(url, post=options)
            self.logDebug("result: %s" % result)

            if "limit-size" in result:
                self.fail("File too big for free download")
            elif "limit-slot" in result:  # Temporary restriction so just wait a bit
                self.setWait(30 * 60, True)
                self.wait()
                self.retry()
            elif "limit-parallel" in result:
                self.fail("Cannot download in parallel")
            elif self.DL_LIMIT_PATTERN in result:  # limit-dl
                self.setWait(3 * 60 * 60, True)
                self.wait()
                self.retry()
            elif 'err:"captcha"' in result:
                self.logError("ul.net captcha is disabled")
                self.invalidCaptcha()
            elif "type:'download'" in result:
                self.correctCaptcha()
                downloadURL = re.search("url:'([^']+)", result).group(1)
                break
            else:
                self.fail("Unknown error '%s'")

        if not downloadURL:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.download(downloadURL, disposition=True)
        check = self.checkDownload({"limit-dl": self.DL_LIMIT_PATTERN})
        if check == "limit-dl":
            self.setWait(3 * 60 * 60, True)
            self.wait()
            self.retry()
Esempio n. 24
0
    def handleFree(self):
        fid = re.search(
            r'<input type="hidden" name="slow_id" value="([^"]+)">',
            self.html).group(1)
        self.html = self.load(self.pyfile.url,
                              post={
                                  'yt0': '',
                                  'slow_id': fid
                              })

        m = re.search(self.WAIT_PATTERN, self.html)
        if m:
            wait_string = m.group(1)
            wait_time = int(wait_string[0:2]) * 3600 + int(
                wait_string[3:5]) * 60 + int(wait_string[6:8])
            self.setWait(wait_time, True)
            self.wait()
            self.process(self.pyfile)

        recaptcha = ReCaptcha(self)
        for i in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {
                'recaptcha_challenge_field': challenge,
                'recaptcha_response_field': response,
                'CaptchaForm%5Bcode%5D': '',
                'free': 1,
                'freeDownloadRequest': 1,
                'uniqueId': fid,
                'yt0': ''
            }

            self.html = self.load(self.pyfile.url, post=post_data)

            if 'recaptcha' not in self.html:
                self.correctCaptcha()
                self.setWait(30)
                self.wait()
                break
            else:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
        else:
            self.fail("All captcha attempts failed")

        self.html = self.load(self.pyfile.url,
                              post={
                                  'uniqueId': fid,
                                  'free': 1
                              })

        dl = 'http://keep2share.cc'
        m = re.search(self.DIRECT_LINK_PATTERN, self.html)
        if not m:
            self.parseError("Unable to detect direct link")
        dl += m.group(1)
        self.logDebug('Direct Link: ' + dl)
        self.download(dl, disposition=True)
Esempio n. 25
0
    def handleFree(self):
        self.loadAPIData()
        self.pyfile.name = self.api_data["filename"]
        self.pyfile.size = int(self.api_data["size"])

        self.html = self.load(self.pyfile.url, cookies=True)  # refer, stuff
        self.setWait(3)
        self.wait()

        self.html = self.load("%s/free/" % self.pyfile.url,
                              post={
                                  "dl_free": "1",
                                  "choice": "free"
                              },
                              decode=True)
        self.checkErrors()

        found = re.search(r'var wait=(\d+);', self.html)

        recaptcha = ReCaptcha(self)
        for _ in xrange(5):
            challenge, response = recaptcha.challenge(
                "6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX")
            self.setWait(int(found.group(1)) if found else 30)
            response = self.load("%s/free/captcha/%d" %
                                 (self.pyfile.url, int(time() * 1000)),
                                 post={
                                     'dl_free': '1',
                                     'recaptcha_challenge_field': challenge,
                                     'recaptcha_response_field': response
                                 })

            if not response == '0':
                break
        else:
            self.fail("No valid captcha solution received")

        download_url = response.decode("base64")
        self.logDebug(download_url)
        if not download_url.startswith("http://"):
            self.parseError("download url")

        self.wait()
        self.download(download_url)
        # check download
        check = self.checkDownload({
            "cookie":
            re.compile(r'<div id="dl_failure"'),
            "fail":
            re.compile(r"<title>Share-Online")
        })
        if check == "cookie":
            self.retry(5, 60, "Cookie failure")
        elif check == "fail":
            self.retry(5, 5 * 60, "Download failed")
Esempio n. 26
0
    def handleFree(self, pyfile):
        recaptcha   = ReCaptcha(self)
        captcha_key = recaptcha.detect_key()

        if captcha_key:
            try:
                self.link = re.search(self.LINK_PREMIUM_PATTERN, self.html)
                recaptcha.challenge()

            except Exception, e:
                self.error(e)
Esempio n. 27
0
    def handleFree(self):
        self.req.setOption("timeout", 120)
        self.html = self.load(self.pyfile.url, decode=not self.SH_BROKEN_ENCODING, cookies=self.SH_COOKIES)

        # Wait between downloads
        m = re.search(r'musst du <span id="time">(\d+)</span> Sekunden warten', self.html)
        if m:
            waittime = int(m.group(1))
            self.retry(3, waittime, 'Wait between free downloads')

        self.getFileInfo()

        self.html = self.load(self.pyfile.url, decode=True)

        inputs = self.parseHtmlForm(input_names='token')[1]
        if 'token' not in inputs:
            self.parseError('Unable to detect token')
        token = inputs['token']
        self.logDebug('Token: ' + token)

        self.html = self.load(self.pyfile.url, post={'token': token}, decode=True)

        inputs = self.parseHtmlForm(input_names='hash')[1]
        if 'hash' not in inputs:
            self.parseError('Unable to detect hash')
        hash_data = inputs['hash']
        self.logDebug('Hash: ' + hash_data)

        downloadURL = ''
        recaptcha = ReCaptcha(self)
        for i in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {'recaptcha_challenge_field': challenge,
                         'recaptcha_response_field': response,
                         'hash': hash_data}

            # Workaround for 0.4.9 just_header issue. In 0.5 clean the code using just_header
            self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0)
            self.load(self.pyfile.url, post=post_data)
            self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1)

            if 'location' in self.req.http.header:
                location = re.search(r'location: (\S+)', self.req.http.header).group(1)
                downloadURL = 'http://filer.net' + location
                self.correctCaptcha()
                break
            else:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()

        if not downloadURL:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.download(downloadURL, disposition=True)
Esempio n. 28
0
    def getDownloadUrl(self):
        # Return location if direct download is active
        if self.premium:
            header = self.load(self.pyfile.url, cookies=True, just_header=True)
            if 'location' in header:
                return header['location']

        # Get download info
        self.logDebug("Getting download info")
        response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
                             post={"request": "generateID", "ajaxid": self.ajaxid})
        self.handleErrors(response, ':')
        parts = response.split(":")
        filetype = parts[0]
        wait = int(parts[1])
        captcha = int(parts[2])
        self.logDebug("Download info [type: '%s', waiting: %d, captcha: %d]" % (filetype, wait, captcha))

        # Waiting
        if wait > 0:
            self.logDebug("Waiting %d seconds." % wait)
            if wait < 120:
                self.setWait(wait, False)
                self.wait()
            else:
                self.setWait(wait - 55, True)
                self.wait()
                self.retry()

        # Resolve captcha
        if captcha == 1:
            self.logDebug("File is captcha protected")
            id = re.search(BitshareCom.CAPTCHA_KEY_PATTERN, self.html).group(1)
            # Try up to 3 times
            for i in range(3):
                self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i + 1))
                recaptcha = ReCaptcha(self)
                challenge, code = recaptcha.challenge(id)
                response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
                                     post={"request": "validateCaptcha", "ajaxid": self.ajaxid,
                                           "recaptcha_challenge_field": challenge, "recaptcha_response_field": code})
                if self.handleCaptchaErrors(response):
                    break

        # Get download URL
        self.logDebug("Getting download url")
        response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
                             post={"request": "getDownloadURL", "ajaxid": self.ajaxid})
        self.handleErrors(response, '#')
        url = response.split("#")[-1]

        return url
Esempio n. 29
0
    def unlockProtection(self):

        postData = {}

        form = re.search(r'<form name="protected"(.*?)</form>',
                         self.cleanedHtml, re.DOTALL).group(1)

        # Submit package password
        if "password" in form:
            password = self.getPassword()
            self.logDebug("Submitting password [%s] for protected links" %
                          password)
            postData['password'] = password

        # Resolve anicaptcha
        if "anicaptcha" in form:
            self.captcha = True
            self.logDebug("Captcha protected, resolving captcha")
            captchaUri = re.search(r'src="(/temp/anicaptcha/[^"]+)',
                                   form).group(1)
            captcha = self.decryptCaptcha("http://ncrypt.in" + captchaUri)
            self.logDebug("Captcha resolved [%s]" % captcha)
            postData['captcha'] = captcha

        # Resolve recaptcha
        if "recaptcha" in form:
            self.captcha = True
            id = re.search(r'\?k=(.*?)"', form).group(1)
            self.logDebug("Resolving ReCaptcha with key [%s]" % id)
            recaptcha = ReCaptcha(self)
            challenge, code = recaptcha.challenge(id)
            postData['recaptcha_challenge_field'] = challenge
            postData['recaptcha_response_field'] = code

        # Resolve circlecaptcha
        if "circlecaptcha" in form:
            self.captcha = True
            self.logDebug("Captcha protected")
            captcha_img_url = "http://ncrypt.in/classes/captcha/circlecaptcha.php"
            coords = self.decryptCaptcha(captcha_img_url,
                                         forceUser=True,
                                         imgtype="png",
                                         result_type='positional')
            self.logDebug("Captcha resolved, coords [%s]" % str(coords))
            self.captcha_post_url = self.pyfile.url

            postData['circle.x'] = coords[0]
            postData['circle.y'] = coords[1]

        # Unlock protection
        postData['submit_protected'] = 'Continue to folder '
        return self.load(self.pyfile.url, post=postData)
Esempio n. 30
0
    def handleFree(self):
        self.loadAPIData()
        self.pyfile.name = self.api_data["filename"]
        self.pyfile.size = int(self.api_data["size"])

        self.html = self.load(self.pyfile.url, cookies=True)  # refer, stuff
        self.setWait(3)
        self.wait()

        self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True)
        self.checkErrors()

        found = re.search(r'var wait=(\d+);', self.html)

        recaptcha = ReCaptcha(self)
        for _ in xrange(5):
            challenge, response = recaptcha.challenge("6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX")
            self.setWait(int(found.group(1)) if found else 30)
            response = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), post={
                'dl_free': '1',
                'recaptcha_challenge_field': challenge,
                'recaptcha_response_field': response})

            if not response == '0':
                self.correctCaptcha()
                break
            else:
                self.invalidCaptcha()
        else:
            self.invalidCaptcha()
            self.fail("No valid captcha solution received")

        download_url = response.decode("base64")
        self.logDebug(download_url)
        if not download_url.startswith("http://"):
            self.parseError("download url")

        self.wait()
        self.download(download_url)
        # check download
        check = self.checkDownload({
            "cookie": re.compile(r'<div id="dl_failure"'),
            "fail": re.compile(r"<title>Share-Online")
        })
        if check == "cookie":
            self.invalidCaptcha()
            self.retry(5, 60, "Cookie failure")
        elif check == "fail":
            self.invalidCaptcha()
            self.retry(5, 5 * 60, "Download failed")
        else:
            self.correctCaptcha()
Esempio n. 31
0
    def handleFree(self):
        if r">Only premium users can download this file" in self.html:
            self.fail("Only premium users can download this file")

        m = re.search(
            r"Next free download from your ip will be available in <b>(\d+)\s*minutes",
            self.html)
        if m:
            self.setWait(int(m.group(1)) * 60, True)
            self.wait()
        elif "The daily downloads limit from your IP is exceeded" in self.html:
            self.setWait(3600, True)
            self.wait()

        self.logDebug("URL: " + self.req.http.lastEffectiveURL)
        m = re.match(self.__pattern__, self.req.http.lastEffectiveURL)
        fileID = m.group('ID') if m else self.file_info('ID')

        m = re.search(r'recaptcha/api/challenge\?k=(\w+)', self.html)
        if m:
            recaptcha = ReCaptcha(self)
            captcha_key = m.group(1)

            for i in range(5):
                get_data = {"type": "recaptcha"}
                get_data["challenge"], get_data[
                    "capture"] = recaptcha.challenge(captcha_key)
                response = json_loads(
                    self.load("http://extabit.com/file/%s/" % fileID,
                              get=get_data))
                if "ok" in response:
                    self.correctCaptcha()
                    break
                else:
                    self.invalidCaptcha()
            else:
                self.fail("Invalid captcha")
        else:
            self.parseError('Captcha')

        if not "href" in response:
            self.parseError('JSON')

        self.html = self.load("http://extabit.com/file/%s%s" %
                              (fileID, response['href']))
        m = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
        if not m:
            self.parseError('Download URL')
        url = m.group(1)
        self.logDebug("Download URL: " + url)
        self.download(url)
Esempio n. 32
0
 def handleFree(self):
     found = re.search(self.SECONDS_PATTERN, self.html)
     seconds = int(found.group(1))
     self.logDebug("Seconds found", seconds)
     self.wait(seconds + 1)
     recaptcha = ReCaptcha(self)
     challenge, code = recaptcha.challenge(self.RECAPTCHA_KEY)
     post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": code}
     self.download(self.pyfile.url, post=post_data)
     check = self.checkDownload({"html": re.compile("\A<!DOCTYPE html PUBLIC")})
     if check == "html":
         self.logDebug("Wrong captcha entered")
         self.invalidCaptcha()
         self.retry()
Esempio n. 33
0
 def handleFree(self):
     found = re.search(self.SECONDS_PATTERN, self.html)
     seconds = int(found.group(1))
     self.logDebug("Seconds found", seconds)
     self.setWait(seconds + 1)
     self.wait()
     recaptcha = ReCaptcha(self)
     challenge, code = recaptcha.challenge(self.RECAPTCHA_KEY)
     post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": code}
     self.download(self.pyfile.url, post=post_data)
     check = self.checkDownload({"html": re.compile("\A<!DOCTYPE html PUBLIC")})
     if check == "html":
         self.logDebug("Wrong captcha entered")
         self.invalidCaptcha()
         self.retry()
Esempio n. 34
0
    def downloadFree(self):
        self.logDebug("Free download")
        # Get initial page
        self.html = self.load(self.pyfile.url)
        url = self.pyfile.url + "?start=1"
        self.html = self.load(url)
        self.handleErrors()

        finalUrl = re.search(self.FILE_LINK_PATTERN, self.html)

        if not finalUrl:
            self.doWait(url)

            chall = re.search(self.CAPTCHA_TYPE1_PATTERN, self.html)
            chall2 = re.search(self.CAPTCHA_TYPE2_PATTERN, self.html)
            if chall or chall2:
                for i in range(5):
                    re_captcha = ReCaptcha(self)
                    if chall:
                        self.logDebug("Captcha type1")
                        challenge, result = re_captcha.challenge(chall.group(1))
                    else:
                        self.logDebug("Captcha type2")
                        server = chall2.group(1)
                        challenge = chall2.group(2)
                        result = re_captcha.result(server, challenge)

                    postData = {"recaptcha_challenge_field": challenge,
                                "recaptcha_response_field": result}

                    self.html = self.load(url, post=postData)
                    self.handleErrors()
                    chall = re.search(self.CAPTCHA_TYPE1_PATTERN, self.html)
                    chall2 = re.search(self.CAPTCHA_TYPE2_PATTERN, self.html)

                    if chall or chall2:
                        self.invalidCaptcha()
                    else:
                        self.correctCaptcha()
                        break

            finalUrl = re.search(self.FILE_LINK_PATTERN, self.html)

        if not finalUrl:
            self.fail("Couldn't find free download link")

        self.logDebug("got download url %s" % finalUrl.group(1))
        self.download(finalUrl.group(1))
Esempio n. 35
0
    def downloadFree(self):
        self.logDebug("Free download")
        # Get initial page
        self.html = self.load(self.pyfile.url)
        url = self.pyfile.url + "?start=1"
        self.html = self.load(url)
        self.handleErrors()

        finalUrl = re.search(self.FILE_LINK_PATTERN, self.html)

        if not finalUrl:
            self.doWait(url)

            chall = re.search(self.CAPTCHA_TYPE1_PATTERN, self.html)
            chall2 = re.search(self.CAPTCHA_TYPE2_PATTERN, self.html)
            if chall or chall2:
                for i in range(5):
                    re_captcha = ReCaptcha(self)
                    if chall:
                        self.logDebug("Captcha type1")
                        challenge, result = re_captcha.challenge(chall.group(1))
                    else:
                        self.logDebug("Captcha type2")
                        server = chall2.group(1)
                        challenge = chall2.group(2)
                        result = re_captcha.result(server, challenge)

                    postData = {"recaptcha_challenge_field": challenge,
                                "recaptcha_response_field": result}

                    self.html = self.load(url, post=postData)
                    self.handleErrors()
                    chall = re.search(self.CAPTCHA_TYPE1_PATTERN, self.html)
                    chall2 = re.search(self.CAPTCHA_TYPE2_PATTERN, self.html)

                    if chall or chall2:
                        self.invalidCaptcha()
                    else:
                        self.correctCaptcha()
                        break

            finalUrl = re.search(self.FILE_LINK_PATTERN, self.html)

        if not finalUrl:
            self.fail("Couldn't find free download link")

        self.logDebug("got download url %s" % finalUrl.group(1))
        self.download(finalUrl.group(1))
Esempio n. 36
0
    def handleFree(self, pyfile):
        if "You need Premium membership to download this file." in self.html:
            self.fail(_("You need Premium membership to download this file"))

        for _i in xrange(5):
            m = re.search(self.CAPTCHA_PATTERN, self.html)
            if m:
                url, wait_time = 'http://crocko.com' + m.group(1), int(m.group(2))
                self.wait(wait_time)
                self.html = self.load(url)
            else:
                break

        m = re.search(self.FORM_PATTERN, self.html, re.S)
        if m is None:
            self.error(_("FORM_PATTERN not found"))

        action, form = m.groups()
        inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form))
        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge()
            self.download(action, post=inputs)

            if self.checkDownload({"captcha": recaptcha.KEY_AJAX_PATTERN}):
                self.invalidCaptcha()
            else:
                break
        else:
            self.fail(_("No valid captcha solution received"))
Esempio n. 37
0
    def handleFree(self, pyfile):
        url = 'http://datei.to/ajax/download.php'
        data = {'P': 'I', 'ID': self.info['pattern']['ID']}
        recaptcha = ReCaptcha(self)

        for _i in xrange(10):
            self.logDebug("URL", url, "POST", data)
            self.html = self.load(url, post=data)
            self.checkErrors()

            if url.endswith('download.php') and 'P' in data:
                if data['P'] == 'I':
                    self.doWait()

                elif data['P'] == 'IV':
                    break

            m = re.search(self.DATA_PATTERN, self.html)
            if m is None:
                self.error(_("data"))
            url = 'http://datei.to/' + m.group(1)
            data = dict(x.split('=') for x in m.group(2).split('&'))

            if url.endswith('recaptcha.php'):
                data['recaptcha_response_field'], data['recaptcha_challenge_field'] = recaptcha.challenge()
        else:
            self.fail(_("Too bad..."))

        self.link = self.html
Esempio n. 38
0
    def solveCaptcha(self):
        for _i in xrange(5):
            m = re.search(self.LIMIT_WAIT_PATTERN, self.html)
            if m:
                wait_time = int(m.group(1))
                self.wait(wait_time, wait_time > 60)
                self.retry()

            action, inputs = self.parseHtmlForm("action='#'")
            if not inputs:
                self.error(_("Captcha form not found"))
            self.logDebug(inputs)

            if inputs['captcha_type'] == 'recaptcha':
                recaptcha = ReCaptcha(self)
                inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge()
            else:
                m = re.search(self.CAPTCHA_PATTERN, self.html)
                if m is None:
                    self.error(_("captcha"))
                captcha_url = m.group(1)
                inputs['captcha_response'] = self.decryptCaptcha(captcha_url)

            self.logDebug(inputs)
            self.html = self.load(self.url, post=inputs)

            if '<div class="captcha-error">Incorrect, try again!<' in self.html:
                self.invalidCaptcha()
            else:
                self.correctCaptcha()
                break
        else:
            self.fail(_("Invalid captcha"))
Esempio n. 39
0
 def handleCaptcha(self, inputs):
     found = re.search(self.RECAPTCHA_URL_PATTERN, self.html)
     if found:
         recaptcha_key = unquote(found.group(1))
         self.logDebug("RECAPTCHA KEY: %s" % recaptcha_key)
         recaptcha = ReCaptcha(self)
         inputs["recaptcha_challenge_field"], inputs["recaptcha_response_field"] = recaptcha.challenge(recaptcha_key)
         return 1
     else:
         found = re.search(self.CAPTCHA_URL_PATTERN, self.html)
         if found:
             captcha_url = found.group(1)
             inputs["code"] = self.decryptCaptcha(captcha_url)
             return 2
         else:
             found = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S)
             if found:
                 captcha_div = found.group(1)
                 self.logDebug(captcha_div)
                 numerals = re.findall(
                     r"<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>", html_unescape(captcha_div)
                 )
                 inputs["code"] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))])
                 self.logDebug("CAPTCHA", inputs["code"], numerals)
                 return 3
             else:
                 found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
                 if found:
                     captcha_key = found.group(1)
                     captcha = SolveMedia(self)
                     inputs["adcopy_challenge"], inputs["adcopy_response"] = captcha.challenge(captcha_key)
                     return 4
     return 0
Esempio n. 40
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url)

        #get wait time
        found = re.search('\s*var\sdownloadWait\s=\s(\d+);', self.html)
        self.setWait(int(found.group(1)) if found else 30)

        #parse download form
        action, inputs = parseHtmlForm('id="download', self.html)

        #solve captcha
        found = re.search('recaptcha/api/(?:challenge|noscript)?k=(.+?)',
                          self.html)
        captcha_key = found.group(
            1) if found else "6LdEFb0SAAAAAAwM70vnYo2AkiVkCx-xmfniatHz"

        recaptcha = ReCaptcha(self)

        inputs['recaptcha_challenge_field'], inputs[
            'recaptcha_response_field'] = recaptcha.challenge(captcha_key)
        self.wait()

        #validate
        self.req.http.c.setopt(FOLLOWLOCATION, 0)
        self.html = self.load(action, post=inputs)

        found = re.search(r"Location\s*:\s*(\S*)", self.req.http.header, re.I)
        if found:
            self.correctCaptcha()
            download_url = found.group(1)
        else:
            if "Sicherheitscode falsch" in self.html:
                self.invalidCaptcha()
                self.retry(max_tries=5, reason="Invalid captcha")
            else:
                self.fail("Invalid session")

        #download
        self.req.http.c.setopt(FOLLOWLOCATION, 1)
        self.download(download_url)

        check = self.checkDownload(
            {"ip_blocked": re.compile(r'<div class="error".*IP.*loading')})
        if check == "ip_blocked":
            self.setWait(1800, True)
            self.wait()
            self.retry()
Esempio n. 41
0
    def process(self, pyfile):
        self.html = self.load(pyfile.url, decode=True)
        self.getFileInfo()

        # Check if File is online
        if re.search(self.FILE_OFFLINE_PATTERN, self.html):
            self.offline()

        # Search for Download URL
        m = re.search(self.URL_PATTERN, self.html)
        if not m:
            self.parseError('Unable to detect download URL')
        download_url = m.group(1)

        # Set Timer - may be obsolete
        m = re.search(self.WAIT_PATTERN, self.html)
        if m:
            self.wait(m.group(1))

        # Check if reCaptcha is present
        m = re.search(self.RECAPTCHA_PATTERN, self.html)
        if not m:  # No captcha found
            self.download(download_url)
        else:
            recaptcha = ReCaptcha(self)
            for _ in xrange(5):
                challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
                if not response == '0':
                    break
            else:
                self.fail("No valid captcha solution received")

            self.download(download_url,
                          post={
                              'recaptcha_challenge_field': challenge,
                              'recaptcha_response_field': response
                          })

            # Verifiy reCaptcha by checking content of file for html 404-error
            check = self.checkDownload(
                {"404": re.compile("\A<h1>404 Not Found</h1>")})
            if check == "404":
                self.logWarning(
                    "The captcha you entered was incorrect. Please try again.")
                self.invalidCaptcha()
                self.retry()
Esempio n. 42
0
    def doCaptcha(self):
        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)
        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = recaptcha.challenge(captcha_key)
            res = json_loads(self.load(self.URLS[2],
                                       post={'recaptcha_challenge_field'  : challenge,
                                             'recaptcha_response_field'   : response,
                                             'recaptcha_shortencode_field': self.file_id}))
            if not res['success']:
                self.invalidCaptcha()
            else:
                self.correctCaptcha()
                break
        else:
            self.fail(_("Invalid captcha"))
Esempio n. 43
0
    def unlockProtection(self):

        postData = {}

        form = re.search(r'<form name="protected"(.*?)</form>', self.cleanedHtml, re.DOTALL).group(1)

        # Submit package password
        if "password" in form:
            password = self.getPassword()
            self.logDebug("Submitting password [%s] for protected links" % password)
            postData['password'] = password

        # Resolve anicaptcha
        if "anicaptcha" in form:
            self.captcha = True
            self.logDebug("Captcha protected, resolving captcha")
            captchaUri = re.search(r'src="(/temp/anicaptcha/[^"]+)', form).group(1)
            captcha = self.decryptCaptcha("http://ncrypt.in" + captchaUri)
            self.logDebug("Captcha resolved [%s]" % captcha)
            postData['captcha'] = captcha

        # Resolve recaptcha           
        if "recaptcha" in form:
            self.captcha = True
            id = re.search(r'\?k=(.*?)"', form).group(1)
            self.logDebug("Resolving ReCaptcha with key [%s]" % id)
            recaptcha = ReCaptcha(self)
            challenge, code = recaptcha.challenge(id)
            postData['recaptcha_challenge_field'] = challenge
            postData['recaptcha_response_field'] = code

        # Resolve circlecaptcha
        if "circlecaptcha" in form:
            self.captcha = True
            self.logDebug("Captcha protected")
            captcha_img_url = "http://ncrypt.in/classes/captcha/circlecaptcha.php"
            coords = self.decryptCaptcha(captcha_img_url, forceUser=True, imgtype="png", result_type='positional')
            self.logDebug("Captcha resolved, coords [%s]" % str(coords))
            self.captcha_post_url = self.pyfile.url

            postData['circle.x'] = coords[0]
            postData['circle.y'] = coords[1]

        # Unlock protection
        postData['submit_protected'] = 'Continue to folder '
        return self.load(self.pyfile.url, post=postData)
Esempio n. 44
0
    def handleFree(self):
        # STAGE 1: get link to continue
        m = re.search(self.CHASH_PATTERN, self.html)
        if not m:
            self.parseError("could not detect hash")
        chash = m.group(1)
        self.logDebug("read hash " + chash)
        # continue to stage2
        post_data = {'hash': chash, 'free': 'Slow download'}
        self.html = self.load(self.pyfile.url, post=post_data, decode=True)

        # STAGE 2: solv captcha and wait
        # first get the infos we need: recaptcha key and wait time
        recaptcha = ReCaptcha(self)
        if not recaptcha.detect_key(self.html):
            self.parseError("could not find recaptcha pattern")
        self.logDebug("using captcha key " + recaptcha.recaptcha_key)
        # try the captcha 5 times
        for i in xrange(5):
            m = re.search(self.WAIT_PATTERN, self.html)
            if not m:
                self.parseError("could not find wait pattern")
            wait_time = m.group(1)

            # then, do the waiting
            self.wait(wait_time)

            # then, handle the captcha
            challenge, code = recaptcha.challenge()
            post_data['recaptcha_challenge_field'] = challenge
            post_data['recaptcha_response_field'] = code

            self.html = self.load(self.pyfile.url, post=post_data, decode=True)

            # STAGE 3: get direct link
            m = re.search(self.DIRECT_LINK_PATTERN, self.html, re.DOTALL)
            if m:
                break

        if not m:
            self.parseError("could not detect direct link")

        direct = m.group(1)
        self.logDebug('found direct link: ' + direct)
        self.download(direct, disposition=True)
Esempio n. 45
0
    def handleFree(self):
        # STAGE 1: get link to continue
        m = re.search(self.CHASH_PATTERN, self.html)
        if not m:
            self.parseError("could not detect hash")
        chash = m.group(1)
        self.logDebug("read hash " + chash)
        # continue to stage2
        post_data = {"hash": chash, "free": "Slow download"}
        self.html = self.load(self.pyfile.url, post=post_data, decode=True)

        # STAGE 2: solv captcha and wait
        # first get the infos we need: recaptcha key and wait time
        recaptcha = ReCaptcha(self)
        if not recaptcha.detect_key(self.html):
            self.parseError("could not find recaptcha pattern")
        self.logDebug("using captcha key " + recaptcha.recaptcha_key)
        # try the captcha 5 times
        for i in xrange(5):
            m = re.search(self.WAIT_PATTERN, self.html)
            if not m:
                self.parseError("could not find wait pattern")
            wait_time = m.group(1)

            # then, do the waiting
            self.wait(wait_time)

            # then, handle the captcha
            challenge, code = recaptcha.challenge()
            post_data["recaptcha_challenge_field"] = challenge
            post_data["recaptcha_response_field"] = code

            self.html = self.load(self.pyfile.url, post=post_data, decode=True)

            # STAGE 3: get direct link
            m = re.search(self.DIRECT_LINK_PATTERN, self.html, re.DOTALL)
            if m:
                break

        if not m:
            self.parseError("could not detect direct link")

        direct = m.group(1)
        self.logDebug("found direct link: " + direct)
        self.download(direct, disposition=True)
Esempio n. 46
0
    def handleFree(self, pyfile):
        if r">Only premium users can download this file" in self.html:
            self.fail(_("Only premium users can download this file"))

        m = re.search(r"Next free download from your ip will be available in <b>(\d+)\s*minutes", self.html)
        if m:
            self.wait(int(m.group(1)) * 60, True)
        elif "The daily downloads limit from your IP is exceeded" in self.html:
            self.logWarning(_("You have reached your daily downloads limit for today"))
            self.wait(secondsToMidnight(gmt=2), True)

        self.logDebug("URL: " + self.req.http.lastEffectiveURL)
        m = re.match(self.__pattern__, self.req.http.lastEffectiveURL)
        fileID = m.group('ID') if m else self.info['pattern']['ID']

        m = re.search(r'recaptcha/api/challenge\?k=(\w+)', self.html)
        if m:
            recaptcha = ReCaptcha(self)
            captcha_key = m.group(1)

            for _i in xrange(5):
                get_data = {"type": "recaptcha"}
                get_data['capture'], get_data['challenge'] = recaptcha.challenge(captcha_key)
                res = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data))
                if "ok" in res:
                    self.correctCaptcha()
                    break
                else:
                    self.invalidCaptcha()
            else:
                self.fail(_("Invalid captcha"))
        else:
            self.error(_("Captcha"))

        if not "href" in res:
            self.error(_("Bad JSON response"))

        self.html = self.load("http://extabit.com/file/%s%s" % (fileID, res['href']))

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m is None:
            self.error(_("LINK_FREE_PATTERN not found"))

        url = m.group(1)
        self.download(url)
Esempio n. 47
0
    def handleFree(self):
        fid = re.search(r'<input type="hidden" name="slow_id" value="([^"]+)">', self.html).group(1)
        self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': fid})

        m = re.search(self.WAIT_PATTERN, self.html)
        if m:
            wait_string = m.group(1)
            wait_time = int(wait_string[0:2]) * 3600 + int(wait_string[3:5]) * 60 + int(wait_string[6:8])
            self.setWait(wait_time, True)
            self.wait()
            self.process(self.pyfile)

        recaptcha = ReCaptcha(self)
        for i in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {'recaptcha_challenge_field': challenge,
                         'recaptcha_response_field': response,
                         'CaptchaForm%5Bcode%5D': '',
                         'free': 1,
                         'freeDownloadRequest': 1,
                         'uniqueId': fid,
                         'yt0': ''}

            self.html = self.load(self.pyfile.url, post=post_data)

            if 'recaptcha' not in self.html:
                self.correctCaptcha()
                self.setWait(30)
                self.wait()
                break
            else:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
        else:
            self.fail("All captcha attempts failed")

        self.html = self.load(self.pyfile.url, post={'uniqueId': fid, 'free': 1})

        dl = 'http://keep2share.cc'
        m = re.search(self.DIRECT_LINK_PATTERN, self.html)
        if not m:
            self.parseError("Unable to detect direct link")
        dl += m.group(1)
        self.logDebug('Direct Link: ' + dl)
        self.download(dl, disposition=True)
Esempio n. 48
0
    def handleFree(self):
        if r">Only premium users can download this file" in self.html:
            self.fail("Only premium users can download this file")

        m = re.search(r"Next free download from your ip will be available in <b>(\d+)\s*minutes", self.html)
        if m:
            self.setWait(int(m.group(1)) * 60, True)
            self.wait()
        elif "The daily downloads limit from your IP is exceeded" in self.html:
            self.setWait(3600, True)
            self.wait()

        self.logDebug("URL: " + self.req.http.lastEffectiveURL)
        m = re.match(self.__pattern__, self.req.http.lastEffectiveURL)
        fileID = m.group('ID') if m else self.file_info('ID')

        m = re.search(r'recaptcha/api/challenge\?k=(\w+)', self.html)
        if m:
            recaptcha = ReCaptcha(self)
            captcha_key = m.group(1)

            for i in range(5):
                get_data = {"type": "recaptcha"}
                get_data["challenge"], get_data["capture"] = recaptcha.challenge(captcha_key)
                response = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data))
                if "ok" in response:
                    self.correctCaptcha()
                    break
                else:
                    self.invalidCaptcha()
            else:
                self.fail("Invalid captcha")
        else:
            self.parseError('Captcha')

        if not "href" in response:
            self.parseError('JSON')

        self.html = self.load("http://extabit.com/file/%s%s" % (fileID, response['href']))
        m = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
        if not m:
            self.parseError('Download URL')
        url = m.group(1)
        self.logDebug("Download URL: " + url)
        self.download(url)
Esempio n. 49
0
    def doCaptcha(self):
        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group("key")
        recaptcha = ReCaptcha(self)

        for _ in xrange(5):
            challenge, code = recaptcha.challenge(captcha_key)

            response = json_loads(self.load(self.URLS[2],
                                            post={'recaptcha_challenge_field': challenge,
                                                  'recaptcha_response_field': code,
                                                  'recaptcha_shortencode_field': self.file_id}))
            self.logDebug("reCaptcha response : %s" % response)
            if not response["success"]:
                self.invalidCaptcha()
            else:
                self.correctCaptcha()
                break
        else:
            self.fail("Invalid captcha")
Esempio n. 50
0
    def handleFree(self):
        if "You need Premium membership to download this file." in self.html:
            self.fail("You need Premium membership to download this file.")

        for _ in xrange(5):
            found = re.search(self.CAPTCHA_URL_PATTERN, self.html)
            if found:
                url, wait_time = 'http://crocko.com' + found.group(1), found.group(2)
                self.setWait(wait_time)
                self.wait()
                self.html = self.load(url)
            else:
                break

        found = re.search(self.CAPTCHA_KEY_PATTERN, self.html)
        if not found:
            self.parseError('Captcha KEY')
        captcha_key = found.group(1)

        found = re.search(self.FORM_PATTERN, self.html, re.DOTALL)
        if not found:
            self.parseError('ACTION')
        action, form = found.groups()
        inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form))

        recaptcha = ReCaptcha(self)

        for _ in xrange(5):
            inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key)
            self.download(action, post=inputs)

            check = self.checkDownload({
                "captcha_err": self.CAPTCHA_KEY_PATTERN
            })

            if check == "captcha_err":
                self.invalidCaptcha()
            else:
                break
        else:
            self.fail('No valid captcha solution received')
Esempio n. 51
0
    def handleCaptcha(self):
        recaptcha = ReCaptcha(self)
        for _ in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {'recaptcha_challenge_field': challenge,
                         'recaptcha_response_field': response,
                         'CaptchaForm%5Bcode%5D': '',
                         'free': 1,
                         'freeDownloadRequest': 1,
                         'uniqueId': self.fid,
                         'yt0': ''}

            self.html = self.load(self.pyfile.url, post=post_data)

            if 'recaptcha' not in self.html:
                self.correctCaptcha()
                break
            else:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()
        else:
            self.fail("All captcha attempts failed")
Esempio n. 52
0
    def handleFree(self):
        url = 'http://datei.to/ajax/download.php'
        data = {'P': 'I', 'ID': self.file_info['ID']}

        recaptcha = ReCaptcha(self)

        for _ in xrange(10):
            self.logDebug("URL", url, "POST", data)
            self.html = self.load(url, post=data)
            self.checkErrors()

            if url.endswith('download.php') and 'P' in data:
                if data['P'] == 'I':
                    self.doWait()

                elif data['P'] == 'IV':
                    break

            found = re.search(self.DATA_PATTERN, self.html)
            if not found:
                self.parseError('data')
            url = 'http://datei.to/' + found.group(1)
            data = dict(x.split('=') for x in found.group(2).split('&'))

            if url.endswith('recaptcha.php'):
                found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html)
                recaptcha_key = found.group(
                    1) if found else "6LdBbL8SAAAAAI0vKUo58XRwDd5Tu_Ze1DA7qTao"

                data['recaptcha_challenge_field'], data[
                    'recaptcha_response_field'] = recaptcha.challenge(
                        recaptcha_key)

        else:
            self.fail('Too bad...')

        download_url = self.html
        self.logDebug('Download URL', download_url)
        self.download(download_url)
Esempio n. 53
0
    def solveCaptcha(self):
        for i in range(5):
            found = re.search(self.LIMIT_WAIT_PATTERN, self.html)
            if found:
                wait_time = int(found.group(1))
                self.setWait(wait_time, wait_time > 60)
                self.wait()
                self.retry()

            action, inputs = self.parseHtmlForm("action='#'")
            if not inputs:
                self.parseError("captcha form")
            self.logDebug(inputs)

            if inputs['captcha_type'] == 'recaptcha':
                recaptcha = ReCaptcha(self)
                found = re.search(self.CAPTCHA_KEY_PATTERN, self.html)
                captcha_key = found.group(
                    1) if found else '6LcTGLoSAAAAAHCWY9TTIrQfjUlxu6kZlTYP50_c'
                inputs['recaptcha_challenge_field'], inputs[
                    'recaptcha_response_field'] = recaptcha.challenge(
                        captcha_key)
            else:
                found = re.search(self.CAPTCHA_SRC_PATTERN, self.html)
                if not found:
                    self.parseError('captcha')
                captcha_url = found.group(1)
                inputs['captcha_response'] = self.decryptCaptcha(captcha_url)

            self.logDebug(inputs)
            self.html = self.load(self.url, post=inputs)

            if not "<div class='download-timer-header'>" in self.html:
                self.invalidCaptcha()
            else:
                self.correctCaptcha()
                break
        else:
            self.fail("Invalid captcha")
Esempio n. 54
0
    def getCaptcha(self):
        found = re.search(self.ADSCAPTCHA_SRC_PATTERN, self.html)
        if found:
            captcha_key = found.group(1)
            captcha = AdsCaptcha(self)
        else:
            found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html)
            if found:
                captcha_key = found.group(1)
                captcha = ReCaptcha(self)
            else:
                found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
                if found:
                    captcha_key = found.group(1)
                    captcha = SolveMedia(self)
                else:
                    self.parseError("Captcha")

        return captcha, captcha_key
Esempio n. 55
0
    def handleFree(self):
        data = {"ukey": self.file_info['ID']}

        found = re.search(self.AB1_PATTERN, self.html)
        if not found:
            raise PluginParseError("__AB1")
        data["__ab1"] = found.group(1)

        if not self.account:
            self.fail("User not logged in")
        elif not self.account.logged_in:
            recaptcha = ReCaptcha(self)
            captcha_challenge, captcha_response = recaptcha.challenge(self.RECAPTCHA_KEY)
            self.account.form_data = {"recaptcha_challenge_field": captcha_challenge,
                                      "recaptcha_response_field": captcha_response}
            self.account.relogin(self.user)
            self.retry(max_tries=2)

        json_url = "http://filecloud.io/download-request.json"
        response = self.load(json_url, post=data)
        self.logDebug(response)
        response = json_loads(response)

        if "error" in response and response["error"]:
            self.fail(response)

        self.logDebug(response)
        if response["captcha"]:
            recaptcha = ReCaptcha(self)
            found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html)
            captcha_key = found.group(1) if found else self.RECAPTCHA_KEY
            data["ctype"] = "recaptcha"

            for i in range(5):
                data["recaptcha_challenge"], data["recaptcha_response"] = recaptcha.challenge(captcha_key)

                json_url = "http://filecloud.io/download-request.json"
                response = self.load(json_url, post=data)
                self.logDebug(response)
                response = json_loads(response)

                if "retry" in response and response["retry"]:
                    self.invalidCaptcha()
                else:
                    self.correctCaptcha()
                    break
            else:
                self.fail("Incorrect captcha")

        if response["dl"]:
            self.html = self.load('http://filecloud.io/download.html')
            found = re.search(self.DOWNLOAD_LINK_PATTERN % self.file_info['ID'], self.html)
            if not found:
                raise PluginParseError("Download URL")
            download_url = found.group(1)
            self.logDebug("Download URL: %s" % download_url)

            if "size" in self.file_info and self.file_info['size']:
                self.check_data = {"size": int(self.file_info['size'])}
            self.download(download_url)
        else:
            self.fail("Unexpected server response")
Esempio n. 56
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url,
                              post={"gateway_result": "1"},
                              cookies=True)
        if re.search(self.FILE_OFFLINE_PATTERN, self.html):
            self.offline()

        if re.search(r'File is checked, please try again in a minute.',
                     self.html) is not None:
            self.logInfo(
                "DepositFiles.com: The file is being checked. Waiting 1 minute."
            )
            self.wait(61)
            self.retry()

        wait = re.search(r'html_download_api-limit_interval\">(\d+)</span>',
                         self.html)
        if wait:
            wait_time = int(wait.group(1))
            self.logInfo("%s: Traffic used up. Waiting %d seconds." %
                         (self.__name__, wait_time))
            self.wait(wait_time, True)
            self.retry()

        wait = re.search(r'>Try in (\d+) minutes or use GOLD account',
                         self.html)
        if wait:
            wait_time = int(wait.group(1))
            self.logInfo("%s: All free slots occupied. Waiting %d minutes." %
                         (self.__name__, wait_time))
            self.setWait(wait_time * 60, False)

        wait = re.search(r'Please wait (\d+) sec', self.html)
        if wait:
            self.setWait(int(wait.group(1)))

        found = re.search(r"var fid = '(\w+)';", self.html)
        if not found:
            self.retry(wait_time=5)
        params = {'fid': found.group(1)}
        self.logDebug("FID: %s" % params['fid'])

        captcha_key = '6LdRTL8SAAAAAE9UOdWZ4d0Ky-aeA7XfSqyWDM2m'
        found = re.search(self.RECAPTCHA_PATTERN, self.html)
        if found:
            captcha_key = found.group(1)
        self.logDebug("CAPTCHA_KEY: %s" % captcha_key)

        self.wait()
        recaptcha = ReCaptcha(self)

        for _ in xrange(5):
            self.html = self.load("http://depositfiles.com/get_file.php",
                                  get=params)

            if '<input type=button value="Continue" onclick="check_recaptcha' in self.html:
                if not captcha_key:
                    self.parseError('Captcha key')
                if 'response' in params:
                    self.invalidCaptcha()
                params['challenge'], params['response'] = recaptcha.challenge(
                    captcha_key)
                self.logDebug(params)
                continue

            found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
            if found:
                if 'response' in params:
                    self.correctCaptcha()
                link = unquote(found.group(1))
                self.logDebug("LINK: %s" % link)
                break
            else:
                self.parseError('Download link')
        else:
            self.fail('No valid captcha response received')

        try:
            self.download(link, disposition=True)
        except:
            self.retry(wait_time=60)
Esempio n. 57
0
    def handleFree(self):
        self.html = self.load(self.pyfile.url, decode=True)
        self.getFileInfo()

        if "You can download files up to 500 MB in free mode" in self.html \
        or "This file can be downloaded by premium only" in self.html:
            self.fail("Premium account needed for download")

        self.checkWait()

        jsvars = dict(re.findall(self.JSVARS_PATTERN, self.html))
        self.logDebug(jsvars)

        self.req.http.lastURL = self.pyfile.url
        self.req.http.c.setopt(HTTPHEADER,
                               ["X-Requested-With: XMLHttpRequest"])

        url = "http://rapidgator.net%s?fid=%s" % (jsvars.get(
            'startTimerUrl', '/download/AjaxStartTimer'), jsvars["fid"])
        jsvars.update(self.getJsonResponse(url))

        self.setWait(int(jsvars.get('secs', 30)) + 1, False)
        self.wait()

        url = "http://rapidgator.net%s?sid=%s" % (jsvars.get(
            'getDownloadUrl', '/download/AjaxGetDownload'), jsvars["sid"])
        jsvars.update(self.getJsonResponse(url))

        self.req.http.lastURL = self.pyfile.url
        self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With:"])

        url = "http://rapidgator.net%s" % jsvars.get('captchaUrl',
                                                     '/download/captcha')
        self.html = self.load(url)
        found = re.search(self.ADSCAPTCHA_SRC_PATTERN, self.html)
        if found:
            captcha_key = found.group(1)
            captcha = AdsCaptcha(self)
        else:
            found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html)
            if found:
                captcha_key = found.group(1)
                captcha = ReCaptcha(self)

            else:
                found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
                if found:
                    captcha_key = found.group(1)
                    captcha = SolveMedia(self)
                else:
                    self.parseError("Captcha")

        for i in range(5):
            self.checkWait()
            captcha_challenge, captcha_response = captcha.challenge(
                captcha_key)

            self.html = self.load(url,
                                  post={
                                      "DownloadCaptchaForm[captcha]": "",
                                      "adcopy_challenge": captcha_challenge,
                                      "adcopy_response": captcha_response
                                  })

            if 'The verification code is incorrect' in self.html:
                self.invalidCaptcha()
            else:
                self.correctCaptcha()
                break
        else:
            self.fail("No valid captcha solution received")

        found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
        if not found:
            self.parseError("download link")
        download_url = found.group(1)
        self.logDebug(download_url)
        self.download(download_url)
Esempio n. 58
0
    def handleFree(self):
        self.req.setOption("timeout", 120)
        self.html = self.load(self.pyfile.url,
                              decode=not self.SH_BROKEN_ENCODING,
                              cookies=self.SH_COOKIES)

        # Wait between downloads
        m = re.search(r'musst du <span id="time">(\d+)</span> Sekunden warten',
                      self.html)
        if m:
            waittime = int(m.group(1))
            self.retry(3, waittime, 'Wait between free downloads')

        self.getFileInfo()

        self.html = self.load(self.pyfile.url, decode=True)

        inputs = self.parseHtmlForm(input_names='token')[1]
        if 'token' not in inputs:
            self.parseError('Unable to detect token')
        token = inputs['token']
        self.logDebug('Token: ' + token)

        self.html = self.load(self.pyfile.url,
                              post={'token': token},
                              decode=True)

        inputs = self.parseHtmlForm(input_names='hash')[1]
        if 'hash' not in inputs:
            self.parseError('Unable to detect hash')
        hash_data = inputs['hash']
        self.logDebug('Hash: ' + hash_data)

        downloadURL = ''
        recaptcha = ReCaptcha(self)
        for i in xrange(5):
            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY)
            post_data = {
                'recaptcha_challenge_field': challenge,
                'recaptcha_response_field': response,
                'hash': hash_data
            }

            # Workaround for 0.4.9 just_header issue. In 0.5 clean the code using just_header
            self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0)
            self.load(self.pyfile.url, post=post_data)
            self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1)

            if 'location' in self.req.http.header:
                location = re.search(r'location: (\S+)',
                                     self.req.http.header).group(1)
                downloadURL = 'http://filer.net' + location
                self.correctCaptcha()
                break
            else:
                self.logInfo('Wrong captcha')
                self.invalidCaptcha()

        if not downloadURL:
            self.fail("No Download url retrieved/all captcha attempts failed")

        self.download(downloadURL, disposition=True)