From 6af9b38a8d5d49355b85aef6ddd003605d6bba05 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Jul 2015 23:44:45 +0200 Subject: Improve Captcha --- module/plugins/captcha/AdYouLike.py | 92 ++++++++++++++ module/plugins/captcha/AdsCaptcha.py | 64 ++++++++++ module/plugins/captcha/GigasizeCom.py | 2 +- module/plugins/captcha/LinksaveIn.py | 2 +- module/plugins/captcha/NetloadIn.py | 2 +- module/plugins/captcha/ReCaptcha.py | 197 +++++++++++++++++++++++++++++ module/plugins/captcha/ShareonlineBiz.py | 2 +- module/plugins/captcha/SolveMedia.py | 105 +++++++++++++++ module/plugins/crypter/DlProtectCom.py | 2 +- module/plugins/crypter/FilecryptCc.py | 8 +- module/plugins/crypter/LinkCryptWs.py | 2 +- module/plugins/crypter/LinkdecrypterCom.py | 2 +- module/plugins/crypter/LixIn.py | 2 +- module/plugins/crypter/NCryptIn.py | 6 +- module/plugins/crypter/RelinkUs.py | 2 +- module/plugins/crypter/SafelinkingNet.py | 2 +- module/plugins/crypter/ShareLinksBiz.py | 2 +- module/plugins/hoster/BezvadataCz.py | 2 +- module/plugins/hoster/BitshareCom.py | 2 +- module/plugins/hoster/CatShareNet.py | 2 +- module/plugins/hoster/CrockoCom.py | 2 +- module/plugins/hoster/CzshareCom.py | 2 +- module/plugins/hoster/DateiTo.py | 2 +- module/plugins/hoster/DepositfilesCom.py | 2 +- module/plugins/hoster/ExtabitCom.py | 2 +- module/plugins/hoster/FastshareCz.py | 2 +- module/plugins/hoster/FileSharkPl.py | 2 +- module/plugins/hoster/FileboomMe.py | 2 +- module/plugins/hoster/FilecloudIo.py | 2 +- module/plugins/hoster/FiledropperCom.py | 2 +- module/plugins/hoster/FilepostCom.py | 2 +- module/plugins/hoster/FilerNet.py | 2 +- module/plugins/hoster/FileserveCom.py | 2 +- module/plugins/hoster/FreakshareCom.py | 2 +- module/plugins/hoster/GigapetaCom.py | 2 +- module/plugins/hoster/IfolderRu.py | 2 +- module/plugins/hoster/Keep2ShareCc.py | 4 +- module/plugins/hoster/KingfilesNet.py | 2 +- module/plugins/hoster/LetitbitNet.py | 2 +- module/plugins/hoster/LoadTo.py | 2 +- module/plugins/hoster/LuckyShareNet.py | 2 +- module/plugins/hoster/MediafireCom.py | 4 +- module/plugins/hoster/MegasharesCom.py | 2 +- module/plugins/hoster/NarodRu.py | 2 +- module/plugins/hoster/NitroflareCom.py | 2 +- module/plugins/hoster/OboomCom.py | 2 +- module/plugins/hoster/RapidgatorNet.py | 6 +- module/plugins/hoster/RapiduNet.py | 2 +- module/plugins/hoster/SendspaceCom.py | 2 +- module/plugins/hoster/ShareonlineBiz.py | 2 +- module/plugins/hoster/TurbobitNet.py | 4 +- module/plugins/hoster/UlozTo.py | 4 +- module/plugins/hoster/UloziskoSk.py | 2 +- module/plugins/hoster/UnibytesCom.py | 2 +- module/plugins/hoster/UploadableCh.py | 2 +- module/plugins/hoster/UploadedTo.py | 2 +- module/plugins/hoster/UploadheroCom.py | 2 +- module/plugins/hoster/UpstoreNet.py | 2 +- module/plugins/hoster/ZippyshareCom.py | 2 +- module/plugins/internal/AdYouLike.py | 92 -------------- module/plugins/internal/AdsCaptcha.py | 64 ---------- module/plugins/internal/Captcha.py | 89 +++++++------ module/plugins/internal/OCR.py | 4 +- module/plugins/internal/ReCaptcha.py | 197 ----------------------------- module/plugins/internal/SolveMedia.py | 105 --------------- module/plugins/internal/XFSHoster.py | 6 +- 66 files changed, 577 insertions(+), 570 deletions(-) create mode 100644 module/plugins/captcha/AdYouLike.py create mode 100644 module/plugins/captcha/AdsCaptcha.py create mode 100644 module/plugins/captcha/ReCaptcha.py create mode 100644 module/plugins/captcha/SolveMedia.py delete mode 100644 module/plugins/internal/AdYouLike.py delete mode 100644 module/plugins/internal/AdsCaptcha.py delete mode 100644 module/plugins/internal/ReCaptcha.py delete mode 100644 module/plugins/internal/SolveMedia.py (limited to 'module/plugins') diff --git a/module/plugins/captcha/AdYouLike.py b/module/plugins/captcha/AdYouLike.py new file mode 100644 index 000000000..d14babb51 --- /dev/null +++ b/module/plugins/captcha/AdYouLike.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +import re + +from module.common.json_layer import json_loads +from module.plugins.internal.CaptchaService import CaptchaService + + +class AdYouLike(CaptchaService): + __name__ = "AdYouLike" + __type__ = "captcha" + __version__ = "0.07" + __status__ = "stable" + + __description__ = """AdYouLike captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' + CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' + + + def detect_key(self, data=None): + html = data or self.retrieve_data() + + m = re.search(self.AYL_PATTERN, html) + n = re.search(self.CALLBACK_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) + self.log_debug("Ayl: %s | Callback: %s" % self.key) + return self.key #: Key is the tuple(ayl, callback) + else: + self.log_warning(_("Ayl or callback pattern not found")) + return None + + + def challenge(self, key=None, data=None): + ayl, callback = key or self.retrieve_key(data) + + #: {'adyoulike':{'key':"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, + #: 'all':{'element_id':"ayl_private_cap_92300",'lang':"fr",'env':"prod"}} + ayl = json_loads(ayl) + + html = self.plugin.load("http://api-ayl.appspot.com/challenge", + get={'key' : ayl['adyoulike']['key'], + 'env' : ayl['all']['env'], + 'callback': callback}) + try: + challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) + + except AttributeError: + self.fail(_("AdYouLike challenge pattern not found")) + + self.log_debug("Challenge: %s" % challenge) + + return self.result(ayl, challenge), challenge + + + def result(self, server, challenge): + #: Adyoulike.g._jsonp_5579316662423138 + #: ({'translations':{'fr':{'instructions_visual':"Recopiez « Soonnight » ci-dessous :"}}, + #: 'site_under':true,'clickable':true,'pixels':{'VIDEO_050':[],'DISPLAY':[],'VIDEO_000':[],'VIDEO_100':[], + #: 'VIDEO_025':[],'VIDEO_075':[]},'medium_type':"image/adyoulike", + #: 'iframes':{'big':""},'shares':{},'id':256, + #: 'token':"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1",'formats':{'small':{'y':300,'x':0,'w':300,'h':60}, + #: 'big':{'y':0,'x':0,'w':300,'h':250},'hover':{'y':440,'x':0,'w':300,'h':60}}, + #: 'tid':"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + + if isinstance(server, basestring): + server = json_loads(server) + + if isinstance(challenge, basestring): + challenge = json_loads(challenge) + + try: + instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] + result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() + + except AttributeError: + self.fail(_("AdYouLike result not found")) + + result = {'_ayl_captcha_engine' : "adyoulike", + '_ayl_env' : server['all']['env'], + '_ayl_tid' : challenge['tid'], + '_ayl_token_challenge': challenge['token'], + '_ayl_response' : response} + + self.log_debug("Result: %s" % result) + + return result diff --git a/module/plugins/captcha/AdsCaptcha.py b/module/plugins/captcha/AdsCaptcha.py new file mode 100644 index 000000000..da0c531be --- /dev/null +++ b/module/plugins/captcha/AdsCaptcha.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +import random +import re + +from module.plugins.internal.CaptchaService import CaptchaService + + +class AdsCaptcha(CaptchaService): + __name__ = "AdsCaptcha" + __type__ = "captcha" + __version__ = "0.10" + __status__ = "stable" + + __description__ = """AdsCaptcha captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?CaptchaId=(\d+)' + PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?PublicKey=([\w-]+)' + + + def detect_key(self, data=None): + html = data or self.retrieve_data() + + m = re.search(self.PUBLICKEY_PATTERN, html) + n = re.search(self.CAPTCHAID_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) #: Key is the tuple(PublicKey, CaptchaId) + self.log_debug("Key: %s | ID: %s" % self.key) + return self.key + else: + self.log_warning(_("Key or id pattern not found")) + return None + + + def challenge(self, key=None, data=None): + PublicKey, CaptchaId = key or self.retrieve_key(data) + + html = self.plugin.load("http://api.adscaptcha.com/Get.aspx", + get={'CaptchaId': CaptchaId, + 'PublicKey': PublicKey}) + try: + challenge = re.search("challenge: '(.+?)',", html).group(1) + server = re.search("server: '(.+?)',", html).group(1) + + except AttributeError: + self.fail(_("AdsCaptcha challenge pattern not found")) + + self.log_debug("Challenge: %s" % challenge) + + return self.result(server, challenge), challenge + + + def result(self, server, challenge): + result = self.decrypt("%sChallenge.aspx" % server, + get={'cid': challenge, 'dummy': random.random()}, + cookies=True, + input_type="jpg") + + self.log_debug("Result: %s" % result) + + return result diff --git a/module/plugins/captcha/GigasizeCom.py b/module/plugins/captcha/GigasizeCom.py index 19ad9d680..f71266b23 100644 --- a/module/plugins/captcha/GigasizeCom.py +++ b/module/plugins/captcha/GigasizeCom.py @@ -14,7 +14,7 @@ class GigasizeCom(OCR): __authors__ = [("pyLoad Team", "admin@pyload.org")] - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) self.threshold(2.8) self.run_tesser(True, False, False, True) diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index 68704f21d..0a4731375 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -137,7 +137,7 @@ class LinksaveIn(OCR): self.pixels = self.image.load() - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) bg = self.get_bg() self.substract_bg(bg) diff --git a/module/plugins/captcha/NetloadIn.py b/module/plugins/captcha/NetloadIn.py index b6ba2b6e9..56b7c9196 100644 --- a/module/plugins/captcha/NetloadIn.py +++ b/module/plugins/captcha/NetloadIn.py @@ -14,7 +14,7 @@ class NetloadIn(OCR): __authors__ = [("pyLoad Team", "admin@pyload.org")] - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) self.to_greyscale() self.clean(3) diff --git a/module/plugins/captcha/ReCaptcha.py b/module/plugins/captcha/ReCaptcha.py new file mode 100644 index 000000000..8f9755961 --- /dev/null +++ b/module/plugins/captcha/ReCaptcha.py @@ -0,0 +1,197 @@ +# -*- coding: utf-8 -*- + +import random +import re +import time +import urlparse + +from base64 import b64encode + +from module.plugins.internal.CaptchaService import CaptchaService + + +class ReCaptcha(CaptchaService): + __name__ = "ReCaptcha" + __type__ = "captcha" + __version__ = "0.18" + __status__ = "stable" + + __description__ = """ReCaptcha captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com"), + ("zapp-brannigan", "fuerst.reinje@web.de")] + + + KEY_V1_PATTERN = r'(?:recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=|Recaptcha\.create\s*\(\s*["\'])([\w-]+)' + KEY_V2_PATTERN = r'(?:data-sitekey=["\']|["\']sitekey["\']:\s*["\'])([\w-]+)' + + + def detect_key(self, data=None): + html = data or self.retrieve_data() + + m = re.search(self.KEY_V2_PATTERN, html) or re.search(self.KEY_V1_PATTERN, html) + if m: + self.key = m.group(1).strip() + self.log_debug("Key: %s" % self.key) + return self.key + else: + self.log_warning(_("Key pattern not found")) + return None + + + def challenge(self, key=None, data=None, version=None): + key = key or self.retrieve_key(data) + + if version in (1, 2): + return getattr(self, "_challenge_v%s" % version)(key) + + else: + return self.challenge(key, + version=2 if re.search(self.KEY_V2_PATTERN, html or self.retrieve_data()) else 1) + + + def _challenge_v1(self, key): + html = self.plugin.load("http://www.google.com/recaptcha/api/challenge", + get={'k': key}) + try: + challenge = re.search("challenge : '(.+?)',", html).group(1) + server = re.search("server : '(.+?)',", html).group(1) + + except AttributeError: + self.fail(_("ReCaptcha challenge pattern not found")) + + self.log_debug("Challenge: %s" % challenge) + + return self.result(server, challenge, key) + + + def result(self, server, challenge, key): + self.plugin.load("http://www.google.com/recaptcha/api/js/recaptcha.js") + html = self.plugin.load("http://www.google.com/recaptcha/api/reload", + get={'c' : challenge, + 'k' : key, + 'reason': "i", + 'type' : "image"}) + + try: + challenge = re.search('\(\'(.+?)\',',html).group(1) + + except AttributeError: + self.fail(_("ReCaptcha second challenge pattern not found")) + + self.log_debug("Second challenge: %s" % challenge) + result = self.decrypt("%simage" % server, + get={'c': challenge}, + cookies=True, + input_type="jpg", + ocr=False) + + self.log_debug("Result: %s" % result) + + return result, challenge + + + def _collect_api_info(self): + html = self.plugin.load("http://www.google.com/recaptcha/api.js") + a = re.search(r'po.src = \'(.*?)\';', html).group(1) + vers = a.split("/")[5] + + self.log_debug("API version: %s" % vers) + + language = a.split("__")[1].split(".")[0] + + self.log_debug("API language: %s" % language) + + html = self.plugin.load("https://apis.google.com/js/api.js") + b = re.search(r'"h":"(.*?)","', html).group(1) + jsh = b.decode('unicode-escape') + + self.log_debug("API jsh-string: %s" % jsh) + + return vers, language, jsh + + + def _prepare_time_and_rpc(self): + self.plugin.load("http://www.google.com/recaptcha/api2/demo") + + millis = int(round(time.time() * 1000)) + + self.log_debug("Time: %s" % millis) + + rand = random.randint(1, 99999999) + a = "0.%s" % str(rand * 2147483647) + rpc = int(100000000 * float(a)) + + self.log_debug("Rpc-token: %s" % rpc) + + return millis, rpc + + + def _challenge_v2(self, key, parent=None): + if parent is None: + try: + parent = urlparse.urljoin("http://", urlparse.urlparse(self.plugin.pyfile.url).netloc) + + except Exception: + parent = "" + + botguardstring = "!A" + vers, language, jsh = self._collect_api_info() + millis, rpc = self._prepare_time_and_rpc() + + html = self.plugin.load("https://www.google.com/recaptcha/api2/anchor", + get={'k' : key, + 'hl' : language, + 'v' : vers, + 'usegapi' : "1", + 'jsh' : "%s#id=IO_%s" % (jsh, millis), + 'parent' : parent, + 'pfname' : "", + 'rpctoken': rpc}) + + token1 = re.search(r'id="recaptcha-token" value="(.*?)">', html) + self.log_debug("Token #1: %s" % token1.group(1)) + + html = self.plugin.load("https://www.google.com/recaptcha/api2/frame", + get={'c' : token1.group(1), + 'hl' : language, + 'v' : vers, + 'bg' : botguardstring, + 'k' : key, + 'usegapi': "1", + 'jsh' : jsh}, + decode="unicode-escape") + + token2 = re.search(r'"finput","(.*?)",', html) + self.log_debug("Token #2: %s" % token2.group(1)) + + token3 = re.search(r'"rresp","(.*?)",', html) + self.log_debug("Token #3: %s" % token3.group(1)) + + millis_captcha_loading = int(round(time.time() * 1000)) + captcha_response = self.decrypt("https://www.google.com/recaptcha/api2/payload", + get={'c':token3.group(1), 'k':key}, + cookies=True, + ocr=False) + response = b64encode('{"response":"%s"}' % captcha_response) + + self.log_debug("Result: %s" % response) + + timeToSolve = int(round(time.time() * 1000)) - millis_captcha_loading + timeToSolveMore = timeToSolve + int(float("0." + str(random.randint(1, 99999999))) * 500) + + html = self.plugin.load("https://www.google.com/recaptcha/api2/userverify", + post={'k' : key, + 'c' : token3.group(1), + 'response': response, + 't' : timeToSolve, + 'ct' : timeToSolveMore, + 'bg' : botguardstring}) + + token4 = re.search(r'"uvresp","(.*?)",', html) + self.log_debug("Token #4: %s" % token4.group(1)) + + result = token4.group(1) + + return result, None diff --git a/module/plugins/captcha/ShareonlineBiz.py b/module/plugins/captcha/ShareonlineBiz.py index 7f25f164d..98994b121 100644 --- a/module/plugins/captcha/ShareonlineBiz.py +++ b/module/plugins/captcha/ShareonlineBiz.py @@ -14,7 +14,7 @@ class ShareonlineBiz(OCR): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - def get_captcha(self, image): + def recognize(self, image): self.load_image(image) self.to_greyscale() self.image = self.image.resize((160, 50)) diff --git a/module/plugins/captcha/SolveMedia.py b/module/plugins/captcha/SolveMedia.py new file mode 100644 index 000000000..cbac2dec2 --- /dev/null +++ b/module/plugins/captcha/SolveMedia.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.Plugin import Fail +from module.plugins.internal.CaptchaService import CaptchaService + + +class SolveMedia(CaptchaService): + __name__ = "SolveMedia" + __type__ = "captcha" + __version__ = "0.15" + __status__ = "stable" + + __description__ = """SolveMedia captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' + + + def detect_key(self, data=None): + html = data or self.retrieve_data() + + m = re.search(self.KEY_PATTERN, html) + if m: + self.key = m.group(1).strip() + self.log_debug("Key: %s" % self.key) + return self.key + else: + self.log_warning(_("Key pattern not found") + return None + + + def challenge(self, key=None, data=None): + key = key or self.retrieve_key(data) + + html = self.plugin.load("http://api.solvemedia.com/papi/challenge.noscript", + get={'k': key}) + + for i in xrange(1, 11): + try: + magic = re.search(r'name="magic" value="(.+?)"', html).group(1) + + except AttributeError: + self.log_warning(_("Magic pattern not found") + magic = None + + try: + challenge = re.search(r'', + html).group(1) + + except AttributeError: + self.fail(_("SolveMedia challenge pattern not found")) + + else: + self.log_debug("Challenge: %s" % challenge) + + try: + result = self.result("http://api.solvemedia.com/papi/media", challenge) + + except Fail, e: + self.log_warning(e) + self.plugin.invalidCaptcha() + result = None + + html = self.plugin.load("http://api.solvemedia.com/papi/verify.noscript", + post={'adcopy_response' : result, + 'k' : key, + 'l' : "en", + 't' : "img", + 's' : "standard", + 'magic' : magic, + 'adcopy_challenge': challenge, + 'ref' : self.plugin.pyfile.url}) + try: + redirect = re.search(r'URL=(.+?)">', html).group(1) + + except AttributeError: + self.fail(_("SolveMedia verify pattern not found")) + + else: + if "error" in html: + self.log_warning(_("Captcha code was invalid")) + self.log_debug("Retry #%d" % i) + html = self.plugin.load(redirect) + else: + break + + else: + self.fail(_("SolveMedia max retries exceeded")) + + return result, challenge + + + def result(self, server, challenge): + result = self.decrypt(server, + get={'c': challenge}, + cookies=True, + input_type="gif") + + self.log_debug("Result: %s" % result) + + return result diff --git a/module/plugins/crypter/DlProtectCom.py b/module/plugins/crypter/DlProtectCom.py index 4626af105..05efaca97 100644 --- a/module/plugins/crypter/DlProtectCom.py +++ b/module/plugins/crypter/DlProtectCom.py @@ -54,7 +54,7 @@ class DlProtectCom(SimpleCrypter): if "Security Code" in self.html: m = re.search(r'/captcha\.php\?key=(.+?)"', self.html) if m: - captcha_code = self.captcha.decrypt_image("http://www.dl-protect.com/captcha.php?key=" + m.group(1), input_type="gif") + captcha_code = self.captcha.decrypt("http://www.dl-protect.com/captcha.php?key=" + m.group(1), input_type="gif") post_req['secure'] = captcha_code self.html = self.load(self.pyfile.url, post=post_req) diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index 23636f3b7..3d0d089a7 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -10,7 +10,7 @@ import urlparse from Crypto.Cipher import AES from module.plugins.internal.Crypter import Crypter -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class FilecryptCc(Crypter): @@ -92,16 +92,16 @@ class FilecryptCc(Crypter): if m: #: Normal captcha self.log_debug("Captcha-URL: %s" % m.group(1)) - captcha_code = self.captcha.decrypt_image(urlparse.urljoin(self.base_url, m.group(1)), + captcha_code = self.captcha.decrypt(urlparse.urljoin(self.base_url, m.group(1)), input_type="gif", - try_ocr=False) + ocr=False) self.site_with_links = self.load(self.pyfile.url, post={'recaptcha_response_field': captcha_code}) elif m2: #: Circle captcha self.log_debug("Captcha-URL: %s" % m2.group(1)) - captcha_code = self.captcha.decrypt_image('%s%s?c=abc' %(self.base_url, m2.group(1)), + captcha_code = self.captcha.decrypt('%s%s?c=abc' %(self.base_url, m2.group(1)), output_type='positional') self.site_with_links = self.load(self.pyfile.url, diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index baa440c51..8132db713 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']*?>.*?<\s*?input.*?src="(.+?)"', self.html, re.I | re.S).group(1) - captcha_code = self.captcha.decrypt_image(captcha_url, input_type="gif", output_type='positional', try_ocr=False) + captcha_code = self.captcha.decrypt(captcha_url, input_type="gif", output_type='positional', ocr=False) self.html = self.load(self.pyfile.url, post={'x': captcha_code[0], 'y': captcha_code[1]}) diff --git a/module/plugins/crypter/LinkdecrypterCom.py b/module/plugins/crypter/LinkdecrypterCom.py index 1936425f2..de1172c6c 100644 --- a/module/plugins/crypter/LinkdecrypterCom.py +++ b/module/plugins/crypter/LinkdecrypterCom.py @@ -52,7 +52,7 @@ class LinkdecrypterCom(Crypter): msg = m.group(1) if m else "" self.log_info(_("Captcha protected link"), result_type, msg) - captcha = self.captcha.decrypt_image(captcha_url, output_type=result_type) + captcha = self.captcha.decrypt(captcha_url, output_type=result_type) if result_type == "positional": captcha = "%d|%d" % captcha self.html = self.load('http://linkdecrypter.com/', post={'captcha': captcha}) diff --git a/module/plugins/crypter/LixIn.py b/module/plugins/crypter/LixIn.py index 67037ae79..24b04a3e9 100644 --- a/module/plugins/crypter/LixIn.py +++ b/module/plugins/crypter/LixIn.py @@ -48,7 +48,7 @@ class LixIn(Crypter): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: self.log_debug("Trying captcha") - captcharesult = self.captcha.decrypt_image(urlparse.urljoin("http://lix.in/", m.group(1))) + captcharesult = self.captcha.decrypt(urlparse.urljoin("http://lix.in/", m.group(1))) self.html = self.load(url, post={'capt': captcharesult, 'submit': "submit", 'tiny': id}) else: diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index bc3f6624f..62b11612c 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -6,7 +6,7 @@ import re from Crypto.Cipher import AES from module.plugins.internal.Crypter import Crypter -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class NCryptIn(Crypter): @@ -146,7 +146,7 @@ class NCryptIn(Crypter): if "anicaptcha" in form: self.log_debug("Captcha protected") captchaUri = re.search(r'src="(/temp/anicaptcha/.+?)"', form).group(1) - captcha = self.captcha.decrypt_image("http://ncrypt.in" + captchaUri) + captcha = self.captcha.decrypt("http://ncrypt.in" + captchaUri) self.log_debug("Captcha resolved [%s]" % captcha) postData['captcha'] = captcha @@ -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_image(captcha_img_url, input_type="png", output_type='positional', try_ocr=False) + coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr=False) 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 f95da1b26..1d27f7c93 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_image(captcha_img_url, input_type="png", output_type='positional', try_ocr=False) + coords = self.captcha.decrypt(captcha_img_url, input_type="png", output_type='positional', ocr=False) 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/SafelinkingNet.py b/module/plugins/crypter/SafelinkingNet.py index 8dc833d03..e182df283 100644 --- a/module/plugins/crypter/SafelinkingNet.py +++ b/module/plugins/crypter/SafelinkingNet.py @@ -6,7 +6,7 @@ import BeautifulSoup from module.common.json_layer import json_loads from module.plugins.internal.Crypter import Crypter -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.SolveMedia import SolveMedia class SafelinkingNet(Crypter): diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 894b6d010..82fc6285e 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -117,7 +117,7 @@ class ShareLinksBiz(Crypter): m = re.search(r'Zadaný ověřovací kód nesouhlasí!" in self.html: diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 40725ff89..63e71e776 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index 02b334969..8c01d8756 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -3,7 +3,7 @@ import re import urllib -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index 3b0367467..ca8a18096 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -4,7 +4,7 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, seconds_to_midnight diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index abe2ef2d6..13490441b 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -55,7 +55,7 @@ class FastshareCz(SimpleHoster): self.error(_("FREE_URL_PATTERN not found")) baseurl = "http://www.fastshare.cz" - captcha = self.captcha.decrypt_image(urlparse.urljoin(baseurl, captcha_src)) + captcha = self.captcha.decrypt(urlparse.urljoin(baseurl, captcha_src)) self.download(urlparse.urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index 901890433..d3fbd26d3 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -100,7 +100,7 @@ class FileSharkPl(SimpleHoster): if m is None: self.retry(reason=_("Captcha image not found")) - inputs['form[captcha]'] = self.captcha.decrypt(m.group(1).decode('base64'), input_type='jpeg') + inputs['form[captcha]'] = self.captcha._decrypt(m.group(1).decode('base64'), input_type='jpeg') inputs['form[start]'] = "" self.download(link, post=inputs, disposition=True) diff --git a/module/plugins/hoster/FileboomMe.py b/module/plugins/hoster/FileboomMe.py index 8d0f5d89c..a0b49d1bd 100644 --- a/module/plugins/hoster/FileboomMe.py +++ b/module/plugins/hoster/FileboomMe.py @@ -56,7 +56,7 @@ class FileboomMe(SimpleHoster): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: - captcha = self.captcha.decrypt_image(urljoin(pyfile.url, m.group(1))) + captcha = self.captcha.decrypt(urljoin(pyfile.url, m.group(1))) self.html = self.load(post_url, post={'CaptchaForm[code]' : captcha, diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index d010af624..4383f27d4 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -3,7 +3,7 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/FiledropperCom.py b/module/plugins/hoster/FiledropperCom.py index dede02dac..930b7efdb 100644 --- a/module/plugins/hoster/FiledropperCom.py +++ b/module/plugins/hoster/FiledropperCom.py @@ -34,7 +34,7 @@ class FiledropperCom(SimpleHoster): if m is None: self.fail("Captcha not found") - captcha_code = self.captcha.decrypt_image("http://www.filedropper.com/%s" % m.group(1)) + captcha_code = self.captcha.decrypt("http://www.filedropper.com/%s" % m.group(1)) m = re.search(r'method="post" action="(.+?)"', self.html) if m is None: diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index bc2278a41..de15baab8 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -4,7 +4,7 @@ import re import time from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index 61b3a9635..26420f294 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -8,7 +8,7 @@ import pycurl import re import urlparse -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 117ee1f4c..60df758f5 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -6,7 +6,7 @@ from module.common.json_layer import json_loads from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster from module.plugins.internal.Plugin import chunks -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import seconds_to_midnight from module.utils import parseFileSize as parse_size diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index ba088027a..a80c71b67 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.Hoster import Hoster -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import seconds_to_midnight diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py index 3fcf4ee32..0334087d3 100644 --- a/module/plugins/hoster/GigapetaCom.py +++ b/module/plugins/hoster/GigapetaCom.py @@ -39,7 +39,7 @@ class GigapetaCom(SimpleHoster): for _i in xrange(5): self.check_errors() - captcha = self.captcha.decrypt_image(captcha_url) + captcha = self.captcha.decrypt(captcha_url) self.html = self.load(pyfile.url, post={ 'captcha_key': captcha_key, 'captcha': captcha, diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 457bd6962..f289e29b5 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -49,7 +49,7 @@ class IfolderRu(SimpleHoster): captcha_url = "http://ints.rusfolder.com/random/images/?session=%s" % session_id for _i in xrange(5): action, inputs = self.parse_html_form('id="download-step-one-form"') - inputs['confirmed_number'] = self.captcha.decrypt_image(captcha_url, cookies=True) + inputs['confirmed_number'] = self.captcha.decrypt(captcha_url, cookies=True) inputs['action'] = '1' self.log_debug(inputs) diff --git a/module/plugins/hoster/Keep2ShareCc.py b/module/plugins/hoster/Keep2ShareCc.py index 4fa3f121f..41538da94 100644 --- a/module/plugins/hoster/Keep2ShareCc.py +++ b/module/plugins/hoster/Keep2ShareCc.py @@ -3,7 +3,7 @@ import re import urlparse -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -101,7 +101,7 @@ class Keep2ShareCc(SimpleHoster): self.log_debug("CAPTCHA_PATTERN found %s" % m) if m: captcha_url = urlparse.urljoin("http://keep2s.cc/", m.group(1)) - post_data['CaptchaForm[code]'] = self.captcha.decrypt_image(captcha_url) + post_data['CaptchaForm[code]'] = self.captcha.decrypt(captcha_url) else: recaptcha = ReCaptcha(self) response, challenge = recaptcha.challenge() diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index d05d8443a..b02b26914 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 92bb5ab62..59d1ae41b 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -11,7 +11,7 @@ import urlparse from module.common.json_layer import json_loads, json_dumps from module.network.RequestFactory import getURL as get_url -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, seconds_to_midnight diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py index 2ce9134a2..e8f8cbf9a 100644 --- a/module/plugins/hoster/LoadTo.py +++ b/module/plugins/hoster/LoadTo.py @@ -6,7 +6,7 @@ import re -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index e5ae3f1c3..d71c0d9d7 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -3,7 +3,7 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index bbe9aeb77..cc3c6a6a4 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.ReCaptcha import ReCaptcha -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 65c41c23f..46c4cba91 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -56,7 +56,7 @@ class MegasharesCom(SimpleHoster): for _i in xrange(5): random_num = re.search(self.REACTIVATE_NUM_PATTERN, self.html).group(1) - verifyinput = self.captcha.decrypt_image("http://d01.megashares.com/index.php", + verifyinput = self.captcha.decrypt("http://d01.megashares.com/index.php", get={'secgfx': "gfx", 'random_num': random_num}) self.log_info(_("Reactivating passport %s: %s %s") % (passport_num, random_num, verifyinput)) diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index f54fbf71e..a833edff4 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -43,7 +43,7 @@ class NarodRu(SimpleHoster): post_data = {'action': "sendcapcha"} captcha_url, post_data['key'] = m.groups() - post_data['rep'] = self.captcha.decrypt_image(captcha_url) + post_data['rep'] = self.captcha.decrypt(captcha_url) self.html = self.load(pyfile.url, post=post_data) diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py index c03cb8de0..54b243e3c 100644 --- a/module/plugins/hoster/NitroflareCom.py +++ b/module/plugins/hoster/NitroflareCom.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index f5624439f..43eb726be 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -7,7 +7,7 @@ import re from module.common.json_layer import json_loads from module.plugins.internal.Hoster import Hoster -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha class OboomCom(Hoster): diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index 7b364e150..8aa513775 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -5,9 +5,9 @@ import re from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader -from module.plugins.internal.AdsCaptcha import AdsCaptcha -from module.plugins.internal.ReCaptcha import ReCaptcha -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.AdsCaptcha import AdsCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py index 9c1670211..a4afc99e4 100644 --- a/module/plugins/hoster/RapiduNet.py +++ b/module/plugins/hoster/RapiduNet.py @@ -5,7 +5,7 @@ import re import time from module.common.json_layer import json_loads -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py index 18e66033f..46cc83824 100644 --- a/module/plugins/hoster/SendspaceCom.py +++ b/module/plugins/hoster/SendspaceCom.py @@ -48,7 +48,7 @@ class SendspaceCom(SimpleHoster): captcha_url2 = "http://www.sendspace.com/" + m.group(1) params = {'captcha_hash': m.group(2), 'captcha_submit': 'Verify', - 'captcha_answer': self.captcha.decrypt_image(captcha_url1) + " " + self.captcha.decrypt_image(captcha_url2)} + 'captcha_answer': self.captcha.decrypt(captcha_url1) + " " + self.captcha.decrypt(captcha_url2)} else: params = {'download': "Regular Download"} diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 13e4f8f87..801057b66 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -6,7 +6,7 @@ import urllib import urlparse from module.network.RequestFactory import getURL as get_url -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index f70a985df..1d47f9329 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -9,7 +9,7 @@ import urllib from Crypto.Cipher import ARC4 -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp @@ -81,7 +81,7 @@ class TurbobitNet(SimpleHoster): if m is None: self.error(_("captcha")) captcha_url = m.group(1) - inputs['captcha_response'] = self.captcha.decrypt_image(captcha_url) + inputs['captcha_response'] = self.captcha.decrypt(captcha_url) self.log_debug(inputs) self.html = self.load(self.url, post=inputs) diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 27b5843d9..1cd4ec853 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -60,7 +60,7 @@ class UlozTo(SimpleHoster): #: Old version - last seen 9.12.2013 self.log_debug('Using "old" version') - captcha_value = self.captcha.decrypt_image("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) + captcha_value = self.captcha.decrypt("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) self.log_debug("CAPTCHA ID: " + inputs['captcha_id'] + ", CAPTCHA VALUE: " + captcha_value) inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) @@ -73,7 +73,7 @@ class UlozTo(SimpleHoster): self.log_debug("xapca = " + str(xapca)) data = json_loads(xapca) - captcha_value = self.captcha.decrypt_image(str(data['image'])) + captcha_value = self.captcha.decrypt(str(data['image'])) self.log_debug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: " + str(data['salt']), "CAPTCHA VALUE: " + captcha_value) inputs.update({'timestamp': data['timestamp'], 'salt': data['salt'], 'hash': data['hash'], 'captcha_value': captcha_value}) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index 58e3b685a..69adedeb1 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -59,7 +59,7 @@ class UloziskoSk(SimpleHoster): self.error(_("CAPTCHA_PATTERN not found")) captcha_url = urlparse.urljoin("http://www.ulozisko.sk", m.group(1)) - captcha = self.captcha.decrypt_image(captcha_url, cookies=True) + captcha = self.captcha.decrypt(captcha_url, cookies=True) self.log_debug("CAPTCHA_URL:" + captcha_url + ' CAPTCHA:' + captcha) diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 96b2fb031..1c1a0bd2b 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -65,7 +65,7 @@ class UnibytesCom(SimpleHoster): self.wait(m.group(1) if m else 60, False) elif last_step in ("captcha", "last"): - post_data['captcha'] = self.captcha.decrypt_image(urlparse.urljoin(domain, "/captcha.jpg")) + post_data['captcha'] = self.captcha.decrypt(urlparse.urljoin(domain, "/captcha.jpg")) else: self.fail(_("No valid captcha code entered")) diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py index 5b2eed554..7d3a6952a 100644 --- a/module/plugins/hoster/UploadableCh.py +++ b/module/plugins/hoster/UploadableCh.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index c5f3cd8ad..f77c6a483 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -5,7 +5,7 @@ import time import urlparse from module.network.RequestFactory import getURL as get_url -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/UploadheroCom.py b/module/plugins/hoster/UploadheroCom.py index 8a0b3a032..69318fb4b 100644 --- a/module/plugins/hoster/UploadheroCom.py +++ b/module/plugins/hoster/UploadheroCom.py @@ -44,7 +44,7 @@ class UploadheroCom(SimpleHoster): if m is None: self.error(_("Captcha not found")) - captcha = self.captcha.decrypt_image(urlparse.urljoin("http://uploadhero.co", m.group(1))) + captcha = self.captcha.decrypt(urlparse.urljoin("http://uploadhero.co", m.group(1))) self.html = self.load(pyfile.url, get={'code': captcha}) diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index 49578aafe..21c359cc2 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 7df13a075..aa64c1903 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -5,7 +5,7 @@ import urllib import BeautifulSoup -from module.plugins.internal.ReCaptcha import ReCaptcha +from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py deleted file mode 100644 index d14babb51..000000000 --- a/module/plugins/internal/AdYouLike.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.common.json_layer import json_loads -from module.plugins.internal.CaptchaService import CaptchaService - - -class AdYouLike(CaptchaService): - __name__ = "AdYouLike" - __type__ = "captcha" - __version__ = "0.07" - __status__ = "stable" - - __description__ = """AdYouLike captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' - CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' - - - def detect_key(self, data=None): - html = data or self.retrieve_data() - - m = re.search(self.AYL_PATTERN, html) - n = re.search(self.CALLBACK_PATTERN, html) - if m and n: - self.key = (m.group(1).strip(), n.group(1).strip()) - self.log_debug("Ayl: %s | Callback: %s" % self.key) - return self.key #: Key is the tuple(ayl, callback) - else: - self.log_warning(_("Ayl or callback pattern not found")) - return None - - - def challenge(self, key=None, data=None): - ayl, callback = key or self.retrieve_key(data) - - #: {'adyoulike':{'key':"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - #: 'all':{'element_id':"ayl_private_cap_92300",'lang':"fr",'env':"prod"}} - ayl = json_loads(ayl) - - html = self.plugin.load("http://api-ayl.appspot.com/challenge", - get={'key' : ayl['adyoulike']['key'], - 'env' : ayl['all']['env'], - 'callback': callback}) - try: - challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) - - except AttributeError: - self.fail(_("AdYouLike challenge pattern not found")) - - self.log_debug("Challenge: %s" % challenge) - - return self.result(ayl, challenge), challenge - - - def result(self, server, challenge): - #: Adyoulike.g._jsonp_5579316662423138 - #: ({'translations':{'fr':{'instructions_visual':"Recopiez « Soonnight » ci-dessous :"}}, - #: 'site_under':true,'clickable':true,'pixels':{'VIDEO_050':[],'DISPLAY':[],'VIDEO_000':[],'VIDEO_100':[], - #: 'VIDEO_025':[],'VIDEO_075':[]},'medium_type':"image/adyoulike", - #: 'iframes':{'big':""},'shares':{},'id':256, - #: 'token':"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1",'formats':{'small':{'y':300,'x':0,'w':300,'h':60}, - #: 'big':{'y':0,'x':0,'w':300,'h':250},'hover':{'y':440,'x':0,'w':300,'h':60}}, - #: 'tid':"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) - - if isinstance(server, basestring): - server = json_loads(server) - - if isinstance(challenge, basestring): - challenge = json_loads(challenge) - - try: - instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] - result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() - - except AttributeError: - self.fail(_("AdYouLike result not found")) - - result = {'_ayl_captcha_engine' : "adyoulike", - '_ayl_env' : server['all']['env'], - '_ayl_tid' : challenge['tid'], - '_ayl_token_challenge': challenge['token'], - '_ayl_response' : response} - - self.log_debug("Result: %s" % result) - - return result diff --git a/module/plugins/internal/AdsCaptcha.py b/module/plugins/internal/AdsCaptcha.py deleted file mode 100644 index f487042e2..000000000 --- a/module/plugins/internal/AdsCaptcha.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- - -import random -import re - -from module.plugins.internal.CaptchaService import CaptchaService - - -class AdsCaptcha(CaptchaService): - __name__ = "AdsCaptcha" - __type__ = "captcha" - __version__ = "0.10" - __status__ = "stable" - - __description__ = """AdsCaptcha captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] - - - CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?CaptchaId=(\d+)' - PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?PublicKey=([\w-]+)' - - - def detect_key(self, data=None): - html = data or self.retrieve_data() - - m = re.search(self.PUBLICKEY_PATTERN, html) - n = re.search(self.CAPTCHAID_PATTERN, html) - if m and n: - self.key = (m.group(1).strip(), n.group(1).strip()) #: Key is the tuple(PublicKey, CaptchaId) - self.log_debug("Key: %s | ID: %s" % self.key) - return self.key - else: - self.log_warning(_("Key or id pattern not found")) - return None - - - def challenge(self, key=None, data=None): - PublicKey, CaptchaId = key or self.retrieve_key(data) - - html = self.plugin.load("http://api.adscaptcha.com/Get.aspx", - get={'CaptchaId': CaptchaId, - 'PublicKey': PublicKey}) - try: - challenge = re.search("challenge: '(.+?)',", html).group(1) - server = re.search("server: '(.+?)',", html).group(1) - - except AttributeError: - self.fail(_("AdsCaptcha challenge pattern not found")) - - self.log_debug("Challenge: %s" % challenge) - - return self.result(server, challenge), challenge - - - def result(self, server, challenge): - result = self.decrypt_image("%sChallenge.aspx" % server, - get={'cid': challenge, 'dummy': random.random()}, - cookies=True, - input_type="jpg") - - self.log_debug("Result: %s" % result) - - return result diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index af7f66ed5..942021f26 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- +import time + from module.plugins.internal.Plugin import Plugin class Captcha(Plugin): __name__ = "Captcha" __type__ = "captcha" - __version__ = "0.01" + __version__ = "0.02" __status__ = "stable" __description__ = """Base anti-captcha plugin""" @@ -35,13 +37,21 @@ class Captcha(Plugin): pass - def decrypt_image(self, url, get={}, post={}, ref=False, cookies=False, decode=False, - input_type='png', output_type='textual', try_ocr=True): - image = self.load(url, get=get, post=post, ref=ref, cookies=cookies, decode=decode) - return self.decrypt(image, input_type, output_type, try_ocr) + def recognize(self, image): + """ + Extend to build your custom anti-captcha ocr + """ + pass + + + def decrypt(self, url, get={}, post={}, ref=False, cookies=False, decode=False, + input_type='png', output_type='textual', ocr=True): + img = self.load(url, get=get, post=post, ref=ref, cookies=cookies, decode=decode) + return self._decrypt(img, input_type, output_type, ocr) - def decrypt(self, data, input_type='png', output_type='textual', try_ocr=True): + #@TODO: Definitely dhoose a better name for this method! + def _decrypt(self, raw, input_type='png', output_type='textual', ocr=None): """ Loads a captcha and decrypts it with ocr, plugin, user input @@ -53,56 +63,53 @@ class Captcha(Plugin): :param output_type: 'textual' if text is written on the captcha\ or 'positional' for captcha where the user have to click\ on a specific region on the captcha - :param try_ocr: if True, ocr is not used + :param ocr: if True, ocr is not used :return: result of decrypting """ - id = ("%.2f" % time.time())[-6:].replace(".", "") + 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 isinstance(ocr, basestring): + OCR = self.pyload.pluginManager.loadClass("captcha", ocr) #: Rename `captcha` to `ocr` in 0.4.10 - with open(os.path.join("tmp", "tmpCaptcha_%s_%s.%s" % (self.plugin.__name__, id, input_type)), "wb") as tmpCaptcha: - tmpCaptcha.write(img) + if self.plugin.pyfile.abort: + self.abort() - has_plugin = self.plugin.__name__ in self.pyload.pluginManager.ocrPlugins + result = OCR(self.plugin.pyfile).recognize(tmp_img.name) - if self.pyload.captcha: - Ocr = self.pyload.pluginManager.loadClass("ocr", self.plugin.__name__) - else: - Ocr = None + else: + result = self.recognize(tmp_img.name) - if Ocr and try_ocr: - time.sleep(random.randint(3000, 5000) / 1000.0) - if self.pyfile.abort: - self.abort() + else: + captchaManager = self.pyload.captchaManager - ocr = Ocr(self.pyfile) - result = ocr.get_captcha(tmpCaptcha.name) - else: - captchaManager = self.pyload.captchaManager - task = captchaManager.newTask(img, input_type, tmpCaptcha.name, output_type) - self.task = task - captchaManager.handleCaptcha(task) + try: + self.task = captchaManager.newTask(img, input_type, tmp_img.name, output_type) + captchaManager.handleCaptcha(self.task) - while task.isWaiting(): - if self.pyfile.abort: - captchaManager.removeTask(task) - self.abort() - time.sleep(1) + while self.task.isWaiting(): + if self.plugin.pyfile.abort: + self.abort() + time.sleep(1) + finally: + captchaManager.removeTask(self.task) - captchaManager.removeTask(task) + if self.task.error: + self.fail(task.error) - if task.error and has_plugin: #: Ignore default error message since the user could use try_ocr - self.fail(_("Pil and tesseract not installed and no Client connected for captcha decrypting")) - elif task.error: - self.fail(task.error) - elif not task.result: - self.fail(_("No captcha result obtained in appropiate time by any of the plugins")) + elif not self.task.result: + self.fail(_("No captcha result obtained in appropiate time by any of the plugins")) - result = task.result - self.log_debug("Received captcha result: %s" % result) + result = task.result + self.log_debug("Received captcha result: %s" % result) #@TODO: Remove from here? if not self.pyload.debug: try: - os.remove(tmpCaptcha.name) + os.remove(tmp_img.name) except Exception: pass diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py index ee5571f77..5c22866c8 100644 --- a/module/plugins/internal/OCR.py +++ b/module/plugins/internal/OCR.py @@ -20,7 +20,7 @@ from module.utils import save_join as fs_join class OCR(Plugin): __name__ = "OCR" __type__ = "ocr" - __version__ = "0.12" + __version__ = "0.13" __status__ = "stable" __description__ = """OCR base plugin""" @@ -133,7 +133,7 @@ class OCR(Plugin): pass - def get_captcha(self, name): + def recognize(self, name): raise NotImplementedError diff --git a/module/plugins/internal/ReCaptcha.py b/module/plugins/internal/ReCaptcha.py deleted file mode 100644 index b4f9ef1eb..000000000 --- a/module/plugins/internal/ReCaptcha.py +++ /dev/null @@ -1,197 +0,0 @@ -# -*- coding: utf-8 -*- - -import random -import re -import time -import urlparse - -from base64 import b64encode - -from module.plugins.internal.CaptchaService import CaptchaService - - -class ReCaptcha(CaptchaService): - __name__ = "ReCaptcha" - __type__ = "captcha" - __version__ = "0.18" - __status__ = "stable" - - __description__ = """ReCaptcha captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("zapp-brannigan", "fuerst.reinje@web.de")] - - - KEY_V1_PATTERN = r'(?:recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=|Recaptcha\.create\s*\(\s*["\'])([\w-]+)' - KEY_V2_PATTERN = r'(?:data-sitekey=["\']|["\']sitekey["\']:\s*["\'])([\w-]+)' - - - def detect_key(self, data=None): - html = data or self.retrieve_data() - - m = re.search(self.KEY_V2_PATTERN, html) or re.search(self.KEY_V1_PATTERN, html) - if m: - self.key = m.group(1).strip() - self.log_debug("Key: %s" % self.key) - return self.key - else: - self.log_warning(_("Key pattern not found")) - return None - - - def challenge(self, key=None, data=None, version=None): - key = key or self.retrieve_key(data) - - if version in (1, 2): - return getattr(self, "_challenge_v%s" % version)(key) - - else: - return self.challenge(key, - version=2 if re.search(self.KEY_V2_PATTERN, html or self.retrieve_data()) else 1) - - - def _challenge_v1(self, key): - html = self.plugin.load("http://www.google.com/recaptcha/api/challenge", - get={'k': key}) - try: - challenge = re.search("challenge : '(.+?)',", html).group(1) - server = re.search("server : '(.+?)',", html).group(1) - - except AttributeError: - self.fail(_("ReCaptcha challenge pattern not found")) - - self.log_debug("Challenge: %s" % challenge) - - return self.result(server, challenge, key) - - - def result(self, server, challenge, key): - self.plugin.load("http://www.google.com/recaptcha/api/js/recaptcha.js") - html = self.plugin.load("http://www.google.com/recaptcha/api/reload", - get={'c' : challenge, - 'k' : key, - 'reason': "i", - 'type' : "image"}) - - try: - challenge = re.search('\(\'(.+?)\',',html).group(1) - - except AttributeError: - self.fail(_("ReCaptcha second challenge pattern not found")) - - self.log_debug("Second challenge: %s" % challenge) - result = self.decrypt("%simage" % server, - get={'c': challenge}, - cookies=True, - input_type="jpg", - try_ocr=False) - - self.log_debug("Result: %s" % result) - - return result, challenge - - - def _collect_api_info(self): - html = self.plugin.load("http://www.google.com/recaptcha/api.js") - a = re.search(r'po.src = \'(.*?)\';', html).group(1) - vers = a.split("/")[5] - - self.log_debug("API version: %s" % vers) - - language = a.split("__")[1].split(".")[0] - - self.log_debug("API language: %s" % language) - - html = self.plugin.load("https://apis.google.com/js/api.js") - b = re.search(r'"h":"(.*?)","', html).group(1) - jsh = b.decode('unicode-escape') - - self.log_debug("API jsh-string: %s" % jsh) - - return vers, language, jsh - - - def _prepare_time_and_rpc(self): - self.plugin.load("http://www.google.com/recaptcha/api2/demo") - - millis = int(round(time.time() * 1000)) - - self.log_debug("Time: %s" % millis) - - rand = random.randint(1, 99999999) - a = "0.%s" % str(rand * 2147483647) - rpc = int(100000000 * float(a)) - - self.log_debug("Rpc-token: %s" % rpc) - - return millis, rpc - - - def _challenge_v2(self, key, parent=None): - if parent is None: - try: - parent = urlparse.urljoin("http://", urlparse.urlparse(self.plugin.pyfile.url).netloc) - - except Exception: - parent = "" - - botguardstring = "!A" - vers, language, jsh = self._collect_api_info() - millis, rpc = self._prepare_time_and_rpc() - - html = self.plugin.load("https://www.google.com/recaptcha/api2/anchor", - get={'k' : key, - 'hl' : language, - 'v' : vers, - 'usegapi' : "1", - 'jsh' : "%s#id=IO_%s" % (jsh, millis), - 'parent' : parent, - 'pfname' : "", - 'rpctoken': rpc}) - - token1 = re.search(r'id="recaptcha-token" value="(.*?)">', html) - self.log_debug("Token #1: %s" % token1.group(1)) - - html = self.plugin.load("https://www.google.com/recaptcha/api2/frame", - get={'c' : token1.group(1), - 'hl' : language, - 'v' : vers, - 'bg' : botguardstring, - 'k' : key, - 'usegapi': "1", - 'jsh' : jsh}, - decode="unicode-escape") - - token2 = re.search(r'"finput","(.*?)",', html) - self.log_debug("Token #2: %s" % token2.group(1)) - - token3 = re.search(r'"rresp","(.*?)",', html) - self.log_debug("Token #3: %s" % token3.group(1)) - - millis_captcha_loading = int(round(time.time() * 1000)) - captcha_response = self.decrypt_image("https://www.google.com/recaptcha/api2/payload", - get={'c':token3.group(1), 'k':key}, - cookies=True, - try_ocr=False) - response = b64encode('{"response":"%s"}' % captcha_response) - - self.log_debug("Result: %s" % response) - - timeToSolve = int(round(time.time() * 1000)) - millis_captcha_loading - timeToSolveMore = timeToSolve + int(float("0." + str(random.randint(1, 99999999))) * 500) - - html = self.plugin.load("https://www.google.com/recaptcha/api2/userverify", - post={'k' : key, - 'c' : token3.group(1), - 'response': response, - 't' : timeToSolve, - 'ct' : timeToSolveMore, - 'bg' : botguardstring}) - - token4 = re.search(r'"uvresp","(.*?)",', html) - self.log_debug("Token #4: %s" % token4.group(1)) - - result = token4.group(1) - - return result, None diff --git a/module/plugins/internal/SolveMedia.py b/module/plugins/internal/SolveMedia.py deleted file mode 100644 index ce4ebb007..000000000 --- a/module/plugins/internal/SolveMedia.py +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.Plugin import Fail -from module.plugins.internal.CaptchaService import CaptchaService - - -class SolveMedia(CaptchaService): - __name__ = "SolveMedia" - __type__ = "captcha" - __version__ = "0.15" - __status__ = "stable" - - __description__ = """SolveMedia captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] - - - KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' - - - def detect_key(self, data=None): - html = data or self.retrieve_data() - - m = re.search(self.KEY_PATTERN, html) - if m: - self.key = m.group(1).strip() - self.log_debug("Key: %s" % self.key) - return self.key - else: - self.log_warning(_("Key pattern not found") - return None - - - def challenge(self, key=None, data=None): - key = key or self.retrieve_key(data) - - html = self.plugin.load("http://api.solvemedia.com/papi/challenge.noscript", - get={'k': key}) - - for i in xrange(1, 11): - try: - magic = re.search(r'name="magic" value="(.+?)"', html).group(1) - - except AttributeError: - self.log_warning(_("Magic pattern not found") - magic = None - - try: - challenge = re.search(r'', - html).group(1) - - except AttributeError: - self.fail(_("SolveMedia challenge pattern not found")) - - else: - self.log_debug("Challenge: %s" % challenge) - - try: - result = self.result("http://api.solvemedia.com/papi/media", challenge) - - except Fail, e: - self.log_warning(e) - self.plugin.invalidCaptcha() - result = None - - html = self.plugin.load("http://api.solvemedia.com/papi/verify.noscript", - post={'adcopy_response' : result, - 'k' : key, - 'l' : "en", - 't' : "img", - 's' : "standard", - 'magic' : magic, - 'adcopy_challenge': challenge, - 'ref' : self.plugin.pyfile.url}) - try: - redirect = re.search(r'URL=(.+?)">', html).group(1) - - except AttributeError: - self.fail(_("SolveMedia verify pattern not found")) - - else: - if "error" in html: - self.log_warning(_("Captcha code was invalid")) - self.log_debug("Retry #%d" % i) - html = self.plugin.load(redirect) - else: - break - - else: - self.fail(_("SolveMedia max retries exceeded")) - - return result, challenge - - - def result(self, server, challenge): - result = self.decrypt_image(server, - get={'c': challenge}, - cookies=True, - input_type="gif") - - self.log_debug("Result: %s" % result) - - return result diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index ec9a18a48..18a50a6b0 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -4,8 +4,8 @@ import pycurl import random import re -from module.plugins.internal.ReCaptcha import ReCaptcha -from module.plugins.internal.SolveMedia import SolveMedia +from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.captcha.SolveMedia import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, seconds_to_midnight from module.utils import html_unescape @@ -221,7 +221,7 @@ class XFSHoster(SimpleHoster): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: captcha_url = m.group(1) - inputs['code'] = self.captcha.decrypt_image(captcha_url) + inputs['code'] = self.captcha.decrypt(captcha_url) return m = re.search(self.CAPTCHA_BLOCK_PATTERN, self.html, re.S) -- cgit v1.2.3