corrade-nucleus-nucleons – Blame information for rev 20
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | // |
2 | // simple unpacker/deobfuscator for scripts messed up with myobfuscate.com |
||
3 | // You really don't want to obfuscate your scripts there: they're tracking |
||
4 | // your unpackings, your script gets turned into something like this, |
||
5 | // as of 2011-04-25: |
||
6 | /* |
||
7 | |||
8 | var _escape = 'your_script_escaped'; |
||
9 | var _111 = document.createElement('script'); |
||
10 | _111.src = 'http://api.www.myobfuscate.com/?getsrc=ok' + |
||
11 | '&ref=' + encodeURIComponent(document.referrer) + |
||
12 | '&url=' + encodeURIComponent(document.URL); |
||
13 | var 000 = document.getElementsByTagName('head')[0]; |
||
14 | 000.appendChild(_111); |
||
15 | document.write(unescape(_escape)); |
||
16 | |||
17 | */ |
||
18 | // |
||
19 | // written by Einar Lielmanis <einar@jsbeautifier.org> |
||
20 | // |
||
21 | // usage: |
||
22 | // |
||
23 | // if (MyObfuscate.detect(some_string)) { |
||
24 | // var unpacked = MyObfuscate.unpack(some_string); |
||
25 | // } |
||
26 | // |
||
27 | // |
||
28 | |||
29 | var MyObfuscate = { |
||
30 | detect: function(str) { |
||
31 | if (/^var _?[0O1lI]{3}\=('|\[).*\)\)\);/.test(str)) { |
||
32 | return true; |
||
33 | } |
||
34 | if (/^function _?[0O1lI]{3}\(_/.test(str) && /eval\(/.test(str)) { |
||
35 | return true; |
||
36 | } |
||
37 | return false; |
||
38 | }, |
||
39 | |||
40 | unpack: function(str) { |
||
41 | if (MyObfuscate.detect(str)) { |
||
42 | var __eval = eval; |
||
43 | try { |
||
44 | eval = function(unpacked) { // jshint ignore:line |
||
45 | if (MyObfuscate.starts_with(unpacked, 'var _escape')) { |
||
46 | // fetch the urlencoded stuff from the script, |
||
47 | var matches = /'([^']*)'/.exec(unpacked); |
||
48 | var unescaped = unescape(matches[1]); |
||
49 | if (MyObfuscate.starts_with(unescaped, '<script>')) { |
||
50 | unescaped = unescaped.substr(8, unescaped.length - 8); |
||
51 | } |
||
52 | if (MyObfuscate.ends_with(unescaped, '</script>')) { |
||
53 | unescaped = unescaped.substr(0, unescaped.length - 9); |
||
54 | } |
||
55 | unpacked = unescaped; |
||
56 | } |
||
57 | // throw to terminate the script |
||
58 | unpacked = "// Unpacker warning: be careful when using myobfuscate.com for your projects:\n" + |
||
59 | "// scripts obfuscated by the free online version may call back home.\n" + |
||
60 | "\n//\n" + unpacked; |
||
61 | throw unpacked; |
||
62 | }; // jshint ignore:line |
||
63 | __eval(str); // should throw |
||
64 | } catch (e) { |
||
65 | // well, it failed. we'll just return the original, instead of crashing on user. |
||
66 | if (typeof e === "string") { |
||
67 | str = e; |
||
68 | } |
||
69 | } |
||
70 | eval = __eval; // jshint ignore:line |
||
71 | } |
||
72 | return str; |
||
73 | }, |
||
74 | |||
75 | starts_with: function(str, what) { |
||
76 | return str.substr(0, what.length) === what; |
||
77 | }, |
||
78 | |||
79 | ends_with: function(str, what) { |
||
80 | return str.substr(str.length - what.length, what.length) === what; |
||
81 | }, |
||
82 | |||
83 | run_tests: function(sanity_test) { |
||
84 | var t = sanity_test || new SanityTest(); |
||
85 | |||
86 | return t; |
||
87 | } |
||
88 | |||
89 | |||
90 | }; |