From 5061a5e1034ee8a26203036fca00e264a62d6905 Mon Sep 17 00:00:00 2001
From: zapp-brannigan <zapp-brannigan@users.noreply.github.com>
Date: Fri, 30 Jan 2015 16:37:47 +0100
Subject: [CaptchaService.py] Fix ReCaptchaV2

Some small changes to make ReCaptchaV2 work again.
---
 module/plugins/internal/CaptchaService.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

(limited to 'module')

diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py
index c6e83fe7d..c7dab2a0a 100644
--- a/module/plugins/internal/CaptchaService.py
+++ b/module/plugins/internal/CaptchaService.py
@@ -12,7 +12,7 @@ from module.common.json_layer import json_loads
 
 class CaptchaService:
     __name__    = "CaptchaService"
-    __version__ = "0.20"
+    __version__ = "0.21"
 
     __description__ = """Base captcha service plugin"""
     __license__     = "GPLv3"
@@ -40,7 +40,7 @@ class CaptchaService:
 
 class ReCaptcha(CaptchaService):
     __name__    = "ReCaptcha"
-    __version__ = "0.11"
+    __version__ = "0.12"
 
     __description__ = """ReCaptcha captcha service plugin"""
     __license__     = "GPLv3"
@@ -190,32 +190,34 @@ class ReCaptcha(CaptchaService):
 
         token1 = re.search(r'id="recaptcha-token" value="(.*?)">', html)
         self.plugin.logDebug("ReCaptcha token #1: %s" % token1.group(1))
-
+                
         html = self.plugin.req.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.plugin.logDebug("ReCaptcha token #2: %s" % token2.group(1))
 
-        token3 = re.search(r'."asconf".\s.\s,"(.*?)".', html)
+        token3 = re.search(r'."asconf".\s,".*?".\s,"(.*?)".', html)
         self.plugin.logDebug("ReCaptcha token #3: %s" % token3.group(1))
 
         html = self.plugin.req.load("https://www.google.com/recaptcha/api2/reload",
-                                    post={'c'     : token2.group(1),
+                                    post={'k'     : key,
+                                          'c'     : token2.group(1),
                                           'reason': "fi",
                                           'fbg'   : token3.group(1)})
 
         token4 = re.search(r'"rresp","(.*?)",', html)
         self.plugin.logDebug("ReCaptcha token #4: %s" % token4.group(1))
-
+        
         millis_captcha_loading = int(round(time.time() * 1000))
         captcha_response       = self.plugin.decryptCaptcha("https://www.google.com/recaptcha/api2/payload",
-                                                            get={'c':token4.group(1)}, forceUser=True)
+                                                            get={'c':token4.group(1), 'k':key}, forceUser=True)
         response               = b64encode('{"response":"%s"}' % captcha_response)
 
         self.plugin.logDebug("ReCaptcha result: %s" % response)
@@ -224,7 +226,8 @@ class ReCaptcha(CaptchaService):
         timeToSolveMore = timeToSolve + int(float("0." + str(randint(1, 99999999))) * 500)
 
         html = self.plugin.req.load("https://www.google.com/recaptcha/api2/userverify",
-                                    post={'c'       : token4.group(1),
+                                    post={'k'       : key,
+                                          'c'       : token4.group(1),
                                           'response': response,
                                           't'       : timeToSolve,
                                           'ct'      : timeToSolveMore,
-- 
cgit v1.2.3