beautifier/js-beautify

'$' issues when use javascriptobfuscator_unpacker

Open

#1,610 opened on 2019年1月3日

GitHub で見る
 (4 comments) (0 reactions) (0 assignees)JavaScript (8,342 stars) (1,460 forks)batch import
good first issuetype: bug

説明

Description

Orignal code:

var a = {
    a: '1',
    b: 2,
    currencySymbol: '$',
    c: 3
};

Input

code after obfuscated

var _0xbe98 = ["\x63\x75\x72\x72\x65\x6e\x63\x79\x53\x79\x6d\x62\x6f\x6c", "\x24"];
var a = {};
a['\x61'] = '\x31';
a['\x62'] = 0x2;
a[_0xbe98[0]] = _0xbe98[1];
a['\x63'] = 0x3;

Expected Output

Expecting result as below after unpack

var a = {};
a['\x61'] = '\x31';
a['\x62'] = 0x2;
a['currencySymbol'] = '$';
a['\x63'] = 0x3;

Actual Output

var a = {};
a['\x61'] = '\x31';
a['\x62'] = 0x2;
a['currencySymbol'] = '; //missing $'
a['\x63'] = 0x3;;
a['\x63'] = 0x3; // where is this line come from?

Steps to Reproduce

JavascriptObfuscator.unpack(code)

Reason

The symbol $ is treated as a capture when replace string using RegExp, standalone $ sign should be escaped for this scenario.

コントリビューターガイド