diff options
Diffstat (limited to 'module/plugins/crypter/ShareLinksBiz.py')
-rw-r--r-- | module/plugins/crypter/ShareLinksBiz.py | 87 |
1 files changed, 52 insertions, 35 deletions
diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 816842216..d2e8138f6 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -9,23 +9,27 @@ from module.plugins.Crypter import Crypter class ShareLinksBiz(Crypter): - __name__ = "ShareLinksBiz" - __type__ = "crypter" - __pattern__ = r'(?P<base>http://(?:www\.)?(share-links|s2l)\.biz)/(?P<id>_?[0-9a-z]+)(/.*)?' - __version__ = "1.13" + __name__ = "ShareLinksBiz" + __type__ = "crypter" + __version__ = "1.14" + + __pattern__ = r'http://(?:www\.)?(share-links|s2l)\.biz/(?P<ID>_?\w+)' + __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + __description__ = """Share-Links.biz decrypter plugin""" - __author_name__ = "fragonib" - __author_mail__ = "fragonib[AT]yahoo[DOT]es" + __license__ = "GPLv3" + __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es")] + def setup(self): self.baseUrl = None self.fileId = None self.package = None - self.html = None self.captcha = False - def decrypt(self, pyfile): + def decrypt(self, pyfile): # Init self.initFile(pyfile) @@ -59,37 +63,43 @@ class ShareLinksBiz(Crypter): # Pack self.packages = [(package_name, package_links, package_folder)] + def initFile(self, pyfile): url = pyfile.url if 's2l.biz' in url: url = self.load(url, just_header=True)['location'] - self.baseUrl = re.match(self.__pattern__, url).group(1) - self.fileId = re.match(self.__pattern__, url).group('id') + self.baseUrl = "http://www.%s.biz" % re.match(self.__pattern__, url).group(1) + self.fileId = re.match(self.__pattern__, url).group('ID') self.package = pyfile.package() + def isOnline(self): if "No usable content was found" in self.html: self.logDebug("File not found") return False return True + def isPasswordProtected(self): if re.search(r'''<form.*?id="passwordForm".*?>''', self.html): self.logDebug("Links are protected") return True return False + def isCaptchaProtected(self): if '<map id="captchamap"' in self.html: self.logDebug("Links are captcha protected") return True return False + def unblockServer(self): imgs = re.findall(r"(/template/images/.*?\.gif)", self.html) for img in imgs: self.load(self.baseUrl + img) + def unlockPasswordProtection(self): password = self.getPassword() self.logDebug("Submitting password [%s] for protected links" % password) @@ -97,6 +107,7 @@ class ShareLinksBiz(Crypter): url = self.baseUrl + '/' + self.fileId self.html = self.load(url, post=post, decode=True) + def unlockCaptchaProtection(self): # Get captcha map captchaMap = self._getCaptchaMap() @@ -112,14 +123,12 @@ class ShareLinksBiz(Crypter): # Resolve captcha href = self._resolveCoords(coords, captchaMap) if href is None: - self.logDebug("Invalid captcha resolving, retrying") self.invalidCaptcha() - self.setWait(5, False) - self.wait() - self.retry() + self.retry(wait_time=5) url = self.baseUrl + href self.html = self.load(url, decode=True) + def _getCaptchaMap(self): mapp = {} for m in re.finditer(r'<area shape="rect" coords="(.*?)" href="(.*?)"', self.html): @@ -128,34 +137,34 @@ class ShareLinksBiz(Crypter): mapp[rect] = href return mapp + def _resolveCoords(self, coords, captchaMap): x, y = coords - for rect, href in captchaMap.items(): + for rect, href in captchaMap.iteritems(): x1, y1, x2, y2 = rect if (x >= x1 and x <= x2) and (y >= y1 and y <= y2): return href + def handleErrors(self): if "The inserted password was wrong" in self.html: 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 "Your choice was wrong" in self.html: - self.logDebug("Invalid captcha, retrying") self.invalidCaptcha() - self.setWait(5) - self.wait() - self.retry() + self.retry(wait_time=5) else: self.correctCaptcha() + def getPackageInfo(self): name = folder = None # Extract from web package header title_re = r'<h2><img.*?/>(.*)</h2>' - m = re.search(title_re, self.html, re.DOTALL) + m = re.search(title_re, self.html, re.S) if m is not None: title = m.group(1).strip() if 'unnamed' not in title: @@ -171,38 +180,45 @@ class ShareLinksBiz(Crypter): # Return package info return name, folder + def handleWebLinks(self): package_links = [] self.logDebug("Handling Web links") #@TODO: Gather paginated web links - pattern = r"javascript:_get\('(.*?)', \d+, ''\)" + pattern = r'javascript:_get\(\'(.*?)\', \d+, \'\'\)' ids = re.findall(pattern, self.html) self.logDebug("Decrypting %d Web links" % len(ids)) for i, ID in enumerate(ids): try: self.logDebug("Decrypting Web link %d, [%s]" % (i + 1, ID)) + dwLink = self.baseUrl + "/get/lnk/" + ID - response = self.load(dwLink) - code = re.search(r'frm/(\d+)', response).group(1) + res = self.load(dwLink) + + code = re.search(r'frm/(\d+)', res).group(1) fwLink = self.baseUrl + "/get/frm/" + code - response = self.load(fwLink) - jscode = re.search(r'<script language="javascript">\s*eval\((.*)\)\s*</script>', response, - re.DOTALL).group(1) + res = self.load(fwLink) + + jscode = re.search(r'<script language="javascript">\s*eval\((.*)\)\s*</script>', res, re.S).group(1) jscode = self.js.eval("f = %s" % jscode) jslauncher = "window=''; parent={frames:{Main:{location:{href:''}}},location:''}; %s; parent.frames.Main.location.href" + dlLink = self.js.eval(jslauncher % jscode) + self.logDebug("JsEngine returns value [%s] for redirection link" % dlLink) + package_links.append(dlLink) except Exception, detail: self.logDebug("Error decrypting Web link [%s], %s" % (ID, detail)) return package_links + def handleContainers(self): package_links = [] self.logDebug("Handling Container links") - pattern = r"javascript:_get\('(.*?)', 0, '(rsdf|ccf|dlc)'\)" + pattern = r'javascript:_get\(\'(.*?)\', 0, \'(rsdf|ccf|dlc)\'\)' containersLinks = re.findall(pattern, self.html) self.logDebug("Decrypting %d Container links" % len(containersLinks)) for containerLink in containersLinks: @@ -210,6 +226,7 @@ class ShareLinksBiz(Crypter): package_links.append(link) return package_links + def handleCNL2(self): package_links = [] self.logDebug("Handling CNL2 links") @@ -219,16 +236,16 @@ class ShareLinksBiz(Crypter): (crypted, jk) = self._getCipherParams() 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): + def _getCipherParams(self): # Request CNL2 - code = re.search(r'ClicknLoad.swf\?code=(.*?)"', self.html).group(1) - url = "%s/get/cnl2/%s" % (self.baseUrl, code) - response = self.load(url) - params = response.split(";;") + code = re.search(r'ClicknLoad.swf\?code=(.*?)"', self.html).group(1) + url = "%s/get/cnl2/%s" % (self.baseUrl, code) + res = self.load(url) + params = res.split(";;") # Get jk strlist = list(base64.standard_b64decode(params[1])) @@ -243,8 +260,8 @@ class ShareLinksBiz(Crypter): # Log and return return crypted, jk - def _getLinks(self, crypted, jk): + def _getLinks(self, crypted, jk): # Get key jreturn = self.js.eval("%s f()" % jk) self.logDebug("JsEngine returns value [%s]" % jreturn) |