beautifier/js-beautify

'$' issues when use javascriptobfuscator_unpacker

Open

#1610 aperta il 3 gen 2019

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)JavaScript (1460 fork)batch import
good first issuetype: bug

Metriche repository

Star
 (8342 star)
Metriche merge PR
 (Merge medio 51g 1h) (16 PR mergiate in 30 g)

Descrizione

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.

Guida contributor