Esempio n. 1
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. 2
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

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

        challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=(\w+)",
                              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. 3
0
    def handleCaptcha(self):
        post_data = {
            'free': 1,
            'freeDownloadRequest': 1,
            'uniqueId': self.fid,
            'yt0': ''
        }

        m = re.search(r'id="(captcha\-form)"', self.html)
        self.logDebug("captcha-form found %s" % m)

        m = re.search(self.CAPTCHA_PATTERN, self.html)
        self.logDebug("CAPTCHA_PATTERN found %s" % m)
        if m:
            captcha_url = urlparse.urljoin("http://keep2s.cc/", m.group(1))
            post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url)
        else:
            recaptcha = ReCaptcha(self)
            response, challenge = recaptcha.challenge()
            post_data.update({
                'recaptcha_challenge_field': challenge,
                'recaptcha_response_field': response
            })

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

        if 'verification code is incorrect' not in self.html:
            self.correctCaptcha()
        else:
            self.invalidCaptcha()
Esempio n. 4
0
    def handleFree(self, pyfile):
        # Click the "free user" button and wait
        a = self.load(pyfile.url, post={'downloadLink': "wait"}, decode=True)
        self.logDebug(a)

        self.wait(30)

        # Make the recaptcha appear and show it the pyload interface
        b = self.load(pyfile.url, post={'checkDownload': "check"}, decode=True)
        self.logDebug(b)  #: Expected output: {"success":"showCaptcha"}

        recaptcha = ReCaptcha(self)

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

        # Submit the captcha solution
        self.load("http://www.uploadable.ch/checkReCaptcha.php",
                  post={'recaptcha_challenge_field'  : challenge,
                        'recaptcha_response_field'   : response,
                        'recaptcha_shortencode_field': self.info['pattern']['ID']},
                  decode=True)

        self.wait(3)

        # Get ready for downloading
        self.load(pyfile.url, post={'downloadLink': "show"}, decode=True)

        self.wait(3)

        # Download the file
        self.download(pyfile.url, post={'download': "normal"}, disposition=True)
Esempio n. 5
0
    def handleFree(self, pyfile):
        # Click the "free user" button and wait
        a = self.load(pyfile.url, post={'downloadLink': "wait"}, decode=True)
        self.logDebug(a)

        self.wait(30)

        # Make the recaptcha appear and show it the pyload interface
        b = self.load(pyfile.url, post={'checkDownload': "check"}, decode=True)
        self.logDebug(b)  #: Expected output: {"success":"showCaptcha"}

        recaptcha = ReCaptcha(self)

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

        # Submit the captcha solution
        self.load("http://www.uploadable.ch/checkReCaptcha.php",
                  post={
                      'recaptcha_challenge_field': challenge,
                      'recaptcha_response_field': response,
                      'recaptcha_shortencode_field': self.info['pattern']['ID']
                  },
                  decode=True)

        self.wait(3)

        # Get ready for downloading
        self.load(pyfile.url, post={'downloadLink': "show"}, decode=True)

        self.wait(3)

        # Download the file
        self.download(pyfile.url,
                      post={'download': "normal"},
                      disposition=True)
Esempio n. 6
0
    def handleCaptcha(self):
        post_data = {'free'               : 1,
                     'freeDownloadRequest': 1,
                     'uniqueId'           : self.fid,
                     'yt0'                : ''}

        m = re.search(r'id="(captcha\-form)"', self.html)
        self.logDebug("captcha-form found %s" % m)

        m = re.search(self.CAPTCHA_PATTERN, self.html)
        self.logDebug("CAPTCHA_PATTERN found %s" % m)
        if m:
            captcha_url = urlparse.urljoin("http://keep2s.cc/", m.group(1))
            post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url)
        else:
            recaptcha = ReCaptcha(self)
            response, challenge = recaptcha.challenge()
            post_data.update({'recaptcha_challenge_field': challenge,
                              'recaptcha_response_field' : response})

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

        if 'verification code is incorrect' not in self.html:
            self.correctCaptcha()
        else:
            self.invalidCaptcha()
Esempio n. 7
0
    def handleFree(self, pyfile):
        self.load("http://uploaded.net/language/en", just_header=True)

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

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

        self.html = self.load("http://uploaded.net/io/ticket/captcha/%s" %
                              self.info['pattern']['ID'],
                              post={
                                  'recaptcha_challenge_field': challenge,
                                  'recaptcha_response_field': response
                              })

        if "type:'download'" in self.html:
            self.correctCaptcha()
            try:
                self.link = re.search("url:'(.+?)'", self.html).group(1)

            except Exception:
                pass

        self.checkErrors()
Esempio n. 8
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(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.link = json['link']
Esempio n. 9
0
    def handleFree(self, pyfile):
        self.req.http.lastURL = pyfile.url
        self.req.http.c.setopt(pycurl.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. 10
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()

        self.load(pyfile.url,
                  post={
                      'recaptcha_challenge_field': challenge,
                      'recaptcha_response_field': response,
                      'hash': inputs['hash']
                  },
                  follow_location=False)

        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. 11
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. 12
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(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.link = json['link']
Esempio n. 13
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. 14
0
    def handle_free(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 = urllib.unquote(m.group(1))
Esempio n. 15
0
    def handle_free(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. 16
0
    def getDownloadUrl(self):
        # Return location if direct download is active
        if self.premium:
            header = self.load(self.pyfile.url, just_header=True)
            if 'location' in header:
                return header['location']

        # Get download info
        self.logDebug("Getting download info")
        res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
                        post={"request": "generateID", "ajaxid": self.ajaxid})

        self.handleErrors(res, ':')

        parts    = res.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.wait(wait, False)
            else:
                self.wait(wait - 55, True)
                self.retry()

        # Resolve captcha
        if captcha == 1:
            self.logDebug("File is captcha protected")
            recaptcha = ReCaptcha(self)

            # Try up to 3 times
            for _i in xrange(3):
                response, challenge = recaptcha.challenge()
                res = 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" : response})
                if self.handleCaptchaErrors(res):
                    break

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

        self.handleErrors(res, '#')

        url = res.split("#")[-1]

        return url
Esempio n. 17
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. 18
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. 19
0
    def handleCaptcha(self, inputs):
        m = re.search(self.CAPTCHA_PATTERN, self.html)
        if m:
            captcha_url = m.group(1)
            inputs['code'] = self.decryptCaptcha(captcha_url)
            return 1

        m = re.search(self.CAPTCHA_BLOCK_PATTERN, self.html, re.S)
        if m:
            captcha_div = m.group(1)
            numerals = re.findall(
                r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>',
                html_unescape(captcha_div))

            self.logDebug(captcha_div)

            inputs['code'] = "".join(
                a[1] for a in sorted(numerals, key=lambda num: int(num[0])))

            self.logDebug("Captcha code: %s" % inputs['code'], numerals)
            return 2

        recaptcha = ReCaptcha(self)
        try:
            captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1)

        except Exception:
            captcha_key = recaptcha.detect_key()

        else:
            self.logDebug("ReCaptcha key: %s" % captcha_key)

        if captcha_key:
            inputs['recaptcha_response_field'], inputs[
                'recaptcha_challenge_field'] = recaptcha.challenge(captcha_key)
            return 3

        solvemedia = SolveMedia(self)
        try:
            captcha_key = re.search(self.SOLVEMEDIA_PATTERN,
                                    self.html).group(1)

        except Exception:
            captcha_key = solvemedia.detect_key()

        else:
            self.logDebug("SolveMedia key: %s" % captcha_key)

        if captcha_key:
            inputs['adcopy_response'], inputs[
                'adcopy_challenge'] = solvemedia.challenge(captcha_key)
            return 4

        return 0
Esempio n. 20
0
    def handleFree(self, pyfile):
        recaptcha = ReCaptcha(self)

        response, challenge = recaptcha.challenge()
        self.html = self.load(pyfile.url,
                              post={'recaptcha_challenge_field': challenge,
                                    'recaptcha_response_field' : response})

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            self.link = m.group(1)
Esempio n. 21
0
    def handleFree(self, pyfile):
        m = re.search(self.FLP_TOKEN_PATTERN, self.html)
        if m is None:
            self.error(_("Token"))
        flp_token = m.group(1)

        m = re.search(self.RECAPTCHA_PATTERN, self.html)
        if m is None:
            self.error(_("Captcha key"))
        captcha_key = m.group(1)

        # Get wait time
        get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time.time() * 10000)) + '-xml'}
        post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']}
        wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time'))

        if wait_time > 0:
            self.wait(wait_time)

        post_dict = {"token": flp_token, "code": self.info['pattern']['ID'], "file_pass": ''}

        if 'var is_pass_exists = true;' in self.html:
            # Solve password
            password = self.getPassword()

            if password:
                self.logInfo(_("Password protected link, trying ") + file_pass)

                get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml'
                post_dict['file_pass'] = file_pass

                self.link = self.getJsonResponse(get_dict, post_dict, 'link')

                if not self.link:
                    self.fail(_("Incorrect password"))
            else:
                self.fail(_("No password found"))

        else:
            # Solve recaptcha
            recaptcha = ReCaptcha(self)

            for i in xrange(5):
                get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml'
                if i:
                    post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_field'] = recaptcha.challenge(
                        captcha_key)
                    self.logDebug(u"RECAPTCHA: %s : %s : %s" % (
                        captcha_key, post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field']))

                self.link = self.getJsonResponse(get_dict, post_dict, 'link')

            else:
                self.fail(_("Invalid captcha"))
Esempio n. 22
0
    def handleFree(self, pyfile):
        recaptcha = ReCaptcha(self)

        response, challenge = recaptcha.challenge()
        self.html = self.load(pyfile.url,
                              post={
                                  'recaptcha_challenge_field': challenge,
                                  'recaptcha_response_field': response
                              })

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            self.link = m.group(1)
Esempio n. 23
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"))

        self.link = m.group(1)
Esempio n. 24
0
    def handleCaptcha(self):
        m = re.search(self.CAPTCHA_PATTERN, self.html)
        m2 = re.search(self.CIRCLE_CAPTCHA_PATTERN, self.html)

        if m:  #: normal captcha
            self.logDebug("Captcha-URL: %s" % m.group(1))

            captcha_code = self.decryptCaptcha(urljoin("http://filecrypt.cc",
                                                       m.group(1)),
                                               forceUser=True,
                                               imgtype="gif")

            self.siteWithLinks = self.load(
                self.pyfile.url,
                post={'recaptcha_response_field': captcha_code},
                decode=True)
        elif m2:  #: circle captcha
            self.logDebug("Captcha-URL: %s" % m2.group(1))

            captcha_code = self.decryptCaptcha(urljoin("http://filecrypt.cc",
                                                       m2.group(1)),
                                               forceUser=True,
                                               imgtype="gif",
                                               result_type='positional')

            self.siteWithLinks = self.load(self.pyfile.url,
                                           post={
                                               'button.x': captcha_code[0],
                                               'button.y': captcha_code[1]
                                           },
                                           decode=True)

        else:
            recaptcha = ReCaptcha(self)
            captcha_key = recaptcha.detect_key()

            if captcha_key:
                response, challenge = recaptcha.challenge(captcha_key)
                self.siteWithLinks = self.load(
                    self.pyfile.url,
                    post={'g-recaptcha-response': response},
                    decode=True)
            else:
                self.logInfo(_("No captcha found"))
                self.siteWithLinks = self.html

        if "recaptcha_image" in self.siteWithLinks or "data-sitekey" in self.siteWithLinks:
            self.invalidCaptcha()
            self.retry()
Esempio n. 25
0
    def handleCaptcha(self, inputs):
        m = re.search(self.CAPTCHA_PATTERN, self.html)
        if m:
            captcha_url = m.group(1)
            inputs['code'] = self.decryptCaptcha(captcha_url)
            return 1

        m = re.search(self.CAPTCHA_BLOCK_PATTERN, self.html, re.S)
        if m:
            captcha_div = m.group(1)
            numerals    = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div))

            self.logDebug(captcha_div)

            inputs['code'] = "".join(a[1] for a in sorted(numerals, key=lambda num: int(num[0])))

            self.logDebug("Captcha code: %s" % inputs['code'], numerals)
            return 2

        recaptcha = ReCaptcha(self)
        try:
            captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1)

        except Exception:
            captcha_key = recaptcha.detect_key()

        else:
            self.logDebug("ReCaptcha key: %s" % captcha_key)

        if captcha_key:
            inputs['recaptcha_response_field'], inputs['recaptcha_challenge_field'] = recaptcha.challenge(captcha_key)
            return 3

        solvemedia = SolveMedia(self)
        try:
            captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1)

        except Exception:
            captcha_key = solvemedia.detect_key()

        else:
            self.logDebug("SolveMedia key: %s" % captcha_key)

        if captcha_key:
            inputs['adcopy_response'], inputs['adcopy_challenge'] = solvemedia.challenge(captcha_key)
            return 4

        return 0
Esempio n. 26
0
    def handleFree(self, pyfile):
        # used here to load the cookies which will be required later
        self.load(pyfile.url, post={'goToFreePage': ""})

        self.load("http://nitroflare.com/ajax/setCookie.php",
                  post={'fileId': self.info['pattern']['ID']})
        self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",
                              post={
                                  'method': "startTimer",
                                  'fileId': self.info['pattern']['ID']
                              })

        self.checkErrors()

        try:
            js_file = self.load(
                "http://nitroflare.com/js/downloadFree.js?v=1.0.1")
            var_time = re.search("var time = (\\d+);", js_file)
            wait_time = int(var_time.groups()[0])

        except Exception:
            wait_time = 60

        self.wait(wait_time)

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

        self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",
                              post={
                                  'method': "fetchDownload",
                                  'recaptcha_challenge_field': challenge,
                                  'recaptcha_response_field': response
                              })

        if "The captcha wasn't entered correctly" in self.html:
            self.logWarning("The captcha wasn't entered correctly")
            return

        if "You have to fill the captcha" in self.html:
            self.logWarning("Captcha unfilled")
            return

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            self.link = m.group(1)
        else:
            self.logError("Unable to detect direct link")
Esempio n. 27
0
    def handle_free(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. 28
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. 29
0
    def unlockProtection(self):
        postData = {}

        form = re.search(r'<form name="protected"(.*?)</form>',
                         self.cleanedHtml, re.S).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.logDebug("Captcha protected")
            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.logDebug("ReCaptcha protected")
            captcha_key = re.search(r'\?k=(.*?)"', form).group(1)
            self.logDebug("Resolving ReCaptcha with key [%s]" % captcha_key)
            recaptcha = ReCaptcha(self)
            response, challenge = recaptcha.challenge(captcha_key)
            postData['recaptcha_challenge_field'] = challenge
            postData['recaptcha_response_field'] = response

        # Resolve circlecaptcha
        if "circlecaptcha" in form:
            self.logDebug("CircleCaptcha 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))
            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, decode=True)
Esempio n. 30
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. 31
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. 32
0
    def handle_free(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"))

        self.link = m.group(1)
Esempio n. 33
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

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

        challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=(\w+)", 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. 34
0
    def handle_free(self, pyfile):
        # STAGE 1: get link to continue
        m = re.search(self.CHASH_PATTERN, self.html)
        if m is None:
            self.error(_("CHASH_PATTERN not found"))
        chash = m.group(1)
        self.logDebug("Read hash " + chash)
        # continue to stage2
        post_data = {'hash': chash, 'free': 'Slow download'}
        self.html = self.load(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)

        # try the captcha 5 times
        for _i in xrange(5):
            m = re.search(self.WAIT_PATTERN, self.html)
            if m is None:
                self.error(_("Wait pattern not found"))
            wait_time = int(m.group(1))

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

            # then, handle the captcha
            response, challenge = recaptcha.challenge()
            post_data.update({
                'recaptcha_challenge_field': challenge,
                'recaptcha_response_field': response
            })

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

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

        if m is None:
            self.error(_("Download link not found"))

        self.link = m.group(1)
Esempio n. 35
0
    def handleFree(self, pyfile):
        # STAGE 1: get link to continue
        m = re.search(self.CHASH_PATTERN, self.html)
        if m is None:
            self.error(_("CHASH_PATTERN not found"))
        chash = m.group(1)
        self.logDebug("Read hash " + chash)
        # continue to stage2
        post_data = {'hash': chash, 'free': 'Slow download'}
        self.html = self.load(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)

        # try the captcha 5 times
        for i in xrange(5):
            m = re.search(self.WAIT_PATTERN, self.html)
            if m is None:
                self.error(_("Wait pattern not found"))
            wait_time = int(m.group(1))

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

            # then, handle the captcha
            response, challenge = recaptcha.challenge()
            post_data.update({'recaptcha_challenge_field': challenge,
                              'recaptcha_response_field' : response})

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

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

        if m is None:
            self.error(_("Download link not found"))

        self.link = m.group(1)
Esempio n. 36
0
    def unlockProtection(self):
        postData = {}

        form = re.search(r'<form name="protected"(.*?)</form>', self.cleanedHtml, re.S).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.logDebug("Captcha protected")
            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.logDebug("ReCaptcha protected")
            captcha_key = re.search(r'\?k=(.*?)"', form).group(1)
            self.logDebug("Resolving ReCaptcha with key [%s]" % captcha_key)
            recaptcha = ReCaptcha(self)
            response, challenge = recaptcha.challenge(captcha_key)
            postData['recaptcha_challenge_field'] = challenge
            postData['recaptcha_response_field']  = response

        # Resolve circlecaptcha
        if "circlecaptcha" in form:
            self.logDebug("CircleCaptcha 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))
            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, decode=True)
Esempio n. 37
0
    def handle_free(self, pyfile):
        # used here to load the cookies which will be required later
        self.load(pyfile.url, post={'goToFreePage': ""})

        self.load("http://nitroflare.com/ajax/setCookie.php", post={'fileId': self.info['pattern']['ID']})
        self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",
                              post={'method': "startTimer", 'fileId': self.info['pattern']['ID']})

        self.checkErrors()

        try:
            js_file   = self.load("http://nitroflare.com/js/downloadFree.js?v=1.0.1")
            var_time  = re.search("var time = (\\d+);", js_file)
            wait_time = int(var_time.groups()[0])

        except Exception:
            wait_time = 60

        self.wait(wait_time)

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

        self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",
                              post={'method'                   : "fetchDownload",
                                    'recaptcha_challenge_field': challenge,
                                    'recaptcha_response_field' : response})

        if "The captcha wasn't entered correctly" in self.html:
            self.logWarning("The captcha wasn't entered correctly")
            return

        if "You have to fill the captcha" in self.html:
            self.logWarning("Captcha unfilled")
            return

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            self.link = m.group(1)
        else:
            self.logError("Unable to detect direct link")
Esempio n. 38
0
    def handleCaptcha(self):
        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY)

            m = re.search(r'var wait=(\d+);', self.html)
            self.setWait(int(m.group(1)) if m else 30)

            res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time.time() * 1000)),
                            post={'dl_free'                  : "1",
                                  'recaptcha_challenge_field': challenge,
                                  'recaptcha_response_field' : response})
            if not res == '0':
                self.correctCaptcha()
                return res
            else:
                self.invalidCaptcha()
        else:
            self.invalidCaptcha()
            self.fail(_("No valid captcha solution received"))
Esempio n. 39
0
    def handleCaptcha(self):
        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY)

            m = re.search(r'var wait=(\d+);', self.html)
            self.setWait(int(m.group(1)) if m else 30)

            res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time.time() * 1000)),
                            post={'dl_free'                  : "1",
                                  'recaptcha_challenge_field': challenge,
                                  'recaptcha_response_field' : response})
            if not res == '0':
                self.correctCaptcha()
                return res
            else:
                self.invalidCaptcha()
        else:
            self.invalidCaptcha()
            self.fail(_("No valid captcha solution received"))
Esempio n. 40
0
    def handleFree(self, pyfile):
        self.load("http://uploaded.net/language/en", just_header=True)

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

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

        self.html = self.load("http://uploaded.net/io/ticket/captcha/%s" % self.info['pattern']['ID'],
                              post={'recaptcha_challenge_field': challenge,
                                    'recaptcha_response_field' : response})

        if "type:'download'" in self.html:
            self.correctCaptcha()
            try:
                self.link = re.search("url:'(.+?)'", self.html).group(1)

            except Exception:
                pass

        self.checkErrors()
Esempio n. 41
0
    def handleCaptcha(self):
        m  = re.search(self.CAPTCHA_PATTERN, self.html)
        m2 = re.search(self.CIRCLE_CAPTCHA_PATTERN, self.html)

        if m:  #: normal captcha
            self.logDebug("Captcha-URL: %s" % m.group(1))

            captcha_code = self.decryptCaptcha(urlparse.urljoin(self.base_url, m.group(1)),
                                               forceUser=True,
                                               imgtype="gif")

            self.siteWithLinks = self.load(self.pyfile.url,
                                           post={'recaptcha_response_field': captcha_code},
                                           decode=True)
        elif m2:  #: circle captcha
            self.logDebug("Captcha-URL: %s" % m2.group(1))

            captcha_code = self.decryptCaptcha('%s%s?c=abc' %(self.base_url, m2.group(1)),
                                               result_type='positional')

            self.siteWithLinks = self.load(self.pyfile.url,
                                           post={'button.x': captcha_code[0], 'button.y': captcha_code[1]},
                                           decode=True)

        else:
            recaptcha   = ReCaptcha(self)
            captcha_key = recaptcha.detect_key()

            if captcha_key:
                response, challenge = recaptcha.challenge(captcha_key)
                self.siteWithLinks  = self.load(self.pyfile.url,
                                                post={'g-recaptcha-response': response},
                                                decode=True)
            else:
                self.logInfo(_("No captcha found"))
                self.siteWithLinks = self.html

        if "recaptcha_image" in self.siteWithLinks or "data-sitekey" in self.siteWithLinks:
            self.invalidCaptcha()
            self.retry()
Esempio n. 42
0
    def solveCaptcha(self):
        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = 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], True)
                self.wait()
                self.retry(5)
        else:
            self.invalidCaptcha()
            self.fail(_("Received invalid captcha 5 times"))
Esempio n. 43
0
    def solveCaptcha(self):
        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = 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], True)
                self.wait()
                self.retry(5)
        else:
            self.invalidCaptcha()
            self.fail(_("Received invalid captcha 5 times"))
Esempio n. 44
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()

        self.load(pyfile.url, post={'recaptcha_challenge_field': challenge,
                                    'recaptcha_response_field': response,
                                    'hash': inputs['hash']}, follow_location=False)

        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. 45
0
    def handle_free(self, pyfile):
        self.req.http.lastURL = pyfile.url
        self.req.http.c.setopt(pycurl.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. 46
0
    def handle_free(self, pyfile):
        action, inputs = self.parseHtmlForm('id="ifree_form"')
        if not action:
            self.error(_("ifree_form"))

        pyfile.size = float(inputs['sssize'])
        self.logDebug(action, inputs)
        inputs['desc'] = ""

        self.html = self.load(urlparse.urljoin("http://letitbit.net/", action), post=inputs)

        m = re.search(self.SECONDS_PATTERN, self.html)
        seconds = int(m.group(1)) if m else 60

        self.logDebug("Seconds found", seconds)

        m = re.search(self.CAPTCHA_CONTROL_FIELD, self.html)
        recaptcha_control_field = m.group(1)

        self.logDebug("ReCaptcha control field found", recaptcha_control_field)

        self.wait(seconds)

        res = self.load("http://letitbit.net/ajax/download3.php", post=" ")
        if res != '1':
            self.error(_("Unknown response - ajax_check_url"))

        self.logDebug(res)

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

        post_data = {"recaptcha_challenge_field": challenge,
                     "recaptcha_response_field": response,
                     "recaptcha_control_field": recaptcha_control_field}

        self.logDebug("Post data to send", post_data)

        res = self.load("http://letitbit.net/ajax/check_recaptcha.php", post=post_data)

        self.logDebug(res)

        if not res:
            self.invalidCaptcha()

        if res == "error_free_download_blocked":
            self.logWarning(_("Daily limit reached"))
            self.wait(secondsToMidnight(gmt=2), True)

        if res == "error_wrong_captcha":
            self.invalidCaptcha()
            self.retry()

        elif res.startswith('['):
            urls = json_loads(res)

        elif res.startswith('http://'):
            urls = [res]

        else:
            self.error(_("Unknown response - captcha check"))

        self.link = urls[0]
Esempio n. 47
0
class NetloadIn(Hoster):
    __name    = "NetloadIn"
    __type    = "hoster"
    __version = "0.49"

    __pattern = r'https?://(?:www\.)?netload\.in/(?P<PATH>datei|index\.php\?id=10&file_id=)(?P<ID>\w+)'

    __description = """Netload.in hoster plugin"""
    __license     = "GPLv3"
    __authors     = [("spoob", "*****@*****.**"),
                       ("RaNaN", "*****@*****.**"),
                       ("Gregy", "*****@*****.**")]


    RECAPTCHA_KEY = "6LcLJMQSAAAAAJzquPUPKNovIhbK6LpSqCjYrsR1"


    def setup(self):
        self.multiDL = self.resumeDownload = self.premium


    def process(self, pyfile):
        self.url = pyfile.url

        self.prepare()

        pyfile.setStatus("downloading")

        self.proceed(self.url)


    def prepare(self):
        self.api_load()

        if self.api_data and self.api_data['filename']:
            self.pyfile.name = self.api_data['filename']

        if self.premium:
            self.logDebug("Use Premium Account")

            settings = self.load("http://www.netload.in/index.php", get={'id': 2, 'lang': "en"})

            if '<option value="2" selected="selected">Direkter Download' in settings:
                self.logDebug("Using direct download")
                return True
            else:
                self.logDebug("Direct downloads not enabled. Parsing html for a download URL")

        if self.download_html():
            return True
        else:
            self.fail(_("Failed"))
            return False


    def api_load(self, n=0):
        url      = self.url
        id_regex = re.compile(self.__pattern)
        match    = id_regex.search(url)

        if match:
            #normalize url
            self.url = 'http://www.netload.in/datei%s.htm' % match.group('ID')
            self.logDebug("URL: %s" % self.url)
        else:
            self.api_data = False
            return

        apiurl = "http://api.netload.in/info.php"
        html = self.load(apiurl, cookies=False,
                        get={"file_id": match.group('ID'), "auth": "Zf9SnQh9WiReEsb18akjvQGqT0I830e8", "bz": "1",
                             "md5": "1"}, decode=True).strip()
        if not html and n <= 3:
            self.setWait(2)
            self.wait()
            self.api_load(n + 1)
            return

        self.logDebug("APIDATA: " + html)

        self.api_data = {}

        if html and ";" in html and html not in ("unknown file_data", "unknown_server_data", "No input file specified."):
            lines = html.split(";")
            self.api_data['exists']   = True
            self.api_data['fileid']   = lines[0]
            self.api_data['filename'] = lines[1]
            self.api_data['size']     = lines[2]
            self.api_data['status']   = lines[3]

            if self.api_data['status'] == "online":
                self.api_data['checksum'] = lines[4].strip()
            else:
                self.api_data = False  # check manually since api data is useless sometimes

            if lines[0] == lines[1] and lines[2] == "0":  # useless api data
                self.api_data = False
        else:
            self.api_data = False


    def final_wait(self, page):
        wait_time = self.get_wait_time.time(page)

        self.setWait(wait_time)

        self.logDebug("Final wait %d seconds" % wait_time)

        self.wait()

        self.url = self.get_file_url(page)


    def check_free_wait(self, page):
        if ">An access request has been made from IP address <" in page:
            self.wantReconnect = True
            self.setWait(self.get_wait_time.time(page) or 30)
            self.wait()
            return True
        else:
            return False


    def download_html(self):
        page = self.load(self.url, decode=True)

        if "/share/templates/download_hddcrash.tpl" in page:
            self.logError(_("Netload HDD Crash"))
            self.fail(_("File temporarily not available"))

        if not self.api_data:
            self.logDebug("API Data may be useless, get details from html page")

            if "* The file was deleted" in page:
                self.offline()

            name = re.search(r'class="dl_first_filename">([^<]+)', page, re.M)
            # the found filename is not truncated
            if name:
                name = name.group(1).strip()
                if not name.endswith(".."):
                    self.pyfile.name = name

        captchawaited = False

        for i in xrange(5):
            if not page:
                page = self.load(self.url)
                t = time.time() + 30

            if "/share/templates/download_hddcrash.tpl" in page:
                self.logError(_("Netload HDD Crash"))
                self.fail(_("File temporarily not available"))

            self.logDebug("Try number %d " % i)

            if ">Your download is being prepared.<" in page:
                self.logDebug("We will prepare your download")
                self.final_wait(page)
                return True

            self.logDebug("Trying to find captcha")

            try:
                url_captcha_html = re.search(r'(index.php\?id=10&amp;.*&amp;captcha=1)', page).group(1).replace("amp;", "")

            except Exception, e:
                self.logDebug("Exception during Captcha regex: %s" % e.message)
                page = None

            else:
                url_captcha_html = urljoin("http://netload.in/", url_captcha_html)
                break

        self.html = self.load(url_captcha_html)

        recaptcha = ReCaptcha(self)

        for _i in xrange(5):
            response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY)

            response_page = self.load("http://www.netload.in/index.php?id=10",
                                      post={'captcha_check'            : '1',
                                            'recaptcha_challenge_field': challenge,
                                            'recaptcha_response_field' : response,
                                            'file_id'                  : self.api_data['fileid'],
                                            'Download_Next'            : ''})
            if "Orange_Link" in response_page:
                break

            if self.check_free_wait(response_page):
                self.logDebug("Had to wait for next free slot, trying again")
                return self.download_html()

            else:
                download_url = self.get_file_url(response_page)
                self.logDebug("Download URL after get_file: " + download_url)
                if not download_url.startswith("http://"):
                    self.error(_("Download url: %s") % download_url)
                self.wait()

                self.url = download_url
                return True
Esempio n. 48
0
    def handleFree(self, pyfile):
        data = {"ukey": self.info['pattern']['ID']}

        m = re.search(self.AB1_PATTERN, self.html)
        if m is None:
            self.error(_("__AB1"))
        data['__ab1'] = m.group(1)

        recaptcha = ReCaptcha(self)

        m = re.search(self.RECAPTCHA_PATTERN, self.html)
        captcha_key = m.group(1) if m else recaptcha.detect_key()

        if captcha_key is None:
            self.error(_("ReCaptcha key not found"))

        response, challenge = recaptcha.challenge(captcha_key)
        self.account.form_data = {
            "recaptcha_challenge_field": challenge,
            "recaptcha_response_field": response
        }
        self.account.relogin(self.user)
        self.retry(2)

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

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

        self.logDebug(res)
        if res['captcha']:
            data['ctype'] = "recaptcha"

            for _i in xrange(5):
                data['recaptcha_response'], data[
                    'recaptcha_challenge'] = recaptcha.challenge(captcha_key)

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

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

        if res['dl']:
            self.html = self.load('http://filecloud.io/download.html')

            m = re.search(self.LINK_FREE_PATTERN % self.info['pattern']['ID'],
                          self.html)
            if m is None:
                self.error(_("LINK_FREE_PATTERN not found"))

            if "size" in self.info and self.info['size']:
                self.check_data = {"size": int(self.info['size'])}

            self.link = m.group(1)
        else:
            self.fail(_("Unexpected server response"))
Esempio n. 49
0
    def handleFree(self, pyfile):
        action, inputs = self.parseHtmlForm('id="ifree_form"')
        if not action:
            self.error(_("ifree_form"))

        pyfile.size = float(inputs['sssize'])
        self.logDebug(action, inputs)
        inputs['desc'] = ""

        self.html = self.load(urljoin("http://letitbit.net/", action),
                              post=inputs)

        m = re.search(self.SECONDS_PATTERN, self.html)
        seconds = int(m.group(1)) if m else 60

        self.logDebug("Seconds found", seconds)

        m = re.search(self.CAPTCHA_CONTROL_FIELD, self.html)
        recaptcha_control_field = m.group(1)

        self.logDebug("ReCaptcha control field found", recaptcha_control_field)

        self.wait(seconds)

        res = self.load("http://letitbit.net/ajax/download3.php", post=" ")
        if res != '1':
            self.error(_("Unknown response - ajax_check_url"))

        self.logDebug(res)

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

        post_data = {
            "recaptcha_challenge_field": challenge,
            "recaptcha_response_field": response,
            "recaptcha_control_field": recaptcha_control_field
        }

        self.logDebug("Post data to send", post_data)

        res = self.load("http://letitbit.net/ajax/check_recaptcha.php",
                        post=post_data)

        self.logDebug(res)

        if not res:
            self.invalidCaptcha()

        if res == "error_free_download_blocked":
            self.logWarning(_("Daily limit reached"))
            self.wait(secondsToMidnight(gmt=2), True)

        if res == "error_wrong_captcha":
            self.invalidCaptcha()
            self.retry()

        elif res.startswith('['):
            urls = json_loads(res)

        elif res.startswith('http://'):
            urls = [res]

        else:
            self.error(_("Unknown response - captcha check"))

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

        # Get download info
        self.logDebug("Getting download info")
        res = self.load("http://bitshare.com/files-ajax/" + self.file_id +
                        "/request.html",
                        post={
                            "request": "generateID",
                            "ajaxid": self.ajaxid
                        })

        self.handleErrors(res, ':')

        parts = res.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.wait(wait, False)
            else:
                self.wait(wait - 55, True)
                self.retry()

        # Resolve captcha
        if captcha == 1:
            self.logDebug("File is captcha protected")
            recaptcha = ReCaptcha(self)

            # Try up to 3 times
            for _i in xrange(3):
                response, challenge = recaptcha.challenge()
                res = 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": response
                                })
                if self.handleCaptchaErrors(res):
                    break

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

        self.handleErrors(res, '#')

        url = res.split("#")[-1]

        return url
Esempio n. 51
0
    def handle_free(self, pyfile):
        data = {"ukey": self.info['pattern']['ID']}

        m = re.search(self.AB1_PATTERN, self.html)
        if m is None:
            self.error(_("__AB1"))
        data['__ab1'] = m.group(1)

        recaptcha = ReCaptcha(self)

        m = re.search(self.RECAPTCHA_PATTERN, self.html)
        captcha_key = m.group(1) if m else recaptcha.detect_key()

        if captcha_key is None:
            self.error(_("ReCaptcha key not found"))

        response, challenge = recaptcha.challenge(captcha_key)
        self.account.form_data = {"recaptcha_challenge_field": challenge,
                                  "recaptcha_response_field" : response}
        self.account.relogin(self.user)
        self.retry(2)

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

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

        self.logDebug(res)
        if res['captcha']:
            data['ctype'] = "recaptcha"

            for _i in xrange(5):
                data['recaptcha_response'], data['recaptcha_challenge'] = recaptcha.challenge(captcha_key)

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

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

        if res['dl']:
            self.html = self.load('http://filecloud.io/download.html')

            m = re.search(self.LINK_FREE_PATTERN % self.info['pattern']['ID'], self.html)
            if m is None:
                self.error(_("LINK_FREE_PATTERN not found"))

            if "size" in self.info and self.info['size']:
                self.check_data = {"size": int(self.info['size'])}

            self.link = m.group(1)
        else:
            self.fail(_("Unexpected server response"))