// by Zzbaivong - https://github.com/lelinhtinh // https://lelinhtinh.github.io/de4js/ (function() { function format() { var source = output.value; if (beautify.checked) source = js_beautify(source, { unescape_strings: true, jslint_happy: true }); if (highlight.checked) source = hljs.highlight('javascript', source).value; view[(highlight.checked ? 'innerHTML' : 'textContent')] = source || 'Hãy chọn kiểu mã hoá phù hợp!'; } function decode() { var source = input.value, packer = bvDecode.encode.value; if (source.trim() === '') return; view.textContent = 'Hãy chọn kiểu mã hoá phù hợp!'; output.value = ''; source = source.trim(); if (packer === 'evalencode') { try { var _source = source.replace('eval(', 'window.sourceEvalEncodeZz = ('); eval(_source); if (window.sourceEvalEncodeZz !== undefined) source = window.sourceEvalEncodeZz; } catch (err) {} } else if (packer === '_numberencode') { try { var patt = /_\d{4}\((_\d{4})\)\;\}/, _source = source; if (!patt.test(_source)) return; _source = _source.replace(/var\s/g, 'this.'); _source = _source.replace(/function\s(_\d{4})\(/, 'this.$1=function('); _source = _source.replace(patt, 'window.sourceNumberEncodeZz=$1;};'); _source = '(function(){' + _source + '})();'; eval(_source); source = window.sourceNumberEncodeZz; } catch (err) {} } else if (packer === 'arrayencode') { try { var pattsplit = /(?:[^\\])"];/, lastchar = ''; if (!pattsplit.test(source)) return; lastchar = source.match(pattsplit)[0].charAt(0); var _source = source.split(pattsplit), _var = _source[0] + lastchar + '"]', _name = _var.match(/var\s([\w\d]+)\s?=\s?\["/)[1], _code = _source[1], pattname = new RegExp('var\\s' + _name + '\\s?=\\s?\\["'), pattkey = new RegExp(_name + '\\[(\\d+)\\]', 'g'), escapable = /[\\\"\x00-\x1f\x7f-\uffff]/g, meta = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }, quote = function(string) { escapable.lastIndex = 0; return escapable.test(string) ? string.replace(escapable, function(a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) : string; }; _var = _var.replace(pattname, '["'); _var = eval(_var); _code.replace(pattkey, function(key, index) { _code = _code.replace(key, '"' + quote(_var[index]) + '"'); return _code; }); _source = _code.replace(/(\["([a-z\d\_]+)"\])/gi, '.$2'); source = _source; } catch (err) {} } else if (packer === 'urlencode' && Urlencoded.detect(source)) { source = Urlencoded.unpack(source); } else if (packer === 'p_a_c_k_e_r' && P_A_C_K_E_R.detect(source)) { source = P_A_C_K_E_R.unpack(source); } else if (packer === 'javascriptobfuscator' && JavascriptObfuscator.detect(source)) { source = JavascriptObfuscator.unpack(source); } else if (packer === 'myobfuscate' && MyObfuscate.detect(source)) { source = MyObfuscate.unpack(source); } output.value = source; format(); } function textreset() { if (copyjs.textContent === 'Sao chép vào Clipboard') return; copyjs.textContent = 'Sao chép vào Clipboard'; copyjs.removeAttribute('style'); } function timereset() { copytimeout = setTimeout(function() { textreset(); }, 3000); } var input = document.getElementById('input'), output = document.getElementById('output'), view = document.getElementById('view'), encode = document.getElementsByName('encode'), beautify = document.getElementById('beautify'), highlight = document.getElementById('highlight'), copyjs = document.getElementById('copyjs'), redecode = document.getElementById('redecode'), clear = document.getElementById('clear'), clipboard = new Clipboard('#copyjs'), copytimeout; input.oninput = decode; for (var i = 0; i < encode.length; i++) { encode[i].onchange = decode; } beautify.onchange = format; highlight.onchange = format; copyjs.onmouseout = function() { textreset(); clearTimeout(copytimeout); }; clipboard.on('success', function(e) { e.trigger.textContent = 'Đã chép vào Clipboard'; e.trigger.style.color = '#4caf50'; e.clearSelection(); timereset(); }); clipboard.on('error', function(e) { e.trigger.textContent = 'Lỗi! Trình duyệt không hỗ trợ.'; e.trigger.style.color = '#f44336'; timereset(); }); redecode.onclick = function() { input.value = output.value; decode(); } clear.onclick = function() { input.value = ''; output.value = ''; view.textContent = 'Hãy chọn kiểu mã hoá phù hợp!'; } })();
<p class="info"> Công cụ này hiện đang được phát triển và chia sẻ trên <a href="https://github.com/lelinhtinh/de4js" target="_blank">Github</a>. <br>Trang này đã không còn nhận được cập nhật và sửa lỗi. Vui lòng truy cập <a href="https://lelinhtinh.github.io/de4js/" target="_blank">de4js</a> để sử dụng phiên bản mới, tốt hơn. </p> <form class="wrap" name="bvDecode"> <h1 class="title center">Giải mã JavaScript</h1> <textarea id="input" class="content" rows="7" placeholder="Nhập code bị mã hoá..."></textarea> <textarea id="output"></textarea> <div class="config center"> <label> <input type="radio" value="" name="encode" checked> None</label> <label> <input type="radio" value="evalencode" name="encode"> Eval</label> <label> <input type="radio" value="_numberencode" name="encode"> _Number</label> <label> <input type="radio" value="arrayencode" name="encode"> Array</label> <label> <input type="radio" value="urlencode" name="encode"> URL Encode</label> <label> <input type="radio" value="p_a_c_k_e_r" name="encode"> Packer</label> <label> <input type="radio" value="javascriptobfuscator" name="encode"> Javascript Obfuscator</label> <label> <input type="radio" value="myobfuscate" name="encode"> My Obfuscate</label> </div> <div class="config center"> <label> <input type="checkbox" id="beautify" name="beautify" checked> Beautify</label> <label> <input type="checkbox" id="highlight" name="highlight" checked> Highlight</label> </div> <div class="center"> <button id="copyjs" data-clipboard-target="#view" class="actionbtn" type="button"> Sao chép vào Clipboard </button> <button id="redecode" class="actionbtn" type="button"> Tiếp tục giải mã </button> <button id="clear" class="actionbtn" type="button"> Làm sạch </button> </div> <pre id="view" class="content">Hãy chọn kiểu mã hoá phù hợp!</pre> </form>
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif; font-size: 14px; } .wrap { margin: 30px auto; width: 90%; } .title { font-size: 1.7em; font-weight: lighter; } .content { display: block; width: 100%; padding: 5px 16px; border: 1px solid #ddd; border-radius: 3px; box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; } #input { background: #fff; } #output { display: none; } #view { background: #eee; white-space: pre-wrap; } .config { font-size: smaller; color: #595656; } .config input { margin-right: 4px; vertical-align: middle; } .config label { display: inline-block; margin: 0 7px; } .center { text-align: center; margin: 20px 0; } .actionbtn { padding: 4px 0; margin: 0 4px; display: inline-block; width: 30%; color: #595656; } .info { color: #d2e7f9; background: #2E9EFF; padding: 1em; } .info a { color: #fff; font-weight: bold; }