From bd365a1fed377665b00c3d815b096b7fa7a26374 Mon Sep 17 00:00:00 2001
From: zapp-brannigan <zapp-brannigan@users.noreply.github.com>
Date: Wed, 22 Apr 2015 09:20:38 +0200
Subject: [FilecryptCc.py] Fix circle captcha

Fix https://github.com/pyload/pyload/issues/1364
---
 module/plugins/crypter/FilecryptCc.py | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

(limited to 'module/plugins')

diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py
index baea8886b..7679e9446 100644
--- a/module/plugins/crypter/FilecryptCc.py
+++ b/module/plugins/crypter/FilecryptCc.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 # http://filecrypt.cc/Container/64E039F859.html
-
+import base64
 import binascii
 import re
 
@@ -14,7 +14,7 @@ from module.plugins.internal.CaptchaService import ReCaptcha
 class FilecryptCc(Crypter):
     __name__    = "FilecryptCc"
     __type__    = "crypter"
-    __version__ = "0.11"
+    __version__ = "0.12"
 
     __pattern__ = r'https?://(?:www\.)?filecrypt\.cc/Container/\w+'
 
@@ -39,7 +39,7 @@ class FilecryptCc(Crypter):
 
 
     def decrypt(self, pyfile):
-        self.html = self.load(pyfile.url)
+        self.html = self.load(pyfile.url, cookies=True)
 
         if "content notfound" in self.html:  #@NOTE: "content notfound" is NOT a typo
             self.offline()
@@ -64,7 +64,7 @@ class FilecryptCc(Crypter):
         self.logInfo(_("Found %d mirrors") % len(mirror))
 
         for i in mirror[1:]:
-            self.siteWithLinks = self.siteWithLinks + self.load(i).decode("utf-8", "replace")
+            self.siteWithLinks = self.siteWithLinks + self.load(i, cookies=True).decode("utf-8", "replace")
 
 
     def handlePasswordProtection(self):
@@ -78,7 +78,7 @@ class FilecryptCc(Crypter):
         if not password:
             self.fail(_("Please enter the password in package section and try again"))
 
-        self.html = self.load(self.pyfile.url, post={"password": password})
+        self.html = self.load(self.pyfile.url, post={"password": password}, cookies=True)
 
 
     def handleCaptcha(self):
@@ -94,17 +94,17 @@ class FilecryptCc(Crypter):
 
             self.siteWithLinks = self.load(self.pyfile.url,
                                            post={'recaptcha_response_field': captcha_code},
+                                           cookies=True,
                                            decode=True)
         elif m2:  #: circle captcha
             self.logDebug("Captcha-URL: %s" % m2.group(1))
 
-            captcha_code = self.decryptCaptcha(urljoin("http://filecrypt.cc", m2.group(1)),
-                                               forceUser=True,
-                                               imgtype="gif",
+            captcha_code = self.decryptCaptcha('https://www.filecrypt.cc/captcha/circle.php?c=abc',
                                                result_type='positional')
-
+                                               
             self.siteWithLinks = self.load(self.pyfile.url,
                                            post={'button.x': captcha_code[0], 'button.y': captcha_code[1]},
+                                           cookies=True,
                                            decode=True)
 
         else:
@@ -140,9 +140,9 @@ class FilecryptCc(Crypter):
             weblinks = re.findall(self.WEBLINK_PATTERN, self.siteWithLinks)
 
             for link in weblinks:
-                res   = self.load("http://filecrypt.cc/Link/%s.html" % link)
+                res   = self.load("http://filecrypt.cc/Link/%s.html" % link, cookies=True)
                 link2 = re.search('<iframe noresize src="(.*)"></iframe>', res)
-                res2  = self.load(link2.group(1), just_header=True)
+                res2  = self.load(link2.group(1), just_header=True, cookies=True)
                 self.links.append(res2['location'])
 
         except Exception, e:
@@ -165,14 +165,17 @@ class FilecryptCc(Crypter):
         # Get key
         key = binascii.unhexlify(str(jk))
 
+        # Decode crypted
+        crypted = base64.standard_b64decode(crypted)
+
         # Decrypt
         Key  = key
         IV   = key
         obj  = AES.new(Key, AES.MODE_CBC, IV)
-        text = obj.decrypt(crypted.decode('base64'))
+        text = obj.decrypt(crypted)
 
         # Extract links
-        text  = text.replace("\x00", "").replace("\r", "")
-        links = filter(bool, text.split('\n'))
+        links = filter(lambda x: x != "",
+                       text.replace("\x00", "").replace("\r", "").split("\n"))
 
         return links
-- 
cgit v1.2.3