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

Add progress bar #97

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add progress bar #97

wants to merge 3 commits into from

Conversation

fuzzbuck
Copy link

@fuzzbuck fuzzbuck commented Jun 13, 2023

Add 'progress' to Options, which displays a visual progress bar of the obfuscation process in STDOUT
image

Example:

JsConfuser.obfuscate(contents, {
    target: "browser",
    progress: true,
    preset: "high"
})

Copy link

@Le0Developer Le0Developer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MichaelXF
Copy link
Owner

This could be implemented using the JsConfuser.debugObfuscation, the same method the js-confuser.com uses to display a progress bar. This way you can avoid the extra dependency. Here's an example:

var outputObject = await JsConfuser.debugObfuscation(
  CODE,
  {
    target: "node",
    preset: "high"
  },
  (transformName, index, totalTransforms) => {
    console.log(transformName + " is done!", index, "/", totalTransforms);
  },
  require("perf_hooks").performance
);

var output: string = outputObject.obfuscated; // The obfuscated code

console.log(outputObject.transformationTimes); // Object of transformation times

/*
Preparation is done! 1 / 21
ObjectExtraction is done! 2 / 21
Flatten is done! 3 / 21
Dispatcher is done! 4 / 21
DeadCode is done! 5 / 21
Calculator is done! 6 / 21
ControlFlowFlattening is done! 7 / 21
GlobalConcealing is done! 8 / 21
OpaquePredicates is done! 9 / 21
StringSplitting is done! 10 / 21
StringConcealing is done! 11 / 21
StringCompression is done! 12 / 21
Stack is done! 13 / 21
DuplicateLiteralsRemoval is done! 14 / 21
Shuffle is done! 15 / 21
MovedDeclarations is done! 16 / 21
RenameLabels is done! 17 / 21
Minify is done! 18 / 21
RenameVariables is done! 19 / 21
AntiTooling is done! 20 / 21
Finalizer is done! 21 / 21
[Object: null prototype] {
  Preparation: 1.0094190000090748,
  ObjectExtraction: 0.9722220000112429,
  Flatten: 2.585480000008829,
  Dispatcher: 6.410395000013523,
  DeadCode: 7.101765999919735,
  Calculator: 4.634364000055939,
  ControlFlowFlattening: 65.66039700002875,
  GlobalConcealing: 40.353111999924295,
  OpaquePredicates: 8.849830999970436,
  StringSplitting: 6.999255000031553,
  StringConcealing: 19.94320500001777,
  StringCompression: 14.935447999974713,
  Stack: 116.39931500004604,
  DuplicateLiteralsRemoval: 37.37533099995926,
  Shuffle: 12.675785999977961,
  MovedDeclarations: 12.70788200001698,
  RenameLabels: 32.359866000013426,
  Minify: 70.36959400004707,
  RenameVariables: 216.08912899997085,
  AntiTooling: 13.917390999966301,
  Finalizer: 22.79970700002741
}
*/

@fuzzbuck
Copy link
Author

This could be implemented using the JsConfuser.debugObfuscation, the same method the js-confuser.com uses to display a progress bar. This way you can avoid the extra dependency. Here's an example:

var outputObject = await JsConfuser.debugObfuscation(
  CODE,
  {
    target: "node",
    preset: "high"
  },
  (transformName, index, totalTransforms) => {
    console.log(transformName + " is done!", index, "/", totalTransforms);
  },
  require("perf_hooks").performance
);

var output: string = outputObject.obfuscated; // The obfuscated code

console.log(outputObject.transformationTimes); // Object of transformation times

/*
Preparation is done! 1 / 21
ObjectExtraction is done! 2 / 21
Flatten is done! 3 / 21
Dispatcher is done! 4 / 21
DeadCode is done! 5 / 21
Calculator is done! 6 / 21
ControlFlowFlattening is done! 7 / 21
GlobalConcealing is done! 8 / 21
OpaquePredicates is done! 9 / 21
StringSplitting is done! 10 / 21
StringConcealing is done! 11 / 21
StringCompression is done! 12 / 21
Stack is done! 13 / 21
DuplicateLiteralsRemoval is done! 14 / 21
Shuffle is done! 15 / 21
MovedDeclarations is done! 16 / 21
RenameLabels is done! 17 / 21
Minify is done! 18 / 21
RenameVariables is done! 19 / 21
AntiTooling is done! 20 / 21
Finalizer is done! 21 / 21
[Object: null prototype] {
  Preparation: 1.0094190000090748,
  ObjectExtraction: 0.9722220000112429,
  Flatten: 2.585480000008829,
  Dispatcher: 6.410395000013523,
  DeadCode: 7.101765999919735,
  Calculator: 4.634364000055939,
  ControlFlowFlattening: 65.66039700002875,
  GlobalConcealing: 40.353111999924295,
  OpaquePredicates: 8.849830999970436,
  StringSplitting: 6.999255000031553,
  StringConcealing: 19.94320500001777,
  StringCompression: 14.935447999974713,
  Stack: 116.39931500004604,
  DuplicateLiteralsRemoval: 37.37533099995926,
  Shuffle: 12.675785999977961,
  MovedDeclarations: 12.70788200001698,
  RenameLabels: 32.359866000013426,
  Minify: 70.36959400004707,
  RenameVariables: 216.08912899997085,
  AntiTooling: 13.917390999966301,
  Finalizer: 22.79970700002741
}
*/

cli-progress is a very small library and providers helpers for repeatedly updating stdout, I think there is no need to reinvent the wheel here

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

Successfully merging this pull request may close these issues.

None yet

3 participants