beautifier / js-beautify

Beautifier for javascript
https://beautifier.io
MIT License
8.62k stars 1.39k forks source link

Not Beautifying The Code Obfuscated By https://obfuscator.io #1987

Open HackNetAyush opened 2 years ago

HackNetAyush commented 2 years ago

Description

It is not able to beautify the code obfuscated by https://obfuscator.io

Input

The code looked like this before beautification:

function _0x5181() {
    var _0x473dc1 = ['8286664ldsTfq', '159078Zipjmg', 'log', '522KeJXxE', '42gtpbCL', '313430onJxLP', '14ODqOFj', '74003446jQXyoJ', '68opHssO', '4155inMTKS', '2069628xkPLzp', 'Hello\x20World!', '1167978UFkeCV'];
    _0x5181 = function() {
        return _0x473dc1;
    };
    return _0x5181();
}

function _0x1324(_0x4e1289, _0x513181) {
    var _0x5181e9 = _0x5181();
    return _0x1324 = function(_0x13243d, _0x123d13) {
        _0x13243d = _0x13243d - 0x143;
        var _0x40e95c = _0x5181e9[_0x13243d];
        return _0x40e95c;
    }, _0x1324(_0x4e1289, _0x513181);
}(function(_0x444bf9, _0x465e44) {
    var _0x4fa4c8 = _0x1324,
        _0x528f96 = _0x444bf9();
    while (!![]) {
        try {
            var _0x248387 = -parseInt(_0x4fa4c8(0x14a)) / 0x1 * (parseInt(_0x4fa4c8(0x14f)) / 0x2) + -parseInt(_0x4fa4c8(0x146)) / 0x3 + parseInt(_0x4fa4c8(0x144)) / 0x4 * (parseInt(_0x4fa4c8(0x145)) / 0x5) + parseInt(_0x4fa4c8(0x148)) / 0x6 * (-parseInt(_0x4fa4c8(0x14d)) / 0x7) + -parseInt(_0x4fa4c8(0x149)) / 0x8 + parseInt(_0x4fa4c8(0x14c)) / 0x9 * (-parseInt(_0x4fa4c8(0x14e)) / 0xa) + parseInt(_0x4fa4c8(0x143)) / 0xb;
            if (_0x248387 === _0x465e44) break;
            else _0x528f96['push'](_0x528f96['shift']());
        } catch (_0x285e68) {
            _0x528f96['push'](_0x528f96['shift']());
        }
    }
}(_0x5181, 0xdfc6a));

function hi() {
    var _0x50fde1 = _0x1324;
    console[_0x50fde1(0x14b)](_0x50fde1(0x147));
}
hi();

Current Output

The code actually looked like this after beautification:

function _0x5181() {
    var _0x473dc1 = ['8286664ldsTfq', '159078Zipjmg', 'log', '522KeJXxE', '42gtpbCL', '313430onJxLP', '14ODqOFj', '74003446jQXyoJ', '68opHssO', '4155inMTKS', '2069628xkPLzp', 'Hello\x20World!', '1167978UFkeCV'];
    _0x5181 = function() {
        return _0x473dc1;
    };
    return _0x5181();
}

function _0x1324(_0x4e1289, _0x513181) {
    var _0x5181e9 = _0x5181();
    return _0x1324 = function(_0x13243d, _0x123d13) {
        _0x13243d = _0x13243d - 0x143;
        var _0x40e95c = _0x5181e9[_0x13243d];
        return _0x40e95c;
    }, _0x1324(_0x4e1289, _0x513181);
}(function(_0x444bf9, _0x465e44) {
    var _0x4fa4c8 = _0x1324,
        _0x528f96 = _0x444bf9();
    while (!![]) {
        try {
            var _0x248387 = -parseInt(_0x4fa4c8(0x14a)) / 0x1 * (parseInt(_0x4fa4c8(0x14f)) / 0x2) + -parseInt(_0x4fa4c8(0x146)) / 0x3 + parseInt(_0x4fa4c8(0x144)) / 0x4 * (parseInt(_0x4fa4c8(0x145)) / 0x5) + parseInt(_0x4fa4c8(0x148)) / 0x6 * (-parseInt(_0x4fa4c8(0x14d)) / 0x7) + -parseInt(_0x4fa4c8(0x149)) / 0x8 + parseInt(_0x4fa4c8(0x14c)) / 0x9 * (-parseInt(_0x4fa4c8(0x14e)) / 0xa) + parseInt(_0x4fa4c8(0x143)) / 0xb;
            if (_0x248387 === _0x465e44) break;
            else _0x528f96['push'](_0x528f96['shift']());
        } catch (_0x285e68) {
            _0x528f96['push'](_0x528f96['shift']());
        }
    }
}(_0x5181, 0xdfc6a));

function hi() {
    var _0x50fde1 = _0x1324;
    console[_0x50fde1(0x14b)](_0x50fde1(0x147));
}
hi();

Expected Output

The code should have looked like this after beautification:

/* Your desired output text */

// Paste your JavaScript code here
function hi() {
  console.log("Hello World!");
}
hi();

Environment

Browser User Agent:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Language Selected: Beautify JavaScript

Settings

{
  "indent_size": "4",
  "indent_char": " ",
  "max_preserve_newlines": "5",
  "preserve_newlines": true,
  "keep_array_indentation": false,
  "break_chained_methods": false,
  "indent_scripts": "normal",
  "brace_style": "collapse",
  "space_before_conditional": true,
  "unescape_strings": false,
  "jslint_happy": false,
  "end_with_newline": false,
  "wrap_line_length": "0",
  "indent_inner_html": false,
  "comma_first": false,
  "e4x": false,
  "indent_empty_lines": false
}
mbartlett21 commented 2 years ago

The actual obfuscator code is here:

https://github.com/javascript-obfuscator/javascript-obfuscator