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

problem with file paths #57

Closed
mo-js opened this issue Jun 18, 2017 · 11 comments
Closed

problem with file paths #57

mo-js opened this issue Jun 18, 2017 · 11 comments

Comments

@mo-js
Copy link

mo-js commented Jun 18, 2017

i am using javascript obfuscator with angular 2 and sytemjs for electron application.
the problem is after obfuscation file paths are wrong and systemjs get file not found error.
for example:
Object['defineProperty'](exports, '\x5f\x5fesModule', { '\x76\x61\x6c\x75\x65': !![] }); var core_1 = require('\x40angular\x2fcore'); var router_1 = require('\x40angular\x2frouter');

@sanex3339
Copy link
Member

Hmm strange, path like require('\x40angular\x2fcore'); should be a valid file path.
Can you provide small example app with this problem?

@mo-js
Copy link
Author

mo-js commented Jun 18, 2017

when i run electron app on windows the final path is like
D:/appfolder/dist/x40angular/x2fplatform/x2dbrowser
but folder names are:
D:/appfolder/dist/@angular/platform-browser
can we disable hex encoding?

@sanex3339
Copy link
Member

sanex3339 commented Jun 18, 2017

Unicode escaped strings should works fine.

Can you provide small example with one or two files that i can reproduce this error?

@sanex3339
Copy link
Member

For example

var _0x6051 = ['\x40angular\x2frouter'];
var _0x1605 = function (_0x41af57, _0x9291fc) {
    _0x41af57 = _0x41af57 - 0x0;
    var _0x51c5de = _0x6051[_0x41af57];
    return _0x51c5de;
};
var module = require(_0x1605('0x0'));

With this code i got error: Cannot find module '@angular/router' because i haven't this module.

@mo-js
Copy link
Author

mo-js commented Jun 18, 2017

i think systemjs is the problem.
when module name has any of (@ . - /) in form of hex (\x40 \x2e \x2d \x2f ) systemjs cannot load the module.
is there any way to prevent hex encoding for "require"?

@sanex3339
Copy link
Member

Right now - no. I'll look into this.

@mo-js
Copy link
Author

mo-js commented Jun 19, 2017

for now i tried to replace back hex for (\x40 \x2e \x2d \x2f) after obfuscation and it's ok!
we may report this problem to systemjs.
thanks for your project and your support.

@sanex3339
Copy link
Member

From my side currently even if 'unicodeEscapeSequence' option is disabled - all non-digit and non-latin symbols will encoded to unicode escape sequence.

This is hack because without that i got esprima errors like unexpected token ILLEGAL.
Now i should understand why this errors happens and encode or escape only important characters, so i'll work on this today and this fix shold be as part of 0.9.5 version alongside with es2017 async functions support.

@sanex3339 sanex3339 added this to the 0.9.5 milestone Jun 19, 2017
sanex3339 added a commit that referenced this issue Jun 19, 2017
Refactoring
@sanex3339 sanex3339 reopened this Jun 19, 2017
@sanex3339
Copy link
Member

sanex3339 commented Jun 19, 2017

Hi again!

Please try new javascript-obfuscator@0.10.0-beta.4.
Now with unicodeEscapeSequence: false - symbols won't encoded into unicode escape sequence.
71be6ab#diff-d2a4cbb17feeac0dedf775107abc89dcR160

@sanex3339 sanex3339 modified the milestones: 0.10.0, 0.9.5 Jun 20, 2017
@sanex3339
Copy link
Member

Any news?

@sanex3339
Copy link
Member

Problem should be fixed few beta releases ago. Closed.

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

2 participants