Overview
ThePass abstract class is the base interface for all obfuscation transformations in Refractor. Each pass implements this interface to mutate the Dart kernel AST in a specific way (renaming, string encryption, dead code injection, etc.).
Source: lib/src/engine/runner/pass.dart:5
Interface
Properties
name
Human-readable identifier for this pass. Used in logging, error messages, and the
--passes CLI flag.Methods
run()
Component, mutating it in place. The pass can access shared state through the context parameter.
The Dart kernel AST to transform. This object is mutated in place.
Shared context containing the symbol table, name generator, configuration options, and scope resolution methods.
Passes mutate the
Component directly rather than returning a new one. This is an intentional design choice for performance—Dart kernel ASTs can be large, and in-place mutation avoids expensive copying.Built-in Passes
Refractor includes three built-in passes:RenamePass
Renames identifiers to
_$0, _$1, etc.StringEncryptPass
Encrypts string literals with XOR encoding
DeadCodePass
Injects unreachable
if (false) branchesImplementing a Custom Pass
You can create custom obfuscation passes by implementing this interface:Pass Execution Order
Passes are executed sequentially in the order they’re added to thePassRunner:
Accessing PassContext
ThePassContext provides essential utilities:
See Also
PassRunner
Orchestrates execution of multiple passes
PassContext
Shared context passed to all passes
PassOptions
Configuration options for passes
RefractorEngine
Main engine that uses PassRunner