Пример #1
0
    def decrypt(self, pyfile):
        url = pyfile.url
        if re.match(self.__pattern__, url).group(1) == "d":
            self.req.http.c.setopt(FOLLOWLOCATION, 0)
            self.load(url)
            m = re.search("^Location: (.+)$", self.req.http.header,
                          re.MULTILINE)
            if m:
                self.core.files.addLinks([m.group(1)], pyfile.package().id)
            else:
                self.fail("Couldn't find forwarded Link")

        else:
            password = ""
            packageLinks = []
            postData = {"post-protect": "1"}

            self.html = self.load(url)

            if "link-password" in self.html:
                password = pyfile.package().password
                postData["link-password"] = password

            if "altcaptcha" in self.html:
                for _ in xrange(5):
                    m = re.search(self.__Solvemedia_pattern__, self.html)
                    if m:
                        captchaKey = m.group(1)
                        captcha = SolveMedia(self)
                        captchaProvider = "Solvemedia"
                    else:
                        self.fail("Error parsing captcha")

                    challenge, response = captcha.challenge(captchaKey)
                    postData["adcopy_challenge"] = challenge
                    postData["adcopy_response"] = response

                    self.html = self.load(url, post=postData)
                    if "The password you entered was incorrect" in self.html:
                        self.fail("Incorrect Password")
                    if not "The CAPTCHA code you entered was wrong" in self.html:
                        break

            pyfile.package().password = ""
            soup = BeautifulSoup(self.html)
            scripts = soup.findAll("script")
            for s in scripts:
                if "d_links" in s.text:
                    break
            m = re.search('d_links":(\[.*?\])', s.text)
            if m:
                linkDict = json_loads(m.group(1))
                for link in linkDict:
                    if not "http://" in link["full"]:
                        packageLinks.append("https://safelinking.net/d/" +
                                            link["full"])
                    else:
                        packageLinks.append(link["full"])

            self.core.files.addLinks(packageLinks, pyfile.package().id)
Пример #2
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
Пример #3
0
    def handleFree(self, pyfile):
        # Search for Download URL
        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m is None:
            self.error(_("LINK_FREE_PATTERN not found"))

        download_url = m.group(1)

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

        # Load.to is using solvemedia captchas since ~july 2014:
        solvemedia  = SolveMedia(self)
        captcha_key = solvemedia.detect_key()

        if captcha_key is None:
            self.download(download_url)
        else:
            response, challenge = solvemedia.challenge(captcha_key)
            self.download(download_url,
                          post={'adcopy_challenge': challenge,
                                'adcopy_response' : response,
                                'returnUrl'       : pyfile.url})
Пример #4
0
    def decrypt(self, pyfile):
        url = pyfile.url
        if re.search(self.__pattern__, url).group(1) == "d":
            self.req.http.c.setopt(FOLLOWLOCATION, 0)
            self.load(url)
            m = re.search("^Location: (.+)$", self.req.http.header, re.MULTILINE)
            if m:
                self.core.files.addLinks([m.group(1)], self.pyfile.package().id)
            else:
                self.fail("Couldn't find forwarded Link")

        else:
            password = ""
            packageLinks = []
            postData = {"post-protect": "1"}

            self.html = self.load(url)

            if "link-password" in self.html:
                password = pyfile.package().password
                postData["link-password"] = password

            if "altcaptcha" in self.html:
                for i in xrange(5):
                    m = re.search(self.__Solvemedia_pattern__, self.html)
                    if m:
                        captchaKey = m.group(1)
                        captcha = SolveMedia(self)
                        captchaProvider = "Solvmedia"
                    else:
                        self.fail("Error parsing captcha")

                    challenge, response = captcha.challenge(captchaKey)
                    postData["adcopy_challenge"] = challenge
                    postData["adcopy_response"] = response

                    self.html = self.load(url, post=postData)
                    if "The password you entered was incorrect" in self.html:
                        self.fail("Incorrect Password")
                    if not "The CAPTCHA code you entered was wrong" in self.html:
                        break

            pyfile.package().password = ""
            soup = BeautifulSoup(self.html)
            scripts = soup.findAll("script")
            for s in scripts:
                if "d_links" in s.text:
                    break
            m = re.search('d_links":(\[.*?\])', s.text)
            if m:
                linkDict = json_loads(m.group(1))
                for link in linkDict:
                    if not "http://" in link["full"]:
                        packageLinks.append("https://safelinking.net/d/" + link["full"])
                    else:
                        packageLinks.append(link["full"])

            self.core.files.addLinks(packageLinks, self.pyfile.package().id)
Пример #5
0
    def getDownloadLink(self):
        retry = False
        self.html = self.load(self.pyfile.url)
        action, inputs = self.parseHtmlForm(
            input_names={"op": re.compile("^download")})
        if 'method_premium' in inputs:
            del inputs['method_premium']

        self.html = self.load(self.pyfile.url, post=inputs)
        action, inputs = self.parseHtmlForm('F1')

        self.setWait(65)
        # Wait
        if 'You have reached the download-limit!!!' in self.html:
            self.setWait(3600, True)
            retry = True

        match = re.search(self.WAIT_PATTERN, self.html)
        if match:
            m = match.groupdict(0)
            waittime = int(m["hour"]) * 60 * 60 + int(m['min']) * 60 + int(
                m['sec'])
            self.setWait(waittime, True)
            retry = True

        self.wait()
        if retry:
            self.retry()

        for i in xrange(5):

            m = re.search(self.SOLVEMEDIA_PATTERN, self.html)
            if not m:
                self.parseError("Error parsing captcha")

            captchaKey = m.group(1)
            captcha = SolveMedia(self)
            challenge, response = captcha.challenge(captchaKey)

            inputs["adcopy_challenge"] = challenge
            inputs["adcopy_response"] = response

            self.html = self.load(self.pyfile.url, post=inputs)
            if "WRONG CAPTCHA" in self.html:
                self.invalidCaptcha()
                self.logInfo("Invalid Captcha")
            else:
                self.correctCaptcha()
                break

        else:
            self.fail("You have entered 5 invalid captcha codes")

        if 'Click here to download' in self.html:
            m = re.search(r'<a href="([^"]+)">Click here to download</a>',
                          self.html)
            return m.group(1)
Пример #6
0
    def getDownloadLink(self):
        retry = False
        self.html = self.load(self.pyfile.url)
        action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")})
        if 'method_premium' in inputs:
            del inputs['method_premium']

        self.html = self.load(self.pyfile.url, post=inputs)
        action, inputs = self.parseHtmlForm('F1')

        self.setWait(65)
        # Wait
        if 'You have reached the download-limit!!!' in self.html:
            self.setWait(3600, True)
            retry = True
            
        match = re.search(self.WAIT_PATTERN, self.html)
        if match:
            m = match.groupdict(0)
            waittime = int(m["hour"])*60*60 + int(m['min']) * 60 + int(m['sec'])
            self.setWait(waittime, True)
            retry = True

        self.wait()
        if retry:
            self.retry()

        for i in xrange(5):
            
            m = re.search(self.SOLVEMEDIA_PATTERN, self.html)
            if not m:
                self.parseError("Error parsing captcha")

            captchaKey = m.group(1)
            captcha = SolveMedia(self)
            challenge, response = captcha.challenge(captchaKey)

            inputs["adcopy_challenge"] = challenge
            inputs["adcopy_response"] = response

            self.html = self.load(self.pyfile.url, post = inputs)
            if "WRONG CAPTCHA" in self.html:
                self.invalidCaptcha()
                self.logInfo("Invalid Captcha")
            else:
                self.correctCaptcha()
                break

        else:
            self.fail("You have entered 5 invalid captcha codes")

        if 'Click here to download' in self.html:
            m = re.search(r'<a href="([^"]+)">Click here to download</a>', self.html)
            return m.group(1)
Пример #7
0
    def decrypt(self, pyfile):
        url = pyfile.url

        if re.match(self.__pattern__, url).group(1) == "d":

            header = self.load(url, just_header=True)
            if 'location' in header:
                self.urls = [header['location']]
            else:
                self.error(_("Couldn't find forwarded Link"))

        else:
            postData = {"post-protect": "1"}

            self.html = self.load(url)

            if "link-password" in self.html:
                postData['link-password'] = self.getPassword()

            if "altcaptcha" in self.html:
                for _i in xrange(5):
                    m = re.search(self.SOLVEMEDIA_PATTERN, self.html)
                    if m:
                        captchaKey = m.group(1)
                        captcha = SolveMedia(self)
                        captchaProvider = "Solvemedia"
                    else:
                        self.fail(_("Error parsing captcha"))

                    response, challenge = captcha.challenge(captchaKey)
                    postData['adcopy_challenge'] = challenge
                    postData['adcopy_response']  = response

                    self.html = self.load(url, post=postData)
                    if "The password you entered was incorrect" in self.html:
                        self.fail(_("Incorrect Password"))
                    if not "The CAPTCHA code you entered was wrong" in self.html:
                        break

            pyfile.package().password = ""
            soup = BeautifulSoup(self.html)
            scripts = soup.findAll("script")
            for s in scripts:
                if "d_links" in s.text:
                    break
            m = re.search('d_links":(\[.*?\])', s.text)
            if m:
                linkDict = json_loads(m.group(1))
                for link in linkDict:
                    if not "http://" in link['full']:
                        self.urls.append("https://safelinking.net/d/" + link['full'])
                    else:
                        self.urls.append(link['full'])
Пример #8
0
 def checkCaptcha(self):
     for _ in xrange(5):
         found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
         if found:
             captcha_key = found.group(1)
             solvemedia = SolveMedia(self)
             captcha_challenge, captcha_response = solvemedia.challenge(captcha_key)
             self.html = self.load(self.url, post={"adcopy_challenge": captcha_challenge,
                                                   "adcopy_response": captcha_response}, decode=True)
         else:
             break
     else:
         self.fail("No valid recaptcha solution received")
Пример #9
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

        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

        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

        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)
Пример #10
0
 def checkCaptcha(self):
     for i in xrange(5):
         found = re.search(self.SOLVEMEDIA_PATTERN, self.html)
         if found:
             captcha_key = found.group(1)
             solvemedia = SolveMedia(self)
             captcha_challenge, captcha_response = solvemedia.challenge(
                 captcha_key)
             self.html = self.load(self.url,
                                   post={
                                       "adcopy_challenge":
                                       captcha_challenge,
                                       "adcopy_response": captcha_response
                                   },
                                   decode=True)
         else:
             break
     else:
         self.fail("No valid recaptcha solution received")
Пример #11
0
    def handleFree(self, pyfile):
        # Click the free user button
        post_data = {'op'         : "download1",
                     'usr_login'  : "",
                     'id'         : self.info['pattern']['ID'],
                     'fname'      : pyfile.name,
                     'referer'    : "",
                     'method_free': "+"}

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

        solvemedia = SolveMedia(self)
        response, challenge = solvemedia.challenge()

        # Make the downloadlink appear and load the file
        m = re.search(self.RAND_ID_PATTERN, self.html)
        if m is None:
            self.error(_("Random key not found"))

        rand = m.group(1)
        self.logDebug("rand = ", rand)

        post_data = {'op'              : "download2",
                     'id'              : self.info['pattern']['ID'],
                     'rand'            : rand,
                     'referer'         : pyfile.url,
                     'method_free'     : "+",
                     'method_premium'  : "",
                     'adcopy_response' : response,
                     'adcopy_challenge': challenge,
                     'down_direct'     : "1"}

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

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

        self.download(m.group(1), cookies=True, disposition=True)
Пример #12
0
    def handleFree(self, pyfile):
        solvemedia  = SolveMedia(self)
        captcha_key = solvemedia.detect_key()

        if captcha_key:
            response, challenge = solvemedia.challenge(captcha_key)
            self.html = self.load(pyfile.url,
                                  post={'adcopy_challenge': challenge,
                                        'adcopy_response' : response},
                                  decode=True)

        if self.PASSWORD_PATTERN in self.html:
            password = self.getPassword()

            if not password:
                self.fail(_("No password found"))
            else:
                self.logInfo(_("Password protected link, trying: ") + password)
                self.html = self.load(self.link, post={'downloadp': password})

                if self.PASSWORD_PATTERN in self.html:
                    self.fail(_("Incorrect password"))

        return super(MediafireCom, self).handleFree(pyfile)