javascript-obfuscator / javascript-obfuscator/gulp-javascript-obfuscator

Bug in obfuscate js code.

Aperta
#24 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug cannot reproduce
Lingua principale
JavaScript
Stelle
103
Fork
37
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

First at all, sorry for my english, i will try to explain it as better as possible.

I have the following js code:

```javascript
export const Painter = function (elements, data) {
let title = elements.title;
let container = elements.container;
this.prePaint = () => { };
this.paint = () => { };
this.postPaint = () => { };
let finalPaint = () => {
this.prePaint = () => { };
this.paint = () => { };
this.postPaint = () => { };
createPromise();
};

let createPromise = () => {
return new Promise((resolve, reject) => {
this.paint = () => { resolve() }
}).then(() => {
this.prePaint(elements, data);
title.innerHTML = data.title;
container.innerHTML = data.html;
this.postPaint(elements, data);
finalPaint();
});
}

createPromise();
};
```

When i obfuscate this code, it seems like this (it was minimized and formatted by the browser):
```javascript
5: [function(a, b, c) {
"use strict";
Object[_0x56ae("0x6")](c, _0x56ae("0x6e"), {
value: !0
});
c[_0x56ae("0xb5")] = function(a, b) {
var c = this
, d = a[_0x56ae("0xb6")]
, e = a[_0x56ae("0xb7")];
this.prePaint = function() {} //// THIS LINE
,
this[_0x56ae("0xb8")] = function() {}
,
this[_0x56ae("0xb9")] = function() {}
;
var f = function() {
c[_0x56ae("0xba")] = function() {}
,
c.paint = function() {} ///// THIS LINE TOO
,
c.postPaint = function() {} ///// AND THIS LINE TOO
,
g()
}
, g = function() {
return new Promise(function(a) {
c.paint = function() {
a()
}
}
)[_0x56ae("0x24")](function() {
c[_0x56ae("0xba")](a, b),
d.innerHTML = b[_0x56ae("0xb6")],
e.innerHTML = b[_0x56ae("0x34")],
c.postPaint(a, b),
f()
})
};
g()
}
}
, {}]
```

You can see, how the fisrt this.prePaint has not transformed to this[_0x56ae("0xba")] and when this is called, it said undefined function.
But if i insert breaklines between all this "problematic" lines, it work. Like this:

```javascript

export const Painter = function (elements, data) {
let title = elements.title;
let container = elements.container;

this.prePaint = () => { };

this.paint = () => { };

this.postPaint = () => { };

let finalPaint = () => {

this.prePaint = () => { };

this.paint = () => { };

this.postPaint = () => { };

createPromise();
};

let createPromise = () => {
return new Promise((resolve, reject) => {

this.paint = () => { resolve() }

}).then(() => {
this.prePaint(elements, data);

title.innerHTML = data.title;
container.innerHTML = data.html;

this.postPaint(elements, data);

finalPaint();

});
}

createPromise();
};
```

I did fix this issue with this partial solution, but i don't know where more places of my code, will appear the same issue.

Thank you

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Non è specificato alcun file del repository, test, versione o configurazione. Inizia riproducendo l'esempio Painter fornito tramite la pipeline di offuscamento gulp e confronta i riferimenti generati per this.prePaint, this.paint e this.postPaint. Il lavoro è completato quando il codice offuscato conserva i riferimenti a proprietà invocabili senza richiedere interruzioni di riga inserite.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
build-system, tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.