diff options
Diffstat (limited to 'module/plugins/container')
-rw-r--r-- | module/plugins/container/CCF.py | 44 | ||||
-rw-r--r-- | module/plugins/container/DLC.py | 72 | ||||
-rw-r--r-- | module/plugins/container/DLC_25.pyc | bin | 8346 -> 0 bytes | |||
-rw-r--r-- | module/plugins/container/DLC_26.pyc | bin | 8319 -> 0 bytes | |||
-rw-r--r-- | module/plugins/container/DLC_27.pyc | bin | 8243 -> 0 bytes | |||
-rw-r--r-- | module/plugins/container/LinkList.py | 71 | ||||
-rw-r--r-- | module/plugins/container/RSDF.py | 55 | ||||
-rw-r--r-- | module/plugins/container/TXT.py | 69 |
8 files changed, 195 insertions, 116 deletions
diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py index bca535175..235d5dc1d 100644 --- a/module/plugins/container/CCF.py +++ b/module/plugins/container/CCF.py @@ -2,42 +2,46 @@ from __future__ import with_statement +import MultipartPostHandler import re - -from os import makedirs -from os.path import exists -from urllib2 import build_opener - -from MultipartPostHandler import MultipartPostHandler +import urllib2 from module.plugins.Container import Container -from module.utils import save_join +from module.utils import fs_encode, save_join class CCF(Container): __name__ = "CCF" - __version__ = "0.20" + __type__ = "container" + __version__ = "0.23" - __pattern__ = r'.+\.ccf' + __pattern__ = r'.+\.ccf$' __description__ = """CCF container decrypter plugin""" __license__ = "GPLv3" - __authors__ = [("Willnix", "Willnix@pyload.org")] + __authors__ = [("Willnix", "Willnix@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")] def decrypt(self, pyfile): - infile = pyfile.url.replace("\n", "") + fs_filename = fs_encode(pyfile.url.strip()) + opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler) - opener = build_opener(MultipartPostHandler) - params = {"src": "ccf", - "filename": "test.ccf", - "upload": open(infile, "rb")} - tempdlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', params).read() + dlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', + {'src' : "ccf", + 'filename': "test.ccf", + 'upload' : open(fs_filename, "rb")}).read() download_folder = self.config['general']['download_folder'] + dlc_file = save_join(download_folder, "tmp_%s.dlc" % pyfile.name) + + try: + dlc = re.search(r'<dlc>(.+)</dlc>', dlc_content, re.S).group(1).decode('base64') + + except AttributeError: + self.fail(_("Container is corrupted")) - tempdlc_name = save_join(download_folder, "tmp_%s.dlc" % pyfile.name) - with open(tempdlc_name, "w") as tempdlc: - tempdlc.write(re.search(r'<dlc>(.*)</dlc>', tempdlc_content, re.S).group(1)) + with open(dlc_file, "w") as tempdlc: + tempdlc.write(dlc) - self.urls = [tempdlc_name] + self.urls = [dlc_file] diff --git a/module/plugins/container/DLC.py b/module/plugins/container/DLC.py new file mode 100644 index 000000000..ff2f0104a --- /dev/null +++ b/module/plugins/container/DLC.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re +import xml.dom.minidom + +from Crypto.Cipher import AES + +from module.plugins.Container import Container +from module.utils import decode, fs_encode + + +class DLC(Container): + __name__ = "DLC" + __type__ = "container" + __version__ = "0.24" + + __pattern__ = r'.+\.dlc$' + + __description__ = """DLC container decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de"), + ("Schnusch", "Schnusch@users.noreply.github.com"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + KEY = "cb99b5cbc24db398" + IV = "9bc24cb995cb8db3" + API_URL = "http://service.jdownloader.org/dlcrypt/service.php?srcType=dlc&destType=pylo&data=%s" + + + def decrypt(self, pyfile): + fs_filename = fs_encode(pyfile.url.strip()) + with open(fs_filename) as dlc: + data = dlc.read().strip() + + data += '=' * (-len(data) % 4) + + dlc_key = data[-88:] + dlc_data = data[:-88].decode('base64') + dlc_content = self.load(self.API_URL % dlc_key) + + try: + rc = re.search(r'<rc>(.+)</rc>', dlc_content, re.S).group(1).decode('base64') + + except AttributeError: + self.fail(_("Container is corrupted")) + + key = iv = AES.new(self.KEY, AES.MODE_CBC, self.IV).decrypt(rc) + + self.data = AES.new(key, AES.MODE_CBC, iv).decrypt(dlc_data).decode('base64') + self.packages = [(name or pyfile.name, links, name or pyfile.name) \ + for name, links in self.getPackages()] + + + def getPackages(self): + root = xml.dom.minidom.parseString(self.data).documentElement + content = root.getElementsByTagName("content")[0] + return self.parsePackages(content) + + + def parsePackages(self, startNode): + return [(decode(node.getAttribute("name")).decode('base64'), self.parseLinks(node)) \ + for node in startNode.getElementsByTagName("package")] + + + def parseLinks(self, startNode): + return [node.getElementsByTagName("url")[0].firstChild.data.decode('base64') \ + for node in startNode.getElementsByTagName("file")] diff --git a/module/plugins/container/DLC_25.pyc b/module/plugins/container/DLC_25.pyc Binary files differdeleted file mode 100644 index 409264902..000000000 --- a/module/plugins/container/DLC_25.pyc +++ /dev/null diff --git a/module/plugins/container/DLC_26.pyc b/module/plugins/container/DLC_26.pyc Binary files differdeleted file mode 100644 index 685995fc2..000000000 --- a/module/plugins/container/DLC_26.pyc +++ /dev/null diff --git a/module/plugins/container/DLC_27.pyc b/module/plugins/container/DLC_27.pyc Binary files differdeleted file mode 100644 index 6c6d663e5..000000000 --- a/module/plugins/container/DLC_27.pyc +++ /dev/null diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py deleted file mode 100644 index c6173ad73..000000000 --- a/module/plugins/container/LinkList.py +++ /dev/null @@ -1,71 +0,0 @@ -# -*- coding: utf-8 -*- - -import codecs - -from module.plugins.Container import Container -from module.utils import fs_encode - - -class LinkList(Container): - __name__ = "LinkList" - __version__ = "0.12" - - __pattern__ = r'.+\.txt' - __config__ = [("clear", "bool", "Clear Linklist after adding", False), - ("encoding", "string", "File encoding (default utf-8)", "")] - - __description__ = """Read link lists in txt format""" - __license__ = "GPLv3" - __authors__ = [("spoob", "spoob@pyload.org"), - ("jeix", "jeix@hasnomail.com")] - - - def decrypt(self, pyfile): - try: - file_enc = codecs.lookup(self.getConfig("encoding")).name - except: - file_enc = "utf-8" - - file_name = fs_encode(pyfile.url) - - txt = codecs.open(file_name, 'r', file_enc) - links = txt.readlines() - curPack = "Parsed links from %s" % pyfile.name - - packages = {curPack:[],} - - for link in links: - link = link.strip() - if not link: - continue - - if link.startswith(";"): - continue - if link.startswith("[") and link.endswith("]"): - # new package - curPack = link[1:-1] - packages[curPack] = [] - continue - packages[curPack].append(link) - txt.close() - - # empty packages fix - - delete = [] - - for key,value in packages.iteritems(): - if not value: - delete.append(key) - - for key in delete: - del packages[key] - - if self.getConfig("clear"): - try: - txt = open(file_name, 'wb') - txt.close() - except: - self.logWarning(_("LinkList could not be cleared")) - - for name, links in packages.iteritems(): - self.packages.append((name, links, name)) diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py index 0c43f0e6c..dd2d14cf7 100644 --- a/module/plugins/container/RSDF.py +++ b/module/plugins/container/RSDF.py @@ -2,55 +2,60 @@ from __future__ import with_statement -import base64 import binascii import re +from Crypto.Cipher import AES + from module.plugins.Container import Container from module.utils import fs_encode class RSDF(Container): __name__ = "RSDF" - __version__ = "0.24" + __type__ = "container" + __version__ = "0.29" - __pattern__ = r'.+\.rsdf' + __pattern__ = r'.+\.rsdf$' __description__ = """RSDF container decrypter plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.org"), - ("spoob", "spoob@pyload.org")] - + ("spoob", "spoob@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")] - def decrypt(self, pyfile): - from Crypto.Cipher import AES + KEY = "8C35192D964DC3182C6F84F3252239EB4A320D2500000000" + IV = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - infile = fs_encode(pyfile.url.replace("\n", "")) - Key = binascii.unhexlify('8C35192D964DC3182C6F84F3252239EB4A320D2500000000') - IV = binascii.unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') - IV_Cipher = AES.new(Key, AES.MODE_ECB) - IV = IV_Cipher.encrypt(IV) + def decrypt(self, pyfile): + KEY = binascii.unhexlify(self.KEY) + IV = binascii.unhexlify(self.IV) - obj = AES.new(Key, AES.MODE_CFB, IV) + iv = AES.new(KEY, AES.MODE_ECB).encrypt(IV) + cipher = AES.new(KEY, AES.MODE_CFB, iv) try: - with open(infile, 'r') as rsdf: + fs_filename = fs_encode(pyfile.url.strip()) + with open(fs_filename, 'r') as rsdf: data = rsdf.read() + except IOError, e: - self.fail(str(e)) + self.fail(e) + + if re.search(r"<title>404 - Not Found</title>", data): + pyfile.setStatus("offline") - if re.search(r"<title>404 - Not Found</title>", data) is None: - data = binascii.unhexlify(''.join(data.split())) - data = data.splitlines() + else: + try: + raw_links = binascii.unhexlify(''.join(data.split())).splitlines() - for link in data: + except TypeError: + self.fail(_("Container is corrupted")) + + for link in raw_links: if not link: continue - link = base64.b64decode(link) - link = obj.decrypt(link) - decryptedUrl = link.replace('CCF: ', '') - self.urls.append(decryptedUrl) - - self.logDebug("Adding package %s with %d links" % (pyfile.package().name, len(self.urls))) + link = cipher.decrypt(link.decode('base64')).replace('CCF: ', '') + self.urls.append(link) diff --git a/module/plugins/container/TXT.py b/module/plugins/container/TXT.py new file mode 100644 index 000000000..d419ee060 --- /dev/null +++ b/module/plugins/container/TXT.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import codecs + +from module.plugins.Container import Container +from module.utils import fs_encode + + +class TXT(Container): + __name__ = "TXT" + __type__ = "container" + __version__ = "0.15" + + __pattern__ = r'.+\.(txt|text)$' + __config__ = [("flush" , "bool" , "Flush list after adding", False ), + ("encoding", "string", "File encoding" , "utf-8")] + + __description__ = """Read link lists in plain text formats""" + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("jeix", "jeix@hasnomail.com")] + + + def decrypt(self, pyfile): + try: + encoding = codecs.lookup(self.getConfig('encoding')).name + + except Exception: + encoding = "utf-8" + + fs_filename = fs_encode(pyfile.url.strip()) + txt = codecs.open(fs_filename, 'r', encoding) + curPack = "Parsed links from %s" % pyfile.name + packages = {curPack:[],} + + for link in txt.readlines(): + link = link.strip() + + if not link: + continue + + if link.startswith(";"): + continue + + if link.startswith("[") and link.endswith("]"): + # new package + curPack = link[1:-1] + packages[curPack] = [] + continue + + packages[curPack].append(link) + + txt.close() + + # empty packages fix + for key, value in packages.iteritems(): + if not value: + packages.pop(key, None) + + if self.getConfig('flush'): + try: + txt = open(fs_filename, 'wb') + txt.close() + + except IOError: + self.logWarning(_("Failed to flush list")) + + for name, links in packages.iteritems(): + self.packages.append((name, links, name)) |