以前没搞过类似的东西,说一下我的思路吧
首先打开链接观察到
https://g.api.mega.co.nz/cs?id=0&domain=meganz…………………… 这个链接请求,是一个 json ,里面的[0]['at']
NQf1ctaRp0DwVAPJYybfRvoGQ_OOYJ8YOfZDXbqa0KpalCK-KHJSdTya0Eo-k01r87bdu6yfCaCNbUFsUSC1ng
是加密后的东西。
然后就是加密算法了看
https://mega.nz/SecurityWhitepaper.pdf 26 页
5.1 Public file links
When a public file link is shared publicly, the following is embedded into the public link:
https://mega.nz/#! || Base64( File Handle ) || ! || Base64( Obfuscated File Key )
也就是说链接后面是 Obfuscated File Key ,这个是一个 32 字节的数据
再看 24 页
4.1 File upload encryption
The File Key is then obfuscated as follows:
Obfuscated File Key = [
File Key[0] ⊕ IV[0],
File Key[1] ⊕ IV[1],
File Key[2] ⊕ Condensed MAC[0] ⊕ Condensed MAC[1],
File Key[3] ⊕ Condensed MAC[2] ⊕ Condensed MAC[3],
IV[0],
IV[1],
Condensed MAC[0] ⊕ Condensed MAC[1],
Condensed MAC[2] ⊕ Condensed MAC[3]
];
也就是说 Obfuscated File Key 包含了 File Key 和 IV
观察得到(以 4 字节为一组)
File Key[0] = Obfuscated File Key[0] ⊕ IV[0]
File Key[1] = Obfuscated File Key[1] ⊕ IV[1]
File Key[2] = Obfuscated File Key[2] ⊕ Obfuscated File Key[6]
File Key[3] = Obfuscated File Key[3] ⊕ Obfuscated File Key[7]
IV[0] = Obfuscated File Key[4]
IV[1] = Obfuscated File Key[5]
4.2 File attribute, preview and thumbnail encryption
When the file is ready to be sent, the file attributes (e.g. the file name, thumbnail, preview) also need
to be encrypted. These are encrypted with:
AES-CBC(File Key, File Attribute Data)
然后通过 File Key 用 AES CBC 解密就行了
还有一些细节,比如 base64 里包含的-_等字符串不是标准的,缺了几个=,还有一些加密算法等等。
乍一看确实挺简单的,但是如果没做过 CTF 类似的东西,还是要花一点时间熟悉一下流程。