diff options
Diffstat (limited to 'module/plugins/captcha/ReCaptcha.py')
-rw-r--r-- | module/plugins/captcha/ReCaptcha.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/module/plugins/captcha/ReCaptcha.py b/module/plugins/captcha/ReCaptcha.py index e2bd5e8ca..b30f110d4 100644 --- a/module/plugins/captcha/ReCaptcha.py +++ b/module/plugins/captcha/ReCaptcha.py @@ -1,19 +1,18 @@ # -*- coding: utf-8 -*- +import base64 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.19" + __version__ = "0.20" __status__ = "testing" __description__ = """ReCaptcha captcha service plugin""" @@ -52,7 +51,7 @@ class ReCaptcha(CaptchaService): def _challenge_v1(self, key): - html = self.plugin.load("http://www.google.com/recaptcha/api/challenge", + html = self.pyfile.plugin.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) try: challenge = re.search("challenge : '(.+?)',", html).group(1) @@ -67,8 +66,8 @@ class ReCaptcha(CaptchaService): 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", + self.pyfile.plugin.load("http://www.google.com/recaptcha/api/js/recaptcha.js") + html = self.pyfile.plugin.load("http://www.google.com/recaptcha/api/reload", get={'c' : challenge, 'k' : key, 'reason': "i", @@ -92,7 +91,7 @@ class ReCaptcha(CaptchaService): def _collect_api_info(self): - html = self.plugin.load("http://www.google.com/recaptcha/api.js") + html = self.pyfile.plugin.load("http://www.google.com/recaptcha/api.js") a = re.search(r'po.src = \'(.*?)\';', html).group(1) vers = a.split("/")[5] @@ -102,7 +101,7 @@ class ReCaptcha(CaptchaService): self.log_debug("API language: %s" % language) - html = self.plugin.load("https://apis.google.com/js/api.js") + html = self.pyfile.plugin.load("https://apis.google.com/js/api.js") b = re.search(r'"h":"(.*?)","', html).group(1) jsh = b.decode('unicode-escape') @@ -112,7 +111,7 @@ class ReCaptcha(CaptchaService): def _prepare_time_and_rpc(self): - self.plugin.load("http://www.google.com/recaptcha/api2/demo") + self.pyfile.plugin.load("http://www.google.com/recaptcha/api2/demo") millis = int(round(time.time() * 1000)) @@ -130,7 +129,7 @@ class ReCaptcha(CaptchaService): def _challenge_v2(self, key, parent=None): if parent is None: try: - parent = urlparse.urljoin("http://", urlparse.urlparse(self.plugin.pyfile.url).netloc) + parent = urlparse.urljoin("http://", urlparse.urlparse(self.pyfile.url).netloc) except Exception: parent = "" @@ -139,7 +138,7 @@ class ReCaptcha(CaptchaService): 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", + html = self.pyfile.plugin.load("https://www.google.com/recaptcha/api2/anchor", get={'k' : key, 'hl' : language, 'v' : vers, @@ -152,7 +151,7 @@ class ReCaptcha(CaptchaService): 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", + html = self.pyfile.plugin.load("https://www.google.com/recaptcha/api2/frame", get={'c' : token1.group(1), 'hl' : language, 'v' : vers, @@ -174,14 +173,14 @@ class ReCaptcha(CaptchaService): cookies=True, ocr=False, timeout=30) - response = b64encode('{"response":"%s"}' % captcha_response) + response = base64.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", + html = self.pyfile.plugin.load("https://www.google.com/recaptcha/api2/userverify", post={'k' : key, 'c' : token3.group(1), 'response': response, |