Git Product home page Git Product logo

Comments (11)

sanex3339 avatar sanex3339 commented on June 7, 2024 2

Check [email protected] and new conditional comments feature.

from webpack-obfuscator.

artaommahe avatar artaommahe commented on June 7, 2024 1

@sanex3339 hm, looks like plugin works over bundles, not separate modules/files. I dont see clear way to obfuscate only some modules that would be part of final app bundels (e.x. common ng2 bundles app, vendor and polyfills and obfuscated modules should be in one of main bundles, app or vendor)

from webpack-obfuscator.

sanex3339 avatar sanex3339 commented on June 7, 2024 1

Also you can use this webpack plugin
https://github.com/sanex3339/editable-sources-webpack-plugin

and temporary make this functional for yourself. This plugin allow you to access source code of each bundle as string (inside callback). You should extract code between comments, obfuscate it with node API of https://github.com/javascript-obfuscator/javascript-obfuscator and replace extracted code on obfuscated code.

from webpack-obfuscator.

artaommahe avatar artaommahe commented on June 7, 2024 1

@sanex3339 thx, used this plugin with simple callback, works fine

const JavaScriptObfuscator = require('javascript-obfuscator');


const commentStart = '\\/\\*\\* obfuscator\\: start \\*\\/';
const commentEnd = '\\/\\*\\* obfuscator\\: end \\*\\/';

const replaceRegExp = new RegExp(`${commentStart}(.|[\n\r])+?${commentEnd}`, '');

const obfuscatorOptions = {
  controlFlowFlattening: true,
  rotateStringArray: true,
  stringArray: true,
};


function JavaScriptObfuscatorCallback(sourceCode) {

    const updatedSourceCode = sourceCode.replace(replaceRegExp, (needToObfuscateCode) => {

      const obfuscatedCode = JavaScriptObfuscator.obfuscate(needToObfuscateCode);

      return obfuscatedCode;
    });

    return updatedSourceCode;
}

from webpack-obfuscator.

sanex3339 avatar sanex3339 commented on June 7, 2024

Hi, it is nice idea, when i will have time i do this.
But now you can check this option
https://github.com/javascript-obfuscator/webpack-obfuscator#excludes

from webpack-obfuscator.

sanex3339 avatar sanex3339 commented on June 7, 2024

Yes. I see only one way - add to obfuscator option to obfuscate only code inside comments:

var abc = 'abc;
/** obfuscator: start **/
// obfuscated code
/** obfuscator: end **/

But this feature will have low priority in development plans. I should finish control flow flattening first.

from webpack-obfuscator.

artaommahe avatar artaommahe commented on June 7, 2024

add to obfuscator option to obfuscate only code inside comments

yep, this looks enough. Waiting for it )

from webpack-obfuscator.

sanex3339 avatar sanex3339 commented on June 7, 2024

Also, controll flow flattening is feature of 0.9.0 version that under development and existing in NPM under dev tag. Latest stable version 0.8.3 doesn't have this feature.

from webpack-obfuscator.

artaommahe avatar artaommahe commented on June 7, 2024

Using comments to determine the boundaries of obfuscation was a bad idea ) If obfuscation is used before UglifyJS2 than on minification a lot of obfuscated code unfolds. If after - comments are removed and boundaries lost.
Currently bypassed this via replacing comments marks with this dummy code console.time('obfuscator: start')/ console.time('obfuscator: end') and disable UglifyJS2 sequences option 😶

from webpack-obfuscator.

sabres207 avatar sabres207 commented on June 7, 2024

@sanex3339 Thanks for the answers and the conditional comments feature.
Is there a way with the conditional comments to tell it where to start and stop obfuscating?
i.e

// other code
// javascript-obfuscator:enable-start
// code to obfuscate
// javascript-obfuscator:enable-end
// other code

from webpack-obfuscator.

andrea-citterio-wwit avatar andrea-citterio-wwit commented on June 7, 2024

@sanex3339 Is it possible to obfuscate only the service files folder in an Angular project?
Thanks

from webpack-obfuscator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.