WordRider Home
Welcome! Log In Create A New Profile

Advanced

Fileserve 1.1.11 - plugin update (reCaptcha fixes)

Posted by RubinX 
Fileserve 1.1.11 - plugin update (reCaptcha fixes)
October 13, 2011 03:39PM
Hi, recently I found some problems with reCaptcha in Fileserve plugin:


1. Common problem: we have to wait extra time (6m:45s) after reCaptcha error (i.e. when typed code doesn't match pictrue).

Why exactly 6m:45s? The Plugin parse the string returned by the server which should contain correct number of seconds to wait. When everything is OK, the string looks like this: "25" (25 seconds to wait), but on error it contains: "fail404". The plugin interprets as 404 + 1 seconds = 6m:45s.


2. From time to time I got: "incorrect-captcha-sol" error (even if the typed code match exactly pictrue).

It may be caused by missing hidden parameter like: ppp = 301:
Language: HTML
<input type="text" id="recaptcha_response_field" class="textfield" size="30" name="recaptcha_response_field" /> <input type="hidden" id="recaptcha_challenge_field" name="recaptcha_challenge_field" /> <input type="hidden" id="recaptcha_shortencode_field" name="recaptcha_shortencode_field" value="ZuGVQ3K" /> <input type="hidden" name="ppp" value="301"/>
It should be pass to server in POST request data (http://www.fileserve.com/checkReCaptcha.php) as well.
recaptcha_challenge_field=...&recaptcha_response_field=...&recaptcha_shortencode_field=...&ppp=301
I'm not 100% sure if this is the real reason, but I tested updated plugin a few days, and it seems that it works fine now.


I made some fixes:
Index: src/fileserve/cz/vity/freerapid/plugins/services/fileserve/FileserveFilesRunner.java
===================================================================
--- src/fileserve/cz/vity/freerapid/plugins/services/fileserve/FileserveFilesRunner.java	(revision 3187)
+++ src/fileserve/cz/vity/freerapid/plugins/services/fileserve/FileserveFilesRunner.java	(working copy)
@@ -5,7 +5,10 @@
 import cz.vity.freerapid.plugins.webclient.FileState;
 import cz.vity.freerapid.plugins.webclient.utils.PlugUtils;
 import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.PostMethod;
 
+import java.util.ArrayList;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
 
@@ -49,6 +52,16 @@
             }
             String recaptcha = "http://www.google.com/recaptcha/api/challenge?k=" + matcher.group(1) + "&ajax=1&cachestop=0." + System.currentTimeMillis();
 
+            // Finding ALL (that's why I use dynamic array) extra hidden parameters (like: ppp = 301):
+            ArrayList extraHiddenParams = new ArrayList();
+            matcher = PlugUtils.matcher("]+name=\"([^\"]+)\"[^>]+value=\"([^\"]+)\"[^>]*>", getContentAsString().replaceFirst("(?s)^.*?(]+id=\"recaptcha_[^\"]+_field\"[^>]*>.*?)]+id=\"captchaAreaLabel\"[^>]*>.*$", "$1"));
+            while (matcher.find()) {
+                if (matcher.group(1).contains("recaptcha_shortencode_field"))
+                    continue; // skip standard field
+                extraHiddenParams.add(new NameValuePair(matcher.group(1), matcher.group(2)));
+            }
+            logger.info("Captcha extra hidden params (" + extraHiddenParams.size() + "): " + extraHiddenParams);
+
             do {
                 logger.info("Captcha URL: " + recaptcha);
                 getMethod = getGetMethod(recaptcha);
@@ -77,10 +90,14 @@
                         .setParameter("recaptcha_response_field", captcha)
                         .setParameter("recaptcha_shortencode_field", fileKey)
                         .toPostMethod();
+
+                // Adding extra hidden parameters (like: ppp = 301) to postMethod before request:
+                ((PostMethod)postMethod).addParameters(extraHiddenParams.toArray(new NameValuePair[0]));
+
                 if (!makeRedirectedRequest(postMethod)) {
                     throw new ServiceConnectionProblemException();
                 }
-            } while (!getContentAsString().contains("success"));
+            } while (!getContentAsString().matches(".*?success\"?\\s*:\\s*1.*?")); // {"success":1} -> OK, {"success":0,"error": ... } -> try again
 
             HttpMethod pMethod = getMethodBuilder().setAction(fileURL).setReferer(fileURL)
                     .setParameter("downloadLink", "wait")

Someone from dev team, please commit this patch to the main repository.

Thanks
Attachments:
open | download - fileserve.patch (2.8 KB)
Re: Fileserve 1.1.11 - plugin update (reCaptcha fixes)
October 13, 2011 05:14PM
Thanks for the patch, I've committed and released it.
Sorry, only registered users may post in this forum.

Click here to login