Exemple #1
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))
Exemple #2
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
Exemple #3
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)
Exemple #4
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
Exemple #5
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
                
     # Unlock protection
     postData['submit_protected'] = 'Continue to folder '
     return self.load(self.pyfile.url, post=postData)
Exemple #6
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('<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
Exemple #7
0
    def handleFree(self):
        ukey = re.search(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 i in range(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"])
Exemple #8
0
    def handleFree(self):
        if "Currently only Premium Members can download files larger than" in self.html:
            self.fail("File too large for free download")
        elif "All free download slots on this server are currently in use" in self.html:
            self.retry(50, 900, "All free slots are busy")
             
        # Check Id
        self.check = re.search(self.FILE_CHECK_PATTERN, self.html).group('check')
        self.logDebug("File check code is [%s]" % self.check)
        
        # Resolve captcha
        found = re.search(self.CAPTCHA_KEY_PATTERN, self.html)
        recaptcha_key = found.group(1) if found else "6LeN8roSAAAAAPdC1zy399Qei4b1BwmSBSsBN8zm"
        recaptcha = ReCaptcha(self)
        
        # Try up to 5 times
        for i in range(5):           
            challenge, code = recaptcha.challenge(recaptcha_key)
            response = json_loads(self.load("http://www.filefactory.com/file/checkCaptcha.php",
                            post={"check" : self.check, "recaptcha_challenge_field" : challenge, "recaptcha_response_field" : code}))
            if response['status'] == 'ok':
                self.correctCaptcha()
                break
            else:
                self.invalidCaptcha()                            
        else:
            self.fail("No valid captcha after 5 attempts")

        # This will take us to a wait screen
        waiturl = "http://www.filefactory.com" + response['path']
        self.logDebug("Fetching wait with url [%s]" % waiturl)
        waithtml = self.load(waiturl, decode=True)
        found = re.search(r'<a href="(http://www.filefactory.com/dlf/.*?)"', waithtml)
        waithtml = self.load(found.group(1), decode=True)

        # Find the wait value and wait
        wait = int(re.search(self.WAIT_PATTERN, waithtml).group('wait'))
        self.logDebug("Waiting %d seconds." % wait)
        self.setWait(wait, True)
        self.wait()

        # Now get the real download url and retrieve the file
        url = re.search(self.FILE_URL_PATTERN,waithtml).group('url')
        # this may either download our file or forward us to an error page
        self.logDebug("Download URL: %s" % url)
        self.download(url)
        
        check = self.checkDownload({"multiple": "You are currently downloading too many files at once.",
                                    "error": '<div id="errorMessage">'})

        if check == "multiple":
            self.setWait(15*60)
            self.logDebug("Parallel downloads detected; waiting 15 minutes")
            self.wait()
            self.retry()
        elif check == "error":
            self.fail("Unknown error")
Exemple #9
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)
Exemple #10
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
Exemple #11
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))
Exemple #12
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)
Exemple #13
0
    def handleFree(self):
        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)
Exemple #14
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()
Exemple #15
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)
                self.wait()
        if "type" in response:
            if response["type"] == "download":
                url = response["url"]
                self.logDebug("Download link", url)
                self.download(url, disposition=True)
Exemple #16
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()
Exemple #17
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.")

        url = False
        for i in range(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 i in range(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')
Exemple #18
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)
Exemple #19
0
 def checkCaptcha(self):
     for i in range(5):
         found = re.search(self.RECAPTCHA_PATTERN, self.html)
         if found:
             captcha_action = re.search(self.PAGE1_ACTION_PATTERN,
                                        self.html).group(1)
             captcha_key = found.group(1)
             recaptcha = ReCaptcha(self)
             captcha_challenge, captcha_response = recaptcha.challenge(
                 captcha_key)
             self.html = self.load(captcha_action,
                                   post={
                                       "recaptcha_challenge_field":
                                       captcha_challenge,
                                       "recaptcha_response_field":
                                       captcha_response
                                   },
                                   decode=True)
         else:
             break
     else:
         self.fail("No valid recaptcha solution received")
Exemple #20
0
    def handleFree(self):
        url = 'http://datei.to/ajax/download.php'
        data = {'P': 'I', 'ID': self.file_info['ID']}

        recaptcha = ReCaptcha(self)

        for i in range(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)
Exemple #21
0
    def doCaptcha(self):
        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN,
                                self.html).group("key")
        recaptcha = ReCaptcha(self)

        for i in range(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")
Exemple #22
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")
Exemple #23
0
    def handleFree(self):
        file_id = re.search(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.setWait(int(json['time']))
        self.wait()

        recaptcha = ReCaptcha(self)
        for i 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'])
Exemple #24
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")
Exemple #25
0
    def handleFree(self):
        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:"+st)
        if captcha.__class__.__name__ == "SolveMedia":
            captcha_prov = "adcopy"
        else:
            captcha_prov = captcha.__class__.__name__.lower()        
        
        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)
Exemple #26
0
    def handleFree(self):
        # Find token and captcha key
        file_id = re.search(self.__pattern__, self.pyfile.url).group(1)

        found = re.search(self.FLP_TOKEN_PATTERN, self.html)
        if not found: self.parseError("Token")
        flp_token = found.group(1)

        found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html)
        if not found: self.parseError("Captcha key")
        captcha_key = found.group(1)

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

        if wait_time > 0:
            self.setWait(wait_time)
            self.wait()

        post_dict = {"token": flp_token, "code": file_id, "file_pass": ''}

        if 'var is_pass_exists = true;' in self.html:
            # Solve password
            for file_pass in self.getPassword().splitlines():
                get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml'
                post_dict['file_pass'] = file_pass
                self.logInfo("Password protected link, trying " + file_pass)

                download_url = self.getJsonResponse(get_dict, post_dict,
                                                    'link')
                if download_url:
                    break

            else:
                self.fail("No or incorrect password")

        else:
            # Solve recaptcha
            recaptcha = ReCaptcha(self)

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

                download_url = self.getJsonResponse(get_dict, post_dict,
                                                    'link')
                if download_url:
                    if pokus: self.correctCaptcha()
                    break
                elif pokus:
                    self.invalidCaptcha()

            else:
                self.fail("Invalid captcha")

        # Download
        self.download(download_url)
Exemple #27
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.log.info("DepositFiles.com: The file is being checked. Waiting 1 minute.")
            self.setWait(61)
            self.wait()
            self.retry()

        wait = re.search(r'html_download_api-limit_interval\">(\d+)</span>', self.html)
        if wait:
            wait_time = int(wait.group(1))
            self.log.info( "%s: Traffic used up. Waiting %d seconds." % (self.__name__, wait_time) )
            self.setWait(wait_time)
            self.wantReconnect = True
            self.wait()
            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.log.info( "%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 i in range(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)
Exemple #28
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(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)
        check = self.checkDownload({"limit-dl": self.DL_LIMIT_PATTERN})
        if check == "limit-dl":
            self.setWait(60 * 60, True)
            self.wait()
            self.retry()