TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pw4k/ironbrew-2/llms.txt
Use this file to discover all available pages before exploring further.
ObfuscationContext class encapsulates the state and randomization data used throughout the obfuscation pipeline. It is automatically created by the obfuscation process and manages instruction mappings, execution order shuffling, and encryption keys.
Constructor
The root bytecode chunk to obfuscate. This is obtained by deserializing compiled Lua bytecode.
Properties
Bytecode Structure
The root chunk containing all bytecode instructions, constants, and nested functions.
Maps standard Lua opcodes to their virtualized equivalents. Used by the VM generator to translate bytecode into custom VM instructions.
Execution Order Randomization
Randomized order for deserializing chunk components. Shuffles the sequence of:
ParameterCount- Function parameter countStringTable- String constant tableInstructions- Bytecode instructionsFunctions- Nested function definitionsLineInfo- Debug line information
Randomized order for deserializing instruction format 1 fields (Type, A, B, C registers).
Randomized order for deserializing instruction format 2 fields (Op, Bx, D operands).
Randomized mapping for constant type encoding (0-3). Shuffles the order in which constant types are identified.
Encryption Keys
Primary XOR key (0-255) used for bytecode encryption. Randomly generated during context initialization.
First instruction XOR key (0-255) for additional instruction-level encryption. Randomly generated during context initialization.
Second instruction XOR key (0-255) for multi-layer instruction encryption. Randomly generated during context initialization.
Enumerations
ChunkStep
Defines the components of a chunk that can be shuffled:InstructionStep1
Defines fields for instruction format 1:InstructionStep2
Defines fields for instruction format 2:Initialization Behavior
When a newObfuscationContext is created, it automatically:
- Stores the bytecode chunk for VM generation
- Shuffles chunk deserialization order - Randomizes the sequence in which chunk components are processed
- Shuffles instruction deserialization order - Randomizes both instruction format orderings
- Shuffles constant type mapping - Randomizes constant type encoding
- Generates encryption keys - Creates three random XOR keys for bytecode encryption
Usage in Obfuscation Pipeline
The context is created and used internally by theIB2.Obfuscate method:
Randomization Impact
Each obfuscation run produces unique output due to randomized:- Chunk component deserialization order
- Instruction field access patterns
- Constant type encoding
- XOR encryption keys
Example
While you typically don’t createObfuscationContext directly, here’s how it’s used internally:
The
ObfuscationContext is an internal implementation detail. You don’t need to create or manipulate it directly when using the IB2.Obfuscate method.Source Reference
Source:IronBrew2/Obfuscator/ObfuscationContext.cs:37