From e61437aa8b7a1525e238664b2004932ac1806e74 Mon Sep 17 00:00:00 2001 From: lelinhtinh Date: Sat, 12 Oct 2019 03:10:46 +0700 Subject: [PATCH] v1.4.0 --- _config.yml | 2 +- _data/options.yml | 4 +- _includes/highlight-js/styles/hljs-theme.css | 1 + .../styles/tomorrow-night-bright.css | 74 ------------ _layouts/default.html | 18 +-- assets/css/style.scss | 28 ++++- assets/js/main.js | 108 ++++++++++-------- assets/js/worker/format.js | 19 ++- package.json | 4 +- userscript/de4js_helper.user.js | 31 +++-- 10 files changed, 122 insertions(+), 167 deletions(-) create mode 100644 _includes/highlight-js/styles/hljs-theme.css delete mode 100644 _includes/highlight-js/styles/tomorrow-night-bright.css diff --git a/_config.yml b/_config.yml index 31c127e..df15183 100644 --- a/_config.yml +++ b/_config.yml @@ -1,6 +1,6 @@ name: de4js description: JavaScript Deobfuscator and Unpacker -version: 1.3.2 +version: 1.4.0 author: Zzbaivong author_email: Zzbaivong@gmail.com url: https://lelinhtinh.github.io diff --git a/_data/options.yml b/_data/options.yml index f81c356..3fb3fd7 100644 --- a/_data/options.yml +++ b/_data/options.yml @@ -15,6 +15,6 @@ - key: p_a_c_k_e_r name: Packer - key: javascriptobfuscator - name: Javascript Obfuscator + name: JS Obfuscator - key: myobfuscate - name: My Obfuscate \ No newline at end of file + name: My Obfuscate diff --git a/_includes/highlight-js/styles/hljs-theme.css b/_includes/highlight-js/styles/hljs-theme.css new file mode 100644 index 0000000..17df0ab --- /dev/null +++ b/_includes/highlight-js/styles/hljs-theme.css @@ -0,0 +1 @@ +.hljs-comment,.hljs-quote{color:#969896}.hljs-variable,.hljs-template-variable,.hljs-tag,.hljs-name,.hljs-selector-id,.hljs-selector-class,.hljs-regexp,.hljs-deletion{color:#d54e53}.hljs-number,.hljs-built_in,.hljs-builtin-name,.hljs-literal,.hljs-type,.hljs-params,.hljs-meta,.hljs-link{color:#e78c45}.hljs-attribute{color:#e7c547}.hljs-string,.hljs-symbol,.hljs-bullet,.hljs-addition{color:#b9ca4a}.hljs-title,.hljs-section{color:#7aa6da}.hljs-keyword,.hljs-selector-tag{color:#c397d8}.hljs{display:block;overflow-x:auto;background:black;color:#eaeaea;padding:.5em}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} \ No newline at end of file diff --git a/_includes/highlight-js/styles/tomorrow-night-bright.css b/_includes/highlight-js/styles/tomorrow-night-bright.css deleted file mode 100644 index e05af8a..0000000 --- a/_includes/highlight-js/styles/tomorrow-night-bright.css +++ /dev/null @@ -1,74 +0,0 @@ -/* Tomorrow Night Bright Theme */ -/* Original theme - https://github.com/chriskempson/tomorrow-theme */ -/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ - -/* Tomorrow Comment */ -.hljs-comment, -.hljs-quote { - color: #969896; -} - -/* Tomorrow Red */ -.hljs-variable, -.hljs-template-variable, -.hljs-tag, -.hljs-name, -.hljs-selector-id, -.hljs-selector-class, -.hljs-regexp, -.hljs-deletion { - color: #d54e53; -} - -/* Tomorrow Orange */ -.hljs-number, -.hljs-built_in, -.hljs-builtin-name, -.hljs-literal, -.hljs-type, -.hljs-params, -.hljs-meta, -.hljs-link { - color: #e78c45; -} - -/* Tomorrow Yellow */ -.hljs-attribute { - color: #e7c547; -} - -/* Tomorrow Green */ -.hljs-string, -.hljs-symbol, -.hljs-bullet, -.hljs-addition { - color: #b9ca4a; -} - -/* Tomorrow Blue */ -.hljs-title, -.hljs-section { - color: #7aa6da; -} - -/* Tomorrow Purple */ -.hljs-keyword, -.hljs-selector-tag { - color: #c397d8; -} - -.hljs { - display: block; - overflow-x: auto; - background: black; - color: #eaeaea; - padding: 0.5em; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} diff --git a/_layouts/default.html b/_layouts/default.html index 67aa71d..1860734 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -1,5 +1,5 @@ - + @@ -44,7 +44,6 @@

{{ site.description }}

-
@@ -57,20 +56,13 @@

{{ site.description }}

-
- - - - -
-
- +
@@ -82,7 +74,7 @@

{{ site.description }}

Open in new tab
-
Please choose a right encoding type!
+

                 
             
diff --git a/assets/css/style.scss b/assets/css/style.scss index e819f70..3ad5d80 100644 --- a/assets/css/style.scss +++ b/assets/css/style.scss @@ -9,7 +9,10 @@ $special-primary-color: #9C27B0; $special-disabled-color: #000000; @import "{{ site.theme }}"; -{% include highlight-js/styles/tomorrow-night-bright.css %} +{% include highlight-js/styles/hljs-theme.css %} +.hljs{ + background: #030303; +} @import "magic-check/sass/magic-check.scss"; body, @@ -33,10 +36,6 @@ code { resize: vertical; } -#output { - display: none; -} - .config { font-size: smaller; color: #595656; @@ -52,7 +51,7 @@ code { label { display: inline-block; - margin: .5em; + margin: .3em; } } @@ -62,6 +61,8 @@ code { } .btn { + cursor: pointer; + &:active, &:focus, &:hover { @@ -76,6 +77,13 @@ code { &::-moz-focus-inner { border: 0 none; } + + &:disabled { + cursor: not-allowed; + background: #141414; + border-color: #1b1b1b; + color: #525252; + } } #view { @@ -83,6 +91,14 @@ code { &.waiting { opacity: .3; + + &:empty:before { + content: 'Please wait...'; + } + } + + &:empty:before { + content: 'Please choose a right encoding type!'; } } diff --git a/assets/js/main.js b/assets/js/main.js index 76cdff4..09fa15a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -39,21 +39,28 @@ } var input = document.getElementById('input'), - output = document.getElementById('output'), view = document.getElementById('view'), + temp = '', encode = document.getElementsByName('encode'), + packer = document.bvDecode.encode.value, - beautify = document.getElementById('beautify'), - auto = document.getElementById('auto'), + checkAll = function (check) { + for (var i = 0; i < encode.length; i++) { + if (encode[i].value === 'nicify') continue; + encode[i].disabled = check; + } + }, - redecode = document.getElementById('redecode'), clear = document.getElementById('clear'), + autoBtn = document.getElementById('auto'), + isAuto = false, + preview = document.getElementById('preview'), clipboard = new ClipboardJS('#copyjs', { - target: function() { + target: function () { return view; } }), @@ -61,29 +68,39 @@ offlineBadge = document.getElementById('offline'), startEffect = function () { - if (output.value === '') view.textContent = 'Please wait...'; + view.textContent = ''; view.classList.add('waiting'); + clear.disabled = true; + autoBtn.disabled = true; + checkAll(true); }, stopEffect = function () { + isAuto = false; view.classList.remove('waiting'); + clear.disabled = false; + autoBtn.disabled = false; + setTimeout(function () { + checkAll(false); + if (packer === '') temp = ''; + }, 0); }, - resetcopy = function (trigger) { + resetCopy = function (trigger) { if (!trigger.classList.contains('copied')) return; trigger.classList.remove('copied'); }, - timereset = function (trigger) { + timeReset = function (trigger) { setTimeout(function () { - resetcopy(trigger); + resetCopy(trigger); }, 800); }, - externalStyle = '*{margin:0;padding:0}html{line-height:1em;background:#1d1f21;color:#c5c8c6}pre{white-space:pre-wrap;word-wrap:break-word;word-break:break-all}.hljs-comment,.hljs-quote{color:#969896}.hljs-variable,.hljs-template-variable,.hljs-tag,.hljs-name,.hljs-selector-id,.hljs-selector-class,.hljs-regexp,.hljs-deletion{color:#c66}.hljs-number,.hljs-built_in,.hljs-builtin-name,.hljs-literal,.hljs-type,.hljs-params,.hljs-meta,.hljs-link{color:#de935f}.hljs-attribute{color:#f0c674}.hljs-string,.hljs-symbol,.hljs-bullet,.hljs-addition{color:#b5bd68}.hljs-title,.hljs-section{color:#81a2be}.hljs-keyword,.hljs-selector-tag{color:#b294bb}.hljs{display:block;overflow-x:auto;background:#1d1f21;color:#c5c8c6;padding:.5em}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}', + externalStyle = '*{margin:0;padding:0}html{line-height:1em;background:#1d1f21;color:#c5c8c6}pre{white-space:pre-wrap;word-wrap:break-word;word-break:break-all}{% include highlight-js/styles/hljs-theme.css %}html,body,.hljs{background:#030303}', externalUrl, externalPreview = function (source) { if (externalUrl) URL.revokeObjectURL(externalUrl); - source = '{{ site.name }} | Preview
' + source + '
'; + source = '{{ site.name }} | Preview
' + source + '
'; externalUrl = new Blob([source], { type: 'text/html' @@ -98,9 +115,7 @@ workerDecode, format = debounce(function () { - var source = output.value.trim(); - - if (source === '') return; + if (temp === '') return; if (!workerFormat) { workerFormat = new Worker('{{ "/assets/js/worker/format.js" | relative_url }}'); @@ -114,8 +129,7 @@ startEffect(); workerFormat.postMessage({ - source: source, - beautify: beautify.checked + source: temp }); }, 250), @@ -146,15 +160,13 @@ }, decode = debounce(function () { - var source = input.value.trim(), - packer = document.bvDecode.encode.value; + if (temp === '') temp = input.value.trim(); + if (temp === '') return; - if (source === '') return; - if (auto.checked) packer = detect(source); + packer = isAuto ? detect(temp) : document.bvDecode.encode.value; if (packer === 'nicify') return; if (packer === '') { - output.value = source; format(); return; } @@ -162,61 +174,59 @@ if (!workerDecode) { workerDecode = new Worker('{{ "/assets/js/worker/decode.js" | relative_url }}'); workerDecode.addEventListener('message', function (e) { - output.value = e.data; + if (e.data !== temp) { + temp = e.data; - if (auto.checked && input.value !== output.value) { - redecode.onclick(); - } else { - format(); + if (isAuto) { + decode(); + return; + } } + + format(); }); } startEffect(); - output.value = ''; workerDecode.postMessage({ - source: source, + source: temp, packer: packer }); }, 250); - input.oninput = debounce(function () { + input.oninput = function () { + temp = input.value.trim(); decode(); - }); - for (var i = 0; i < encode.length; i++) { - encode[i].onchange = decode; } - beautify.onchange = format; + for (var i = 0; i < encode.length; i++) { + encode[i].onchange = function () { + decode(); + }; + } - auto.onchange = function () { - for (var i = 0; i < encode.length; i++) { - if (encode[i].value === 'nicify') continue; - encode[i].disabled = auto.checked; - } + autoBtn.onclick = function () { + isAuto = true; decode(); }; clipboard.on('success', function (e) { e.trigger.classList.add('copied'); e.clearSelection(); - timereset(e.trigger); + timeReset(e.trigger); }); clipboard.on('error', function (e) { e.trigger.classList.add('selected'); - timereset(e.trigger); + timeReset(e.trigger); }); - redecode.onclick = function () { - input.value = output.value; - decode(); - }; - clear.onclick = function () { - view.textContent = 'Please choose a right encoding type!'; + view.textContent = ''; + stopEffect(); - setTimeout(function() { - auto.onchange(); + setTimeout(function () { + input.value = ''; + temp = ''; }, 0); if (workerDecode) { @@ -231,7 +241,7 @@ preview.classList.remove('show'); }; - window.addEventListener('online', updateOnlineStatus); + window.addEventListener('online', updateOnlineStatus); window.addEventListener('offline', updateOnlineStatus); updateOnlineStatus(); diff --git a/assets/js/worker/format.js b/assets/js/worker/format.js index 2eccacd..ecf316a 100644 --- a/assets/js/worker/format.js +++ b/assets/js/worker/format.js @@ -12,19 +12,18 @@ self.addEventListener('message', function (e) { var source = e.data.source; - if (e.data.beautify) { - self._window = self.window; - self.window = {}; + self._window = self.window; + self.window = {}; - self.importScripts('{{ "/assets/js/lib/js-beautify/beautify.min.js" | relative_url }}'); + self.importScripts('{{ "/assets/js/lib/js-beautify/beautify.min.js" | relative_url }}'); - source = self.window.js_beautify(source, { - unescape_strings: true, - jslint_happy: true - }); + source = self.window.js_beautify(source, { + unescape_strings: true, + jslint_happy: true + }); + + self.window = self._window; - self.window = self._window; - } self.importScripts('{{ "/assets/js/lib/highlight-js/highlight.min.js" | relative_url }}'); diff --git a/package.json b/package.json index 52a5b0b..bcf7066 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,11 @@ { "name": "de4js", - "version": "1.3.2", + "version": "1.4.0", "description": "JavaScript Deobfuscator and Unpacker", "main": "/assets/js/main.js", "scripts": { + "start": "bundle exec jekyll serve --watch", + "build": "bundle exec jekyll build", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/userscript/de4js_helper.user.js b/userscript/de4js_helper.user.js index 541641e..1be65a4 100644 --- a/userscript/de4js_helper.user.js +++ b/userscript/de4js_helper.user.js @@ -24,29 +24,35 @@ 'use strict'; var nicify = document.getElementById('nicify'), + none = document.getElementById('none'), input = document.getElementById('input'), - output = document.getElementById('output'), - view = document.getElementById('view'), - redecode = document.getElementById('redecode'); + view = document.getElementById('view'); function jsnice() { if (!isOnine()) return; - if (input.value.trim() === '') return; + var txt = view.textContent.trim() || input.value.trim(); + if (!txt) return; view.classList.add('waiting'); GM.xmlHttpRequest({ method: 'POST', url: 'http://jsnice.org/beautify?pretty=0&rename=1&types=0&packers=0&transpile=0&suggest=0', responseType: 'json', - data: input.value, + data: txt, onload: function (response) { - var source = input.value; + var source; - if (response.response && response.response.js && response.response.js.indexOf('// Error compiling input') !== 0) + if ( + response.response && response.response.js && + response.response.js.indexOf('// Error compiling input') !== 0 + ) source = response.response.js; - output.value = source; - document.getElementById('beautify').onchange(); + nicify.checked = false; + none.checked = true; + + input.value = source; + input.oninput(); }, onerror: function (e) { console.error(e); // eslint-disable-line no-console @@ -60,13 +66,16 @@ } nicify.disabled = false; - nicify.onchange = jsnice; input.addEventListener('input', function () { if (nicify.checked) jsnice(); }); - redecode.addEventListener('click', function () { + nicify.addEventListener('click', function () { + if (nicify.checked) jsnice(); + }); + + nicify.addEventListener('onchange', function () { if (nicify.checked) jsnice(); });