diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-10-11 23:59:07 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-10-11 23:59:07 +0200 |
commit | 37fcdffac990eaf024fdc33a026fcf566e9e263f (patch) | |
tree | 053dfbfa622065485fb9addc6737f6f7112e46ed | |
parent | [XFileSharingPro] Hoster list cleanup + linestorage.com (diff) | |
download | pyload-37fcdffac990eaf024fdc33a026fcf566e9e263f.tar.xz |
[MegaNz] Fix decryptAttr
-rw-r--r-- | module/plugins/hoster/MegaNz.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index 91719b86b..2e6aaa273 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -16,7 +16,7 @@ from module.plugins.Hoster import Hoster class MegaNz(Hoster): __name__ = "MegaNz" __type__ = "hoster" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = r'https?://(\w+\.)?mega\.co\.nz/#!([\w!-]+)' @@ -33,12 +33,14 @@ class MegaNz(Hoster): data = data.replace("-", "+").replace("_", "/") return standard_b64decode(data + '=' * (-len(data) % 4)) + def getCipherKey(self, key): """ Construct the cipher key from the given data """ a = array("I", key) key_array = array("I", [a[0] ^ a[4], a[1] ^ a[5], a[2] ^ a[6], a[3] ^ a[7]]) return key_array + def callApi(self, **kwargs): """ Dispatch a call to the api, see https://mega.co.nz/#developers """ # generate a session id, no idea where to obtain elsewhere @@ -48,8 +50,8 @@ class MegaNz(Hoster): self.logDebug("Api Response: " + resp) return json_loads(resp) - def decryptAttr(self, data, key): + def decryptAttr(self, data, key): cbc = AES.new(self.getCipherKey(key), AES.MODE_CBC, "\0" * 16) attr = cbc.decrypt(self.b64_decode(data)) self.logDebug("Decrypted Attr: " + attr) @@ -57,7 +59,8 @@ class MegaNz(Hoster): self.fail(_("Decryption failed")) # Data is padded, 0-bytes must be stripped - return json_loads(attr.replace("MEGA", "").rstrip("\0").strip()) + return json_loads(re.search(r'{.+?}', attr).group(0)) + def decryptFile(self, key): """ Decrypts the file at lastDownload` """ @@ -92,8 +95,8 @@ class MegaNz(Hoster): self.lastDownload = file_decrypted - def process(self, pyfile): + def process(self, pyfile): key = None # match is guaranteed because plugin was chosen to handle url |