summaryrefslogtreecommitdiffstats
path: root/module/web/cnl
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-03 18:12:36 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-03 18:12:36 +0200
commitdbd9423f99fcde168b0483e4a37a094b93bb2ea0 (patch)
tree30dd0a93d4d706ada845f0552e21de5ab4ffedc4 /module/web/cnl
parentnetload prefetching fix (diff)
downloadpyload-dbd9423f99fcde168b0483e4a37a094b93bb2ea0.tar.xz
new js engine for cnl
Diffstat (limited to 'module/web/cnl')
-rw-r--r--module/web/cnl/views.py40
1 files changed, 25 insertions, 15 deletions
diff --git a/module/web/cnl/views.py b/module/web/cnl/views.py
index 7bc2ae6d4..46db5e76e 100644
--- a/module/web/cnl/views.py
+++ b/module/web/cnl/views.py
@@ -90,28 +90,38 @@ def addcrypted2(request):
jk = request.POST["jk"]
crypted = base64.standard_b64decode(unquote(crypted.replace(" ", "+")))
-
try:
import spidermonkey
- except:
- try:
- jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
- except:
- ## Test for some known js functions to decode
- if jk.find("dec") > -1 and jk.find("org") > -1:
- org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
- jk = list(org)
- jk.reverse()
- jk = "".join(jk)
- else:
- print "Could not decrypt key, please install py-spidermonkey"
- else:
rt = spidermonkey.Runtime()
cx = rt.new_context()
jk = cx.execute("%s f()" % jk)
+ except ImportError:
+ if settings.JS:
+ import subprocess
+ jk = jk.replace("'", '"')
+ cmd = settings.JS + ["-e", "%s ;print(f());" % jk ]
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
+ jk = p.stdout.read().strip()
+
+ else:
+ try:
+ jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
+ except:
+ ## Test for some known js functions to decode
+ if jk.find("dec") > -1 and jk.find("org") > -1:
+ org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
+ jk = list(org)
+ jk.reverse()
+ jk = "".join(jk)
+ else:
+ print "Could not decrypt key, please install py-spidermonkey or other js engine"
+ try:
+ Key = binascii.unhexlify(jk)
+ except:
+ print "Could not decrypt key, please install py-spidermonkey or other js engine"
+ return JsonResponse("failed", request)
- Key = binascii.unhexlify(jk)
IV = Key
obj = AES.new(Key, AES.MODE_CBC, IV)