Skip to main content
  • Option name: "controlFlowFlattening"
  • Option values: true/false/0-1

Input / Output

This example showcases how Control Flow Flattening transforms the code. Try it out by changing the input code and see changes apply in real-time.
Input.js

Control Flow Flattening Process

Control Flow Flattening transforms the code into a large, convoluted switch statement. This switch statement is intended to replicate the functionality of the ‘goto’ statement seen in other languages. The switch statement is designed to be difficult to follow, making it harder for reverse engineers to understand the program’s flow.
  • Control Flow Flattening introduces dead code through these methods:
    • Adds fake chunks that are never reached
    • Adds fake jumps to really mess with deobfuscators (“irreducible control flow”)
    • Clones chunks but these chunks are never executed
  • Control Flow Flattening introduces opaque predicates through these methods:
    • Adds fake conditions that are always true or false
    • XOR encrypts strings found within the basic blocks
    • Entangles number literals found within the basic blocks against the current state values
  • Control Flow Flattening mangles the scoped variables through the use of the with statement.
    • This makes identifiers harder to track from static analysis tools.
  • Control Flow Flattening obfuscates IF-statements into equivalent switch-case statements.
  • Control Flow Flattening obfuscates certain eligible functions into equivalent switch-case statements.

Usage Example

The provided code example will obfuscate the file input.js and write the output to a file named output.js.
Usage Example

Enabled In


Performance reduction

Control Flow Flattening reduces the performance of your program. You should adjust the option controlFlowFlattening to be a percentage that is appropriate for your app.

Other notes

Control Flow Flattening only applies to:
  • Blocks of 3 statements or more

See Also