beautifier/js-beautify

'$' issues when use javascriptobfuscator_unpacker

オープン

#1,610 opened on 2019/01/03

 (4 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (1,460 件のフォーク)batch import
good first issuetype: bug

Repository metrics

Stars
 (8,342 個のスター)
PR merge metrics
 (平均マージ 51d 1h) (30d で 16 merged PRs)

説明

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.

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