caiguanhao / js-obfuscator

Obfuscate JavaScript files via http://javascriptobfuscator.com. This is also a Grunt plugin. Inform me if this plugin doesn't work.
https://www.npmjs.org/package/js-obfuscator
MIT License
117 stars 39 forks source link

grunt build, export message only #5

Closed fbacker closed 9 years ago

fbacker commented 9 years ago

Installed js-obfuscator with npm. Now when running in my project the output js file only includes (my dist.js file) It looks like a HTML code, please use GUI instead.

The build goes without errors. I've included

    grunt.loadNpmTasks('js-obfuscator');

this is my settings

    jsObfuscate: {

            dist: {
                options: {
                    concurrency: 2,
                    keepLinefeeds: false,
                    keepIndentations: false,
                    encodeStrings: true,
                    encodeNumbers: true,
                    moveStrings: true,
                    replaceNames: true,
                    variableExclusions: [ '^_get_', '^_set_', '^_mtd_' ]
                },
                files: {
                    'dist/assets/scripts/dist.js': [
                        'dist/assets/scripts/bower.js',
                        'dist/assets/scripts/scripts.js'
                    ]
                }
            }
        },

using this for building

    grunt.registerTask('buildjs',  ['jshint:beforeconcat', 'concat:distjs', 'uglify:distjs', 'jsObfuscate' ]);
caiguanhao commented 9 years ago

Are you using the latest version 0.1.0 of js-obfuscator?

fbacker commented 9 years ago

Yes.

caiguanhao commented 9 years ago

I ran a test and the grunt plugin is OK. I don't know where your problem is. Maybe you should try to post your code on http://www.javascriptobfuscator.com/ to see if it is the same error.

fbacker commented 9 years ago

Uploaded the script to the site, works like a charm, no errors. Also tried so configure to only use one of my scripts but getting same text in the output js file.

caiguanhao commented 9 years ago

Can you please try this JS files https://github.com/caiguanhao/js-obfuscator/blob/master/test/reduce.js to see if it is the same error?

If you install js-obfuscator globally (npm -g i js-obfuscator):

curl https://raw.githubusercontent.com/caiguanhao/js-obfuscator/master/test/reduce.js -Ls | jsobfuscate

If locally:

curl https://raw.githubusercontent.com/caiguanhao/js-obfuscator/master/test/reduce.js -Ls | ./node_modules/.bin/jsobfuscate

I ran the above commands and it worked fine. You can try them and post the output here. And please also post the version number of your node.js and system.

If these commands works fine, you can post your JS code here or to a secret gist, so I can test the code by myself. If not, then I don't know where the problem is.

fbacker commented 9 years ago

I ran locally curl https://raw.githubusercontent.com/caiguanhao/js-obfuscator/master/test/reduce.js -Ls | ./node_modules/.bin/jsobfuscate output: var _0x14a9=["\x66\x75\x6E\x63\x74\x69\x6F\x6E","\x72\x65\x64\x75\x63\x65","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x41\x72\x72\x61\x79\x2E\x70\x72\x6F\x74\x6F\x74\x79\x70\x65\x2E\x72\x65\x64\x75\x63\x65\x20\x63\x61\x6C\x6C\x65\x64\x20\x6F\x6E\x20\x6E\x75\x6C\x6C\x20\x6F\x72\x20\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x20\x69\x73\x20\x6E\x6F\x74\x20\x61\x20\x66\x75\x6E\x63\x74\x69\x6F\x6E","\x6C\x65\x6E\x67\x74\x68","\x52\x65\x64\x75\x63\x65\x20\x6F\x66\x20\x65\x6D\x70\x74\x79\x20\x61\x72\x72\x61\x79\x20\x77\x69\x74\x68\x20\x6E\x6F\x20\x69\x6E\x69\x74\x69\x61\x6C\x20\x76\x61\x6C\x75\x65"];if(_0x14a9[0]!== typeof Array[_0x14a9[2]][_0x14a9[1]]){Array[_0x14a9[2]][_0x14a9[1]]=function(_0xb8d9x1){_0x14a9[3];if(null===this||_0x14a9[4]=== typeof this){throw new TypeError(_0x14a9[5])};if(_0x14a9[0]!== typeof _0xb8d9x1){throw new TypeError(_0xb8d9x1+_0x14a9[6])};var _0xb8d9x2=Object(this),_0xb8d9x3=_0xb8d9x2[_0x14a9[7]]>>>0,_0xb8d9x4=0,_0xb8d9x5;if(arguments[_0x14a9[7]]>=2){_0xb8d9x5=arguments[1]}else {while(_0xb8d9x4<_0xb8d9x3&&!_0xb8d9x4 in _0xb8d9x2){_0xb8d9x4++};if(_0xb8d9x4>=_0xb8d9x3){throw new TypeError(_0x14a9[8])};_0xb8d9x5=_0xb8d9x2[_0xb8d9x4++];};for(;_0xb8d9x4<_0xb8d9x3;_0xb8d9x4++){if(_0xb8d9x4 in _0xb8d9x2){_0xb8d9x5=_0xb8d9x1(_0xb8d9x5,_0xb8d9x2[_0xb8d9x4],_0xb8d9x4,_0xb8d9x2)}};return _0xb8d9x5;}};

So it seems to work.

But still when running my 'grunt build' I get "It looks like a HTML code, please use GUI instead." in the output js file. I'm kind of new to bower/grunt/node so havn't been able to debug the plugin.

I've updated the modules

Node.js Had: v0.10.33 Now: v0.12.4

Bower Has: 1.4.1

npm Had: 2.10.1 Now: 2.11.0

Grunt Has: grunt-cli v0.1.13 Has: grunt v0.4.5

Still no luck when running 'grunt build'

Will create a gist where you can find the code.

On Wed, Jun 3, 2015 at 11:56 AM CGH notifications@github.com wrote:

Can you please try this JS files https://github.com/caiguanhao/js-obfuscator/blob/master/test/reduce.js to see if it is the same error?

If you install js-obfuscator globally (npm -g i js-obfuscator):

curl https://raw.githubusercontent.com/caiguanhao/js-obfuscator/master/test/reduce.js -Ls | jsobfuscate

If locally:

curl https://raw.githubusercontent.com/caiguanhao/js-obfuscator/master/test/reduce.js -Ls | ./node_modules/.bin/jsobfuscate

I ran the above commands and it worked fine. You can try them and post the output here. And please also post the version number of your node.js and system.

If these commands works fine, you can post your JS code here or to a secret gist, so I can test the code by myself. If not, then I don't know where the problem is.

— Reply to this email directly or view it on GitHub https://github.com/caiguanhao/js-obfuscator/issues/5#issuecomment-108283144 .

fbacker commented 9 years ago

Invited you to a private git with the code.

I'm running: grunt build Look at the file /dist/assets/scripts/dist.js

caiguanhao commented 9 years ago

I paste the file dist/assets/scripts/bower.js to http://www.javascriptobfuscator.com/Javascript-Obfuscator.aspx and it really has this error (It looks like a HTML code, please use GUI instead.): screen shot 2015-06-07 at 1 59 27 pm

I don't know where the problem is in bower.js. There must be a bug on that website. The JS code is OK, I tried to encode it http://www.jsobfuscate.com/ and then obfuscate it and it worked.

fbacker commented 9 years ago

I uploaded a file on the site that worked and noticed that when using online form if I'm using compressed script it doesn't work. Thanks for the help and good thing it wasn't an issue with your great plugin =)