Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in obfuscate js code. #24

Open
ElionTDA opened this issue Dec 17, 2019 · 3 comments
Open

Bug in obfuscate js code. #24

ElionTDA opened this issue Dec 17, 2019 · 3 comments

Comments

@ElionTDA
Copy link

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

I have the following js code:

    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):

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:

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

@zamotkin
Copy link
Member

Cannot reproduce in javascript-obfuscator version 0.18.7 (you can test it here). Please be sure that you are using the latest version.

@ElionTDA
Copy link
Author

I'am using gulp-javascript-obfuscator version 1.1.6 (I think it's the last) but i dont know what versión of javascript-obfuscator is being used.

Its this correct version?

@manik-ushur
Copy link

Facing a similar/related issue: #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants