summaryrefslogtreecommitdiffstats
path: root/module/plugins/crypter/NCryptIn.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-07-21 15:03:21 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-07-21 15:03:21 +0200
commit4b61d36bf18931df0a9720047b3619ce245f8a1b (patch)
treefa6214ca6c85eb547dfe7de1ec7502ff3ce71793 /module/plugins/crypter/NCryptIn.py
parentNormalize line endings to avoid line endings merge conflicts (diff)
downloadpyload-4b61d36bf18931df0a9720047b3619ce245f8a1b.tar.xz
Fixed PEP 8 violations in Crypters
Diffstat (limited to 'module/plugins/crypter/NCryptIn.py')
-rw-r--r--module/plugins/crypter/NCryptIn.py87
1 files changed, 44 insertions, 43 deletions
diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py
index 821636821..6e0c35e92 100644
--- a/module/plugins/crypter/NCryptIn.py
+++ b/module/plugins/crypter/NCryptIn.py
@@ -1,17 +1,19 @@
# -*- coding: utf-8 -*-
-from Crypto.Cipher import AES
-from module.plugins.Crypter import Crypter
-from module.plugins.ReCaptcha import ReCaptcha
import base64
import binascii
import re
+from Crypto.Cipher import AES
+from module.plugins.Crypter import Crypter
+from module.plugins.ReCaptcha import ReCaptcha
+
+
class NCryptIn(Crypter):
__name__ = "NCryptIn"
__type__ = "crypter"
__pattern__ = r"http://(?:www\.)?ncrypt.in/folder-([^/\?]+)"
- __version__ = "1.22"
+ __version__ = "1.23"
__description__ = """NCrypt.in Crypter Plugin"""
__author_name__ = ("fragonib")
__author_mail__ = ("fragonib[AT]yahoo[DOT]es")
@@ -19,7 +21,7 @@ class NCryptIn(Crypter):
# Constants
_JK_KEY_ = "jk"
_CRYPTED_KEY_ = "crypted"
-
+
def setup(self):
self.html = None
self.cleanedHtml = None
@@ -27,16 +29,16 @@ class NCryptIn(Crypter):
self.package = None
def decrypt(self, pyfile):
-
+
# Init
self.package = pyfile.package()
-
+
# Request package
self.html = self.load(self.pyfile.url)
self.cleanedHtml = self.removeCrap(self.html)
if not self.isOnline():
self.offline()
-
+
# Check for protection
if self.isProtected():
self.html = self.unlockProtection()
@@ -50,13 +52,13 @@ class NCryptIn(Crypter):
package_links = []
package_links.extend(self.handleWebLinks())
package_links.extend(self.handleContainers())
- package_links.extend(self.handleCNL2())
+ package_links.extend(self.handleCNL2())
package_links = self.removeContainers(package_links)
package_links = set(package_links)
# Pack
self.packages = [(package_name, package_links, folder_name)]
-
+
def removeCrap(self, content):
patterns = (r'(type="hidden".*?(name=".*?")?.*?value=".*?")',
r'display:none;">(.*?)</(div|span)>',
@@ -67,8 +69,8 @@ class NCryptIn(Crypter):
content = re.sub(rexpr, "", content)
return content
- def removeContainers(self,package_links):
- tmp_package_links = package_links[:]
+ def removeContainers(self, package_links):
+ tmp_package_links = package_links[:]
for link in tmp_package_links:
self.logDebug(link)
if ".dlc" in link or ".ccf" in link or ".rsdf" in link:
@@ -80,18 +82,18 @@ class NCryptIn(Crypter):
else:
return tmp_package_links
- def isOnline(self):
+ def isOnline(self):
if "Your folder does not exist" in self.cleanedHtml:
self.logDebug("File not found")
return False
return True
-
+
def isProtected(self):
if re.search(r'''<form.*?name.*?protected.*?>''', self.cleanedHtml):
self.logDebug("Links are protected")
return True
return False
-
+
def getPackageInfo(self):
title_re = r'<h2><span.*?class="arrow".*?>(?P<title>[^<]+).*?</span>.*?</h2>'
m = re.findall(title_re, self.html, re.DOTALL)
@@ -104,19 +106,19 @@ class NCryptIn(Crypter):
folder = self.package.folder
self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder))
return name, folder
-
+
def unlockProtection(self):
-
+
postData = {}
-
- form = re.search(r'''<form\ name="protected"(.*?)</form>''', self.cleanedHtml, re.DOTALL).group(1)
-
+
+ form = re.search(r'<form name="protected"(.*?)</form>', self.cleanedHtml, re.DOTALL).group(1)
+
# Submit package password
if "password" in form:
password = self.getPassword()
self.logDebug("Submitting password [%s] for protected links" % password)
postData['password'] = password
-
+
# Resolve anicaptcha
if "anicaptcha" in form:
self.captcha = True
@@ -125,10 +127,10 @@ class NCryptIn(Crypter):
captcha = self.decryptCaptcha("http://ncrypt.in" + captchaUri)
self.logDebug("Captcha resolved [%s]" % captcha)
postData['captcha'] = captcha
-
+
# Resolve recaptcha
if "recaptcha" in form:
- self.captcha = True
+ self.captcha = True
id = re.search(r'\?k=(.*?)"', form).group(1)
self.logDebug("Resolving ReCaptcha with key [%s]" % id)
recaptcha = ReCaptcha(self)
@@ -148,18 +150,17 @@ class NCryptIn(Crypter):
postData['circle.x'] = coords[0]
postData['circle.y'] = coords[1]
-
# Unlock protection
postData['submit_protected'] = 'Continue to folder '
return self.load(self.pyfile.url, post=postData)
-
+
def handleErrors(self):
-
+
if "This password is invalid!" in self.cleanedHtml:
self.logDebug("Incorrect password, please set right password on 'Edit package' form and retry")
- self.fail("Incorrect password, please set right password on 'Edit package' form and retry")
+ self.fail("Incorrect password, please set right password on 'Edit package' form and retry")
- if self.captcha:
+ if self.captcha:
if "The securitycheck was wrong!" in self.cleanedHtml:
self.logDebug("Invalid captcha, retrying")
self.invalidCaptcha()
@@ -170,24 +171,24 @@ class NCryptIn(Crypter):
def handleWebLinks(self):
package_links = []
self.logDebug("Handling Web links")
-
+
pattern = r"(http://ncrypt\.in/link-.*?=)"
links = re.findall(pattern, self.html)
self.logDebug("Decrypting %d Web links" % len(links))
for i, link in enumerate(links):
- self.logDebug("Decrypting Web link %d, %s" % (i+1, link))
+ self.logDebug("Decrypting Web link %d, %s" % (i + 1, link))
try:
url = link.replace("link-", "frame-")
link = self.load(url, just_header=True)['location']
package_links.append(link)
except Exception, detail:
- self.logDebug("Error decrypting Web link %s, %s" % (link, detail))
+ self.logDebug("Error decrypting Web link %s, %s" % (link, detail))
return package_links
-
+
def handleContainers(self):
package_links = []
self.logDebug("Handling Container links")
-
+
pattern = r"/container/(rsdf|dlc|ccf)/([a-z0-9]+)"
containersLinks = re.findall(pattern, self.html)
self.logDebug("Decrypting %d Container links" % len(containersLinks))
@@ -195,30 +196,30 @@ class NCryptIn(Crypter):
link = "http://ncrypt.in/container/%s/%s.%s" % (containerLink[0], containerLink[1], containerLink[0])
package_links.append(link)
return package_links
-
+
def handleCNL2(self):
package_links = []
self.logDebug("Handling CNL2 links")
-
+
if 'cnl2_output' in self.cleanedHtml:
try:
(vcrypted, vjk) = self._getCipherParams()
for (crypted, jk) in zip(vcrypted, vjk):
package_links.extend(self._getLinks(crypted, jk))
except:
- self.fail("Unable to decrypt CNL2 links")
+ self.fail("Unable to decrypt CNL2 links")
return package_links
-
+
def _getCipherParams(self):
-
- pattern = r'<input.*?name="%s".*?value="(.*?)"'
-
+
+ pattern = r'<input.*?name="%s".*?value="(.*?)"'
+
# Get jk
- jk_re = pattern % NCryptIn._JK_KEY_
+ jk_re = pattern % NCryptIn._JK_KEY_
vjk = re.findall(jk_re, self.html)
-
+
# Get crypted
- crypted_re = pattern % NCryptIn._CRYPTED_KEY_
+ crypted_re = pattern % NCryptIn._CRYPTED_KEY_
vcrypted = re.findall(crypted_re, self.html)
# Log and return