diff options
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/captcha/ReCaptcha.py | 6 | ||||
-rw-r--r-- | module/plugins/crypter/FilecryptCc.py | 3 | ||||
-rw-r--r-- | module/plugins/crypter/LinkCryptWs.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/NCryptIn.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/RelinkUs.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/ShareLinksBiz.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/Captcha.py | 20 |
7 files changed, 17 insertions, 20 deletions
diff --git a/module/plugins/captcha/ReCaptcha.py b/module/plugins/captcha/ReCaptcha.py index a5aa356e2..5931159c5 100644 --- a/module/plugins/captcha/ReCaptcha.py +++ b/module/plugins/captcha/ReCaptcha.py @@ -84,8 +84,7 @@ class ReCaptcha(CaptchaService): result = self.decrypt(urlparse.urljoin(server, "image"), get={'c': challenge}, cookies=True, - input_type="jpg", - ocr=False) + input_type="jpg") self.log_debug("Result: %s" % result) @@ -173,7 +172,8 @@ class ReCaptcha(CaptchaService): captcha_response = self.decrypt("https://www.google.com/recaptcha/api2/payload", get={'c':token3.group(1), 'k':key}, cookies=True, - ocr=False) + ocr=False, + timeout=30) response = b64encode('{"response":"%s"}' % captcha_response) self.log_debug("Result: %s" % response) diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index 62b6c9ee2..9f4ad69aa 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -93,8 +93,7 @@ class FilecryptCc(Crypter): self.log_debug("Captcha-URL: %s" % m.group(1)) captcha_code = self.captcha.decrypt(urlparse.urljoin(self.base_url, m.group(1)), - input_type="gif", - ocr=False) + input_type="gif") self.site_with_links = self.load(self.pyfile.url, post={'recaptcha_response_field': captcha_code}) diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index f235a9406..af13f55f6 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -133,7 +133,7 @@ class LinkCryptWs(Crypter): def unlock_captcha_protection(self): captcha_url = re.search(r'<form.*?id\s*?=\s*?"captcha"[^>]*?>.*?<\s*?input.*?src="(.+?)"', self.html, re.I | re.S).group(1) - captcha_code = self.captcha.decrypt(captcha_url, input_type="gif", output_type='positional', ocr=False) + captcha_code = self.captcha.decrypt(captcha_url, input_type="gif", output_type='positional') self.html = self.load(self.pyfile.url, post={'x': captcha_code[0], 'y': captcha_code[1]}) diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index 4e419a9c9..d483be323 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -164,7 +164,7 @@ class NCryptIn(Crypter): if "circlecaptcha" in form: self.log_debug("CircleCaptcha protected") captcha_img_url = "http://ncrypt.in/classes/captcha/circlecaptcha.php" - coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr=False) + coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr="CircleCaptcha") self.log_debug("Captcha resolved, coords [%s]" % str(coords)) postData['circle.x'] = coords[0] postData['circle.y'] = coords[1] diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index d2f0a278b..b3c13db5d 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -142,7 +142,7 @@ class RelinkUs(Crypter): def unlock_captcha_protection(self): self.log_debug("Request user positional captcha resolving") captcha_img_url = self.CAPTCHA_IMG_URL + "?id=%s" % self.fileid - coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr=False) + coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr="CircleCaptcha") self.log_debug("Captcha resolved, coords [%s]" % str(coords)) captcha_post_url = self.CAPTCHA_SUBMIT_URL + "?id=%s" % self.fileid captcha_post_data = {'button.x': coords[0], 'button.y': coords[1], 'captcha': 'submit'} diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index b9ddd953f..6fbe59b38 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -117,7 +117,7 @@ class ShareLinksBiz(Crypter): m = re.search(r'<img src="/captcha.gif\?d=(.*?)&PHPSESSID=(.*?)&legend=1"', self.html) captchaUrl = self.base_url + '/captcha.gif?d=%s&PHPSESSID=%s' % (m.group(1), m.group(2)) self.log_debug("Waiting user for correct position") - coords = self.captcha.decrypt(captchaUrl, input_type="gif", output_type='positional', ocr=False) + coords = self.captcha.decrypt(captchaUrl, input_type="gif", output_type='positional') self.log_debug("Captcha resolved, coords [%s]" % str(coords)) #: Resolve captcha diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index f126ca85e..14308fbf5 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -12,7 +12,7 @@ from module.plugins.internal.Plugin import Plugin class Captcha(Plugin): __name__ = "Captcha" __type__ = "captcha" - __version__ = "0.38" + __version__ = "0.39" __status__ = "testing" __description__ = """Base anti-captcha plugin""" @@ -57,7 +57,7 @@ class Captcha(Plugin): #@TODO: Definitely choose a better name for this method! - def _decrypt(self, raw, input_type='jpg', output_type='textual', ocr=None, timeout=120): + def _decrypt(self, raw, input_type='jpg', output_type='textual', ocr=False, timeout=120): """ Loads a captcha and decrypts it with ocr, plugin, user input @@ -73,31 +73,28 @@ class Captcha(Plugin): :return: result of decrypting """ + result = "" time_ref = ("%.2f" % time.time())[-6:].replace(".", "") with open(os.path.join("tmp", "captcha_image_%s_%s.%s" % (self.plugin.__name__, time_ref, input_type)), "wb") as tmp_img: tmp_img.write(raw) - if ocr is not False: + if ocr: if isinstance(ocr, basestring): OCR = self.pyload.pluginManager.loadClass("captcha", ocr) #: Rename `captcha` to `ocr` in 0.4.10 - - if self.plugin.pyfile.abort: - self.plugin.abort() - result = OCR(self.plugin).recognize(tmp_img.name) - else: result = self.recognize(tmp_img.name) - else: + if not result: captchaManager = self.pyload.captchaManager try: self.task = captchaManager.newTask(raw, input_type, tmp_img.name, output_type) + captchaManager.handleCaptcha(self.task) - self.task.setWaiting(max(timeout, 50)) #@TODO: Move to `CaptchaManager` in 0.4.10 + self.task.setWaiting(max(timeout, 50)) #@TODO: Move to `CaptchaManager` in 0.4.10 while self.task.isWaiting(): if self.plugin.pyfile.abort: self.plugin.abort() @@ -114,7 +111,6 @@ class Captcha(Plugin): self.plugin.retry(reason=_("No captcha result obtained in appropiate time")) result = self.task.result - self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? if not self.pyload.debug: try: @@ -124,6 +120,8 @@ class Captcha(Plugin): self.log_warning(_("Error removing: %s") % tmp_img.name, e) traceback.print_exc() + self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? + return result |