The opcode system in IronBrew 2 translates standard Lua 5.1 bytecode instructions into obfuscated virtual machine operations. Each opcode variant handles different operand configurations and generates corresponding Lua code.Documentation 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.
VOpcode Base Class
All virtual opcodes inherit from the abstractVOpcode class:
Methods
- IsInstruction - Returns
trueif the given bytecode instruction matches this opcode variant - GetObfuscated - Generates the Lua code that implements this opcode’s behavior
- Mutate - Modifies instruction operands before serialization (e.g., adjusting constant indices)
Standard Opcodes
Arithmetic Operations
Each arithmetic opcode has multiple variants based on whether operands are registers or constants:OpAdd (Addition)
OpAdd, OpAddB, OpAddC, OpAddBC
Other Arithmetic Opcodes:
OpSub- SubtractionOpMul- MultiplicationOpDiv- DivisionOpMod- ModuloOpPow- ExponentiationOpUnm- Unary minus
Comparison Operations
OpEq- Equality testOpLt- Less thanOpLe- Less than or equalOpGt- Greater thanOpGe- Greater than or equalOpNe- Not equal
Logical Operations
OpNot- Logical NOTOpTest- Conditional testOpTestSet- Conditional test and assignment
Data Movement
OpMove
OpLoadK (Load Constant)
OpLoadNil- Load nil valuesOpLoadBool- Load boolean constantOpLoadStr- Load string constant
Table Operations
OpGetTable
OpGetTable- Read from tableOpSetTable- Write to tableOpNewTable- Create new tableOpSetList- Batch initialize table elementsOpSelf- Method call preparation
Function Operations
OpCall (Function Call)
The call instruction has many variants based on argument count (B) and return count (C):OpCall, OpCallB0, OpCallB1, OpCallB2, OpCallC0, OpCallC1, OpCallC2, and combinations
Other Function Opcodes:
OpTailCall- Tail call optimizationOpReturn- Return from functionOpClosure- Create closureOpVarArg- Variable argument access
Control Flow
OpJmp- Unconditional jumpOpForLoop- Numeric for loop iterationOpForPrep- Numeric for loop initializationOpTForLoop- Generic for loop iteration
Environment Operations
OpGetGlobal- Read global variableOpSetGlobal- Write global variableOpGetUpval- Read upvalueOpSetUpval- Write upvalueOpSetFEnv- Set function environmentOpClose- Close upvalues
Stack Operations
OpSetTop- Adjust stack topOpNewStk- Allocate stack slotsOpPushStk- Push to stack
Utility Operations
OpLen- Length operator (#)OpConcat- String concatenation
Special Opcode Types
OpMutated (Register Shuffling)
Wraps an opcode with shuffled register operands to increase diversity:- Original:
Stk[A] = Stk[B] + Stk[C] - Mutated:
Stk[B] = Stk[C] + Stk[A](registers shuffled [1, 2, 0])
OpSuperOperator (Instruction Fusion)
Combines multiple consecutive instructions into a single opcode:- Mega Super Operators: 60-80 instructions combined
- Mini Super Operators: 5-10 instructions combined
- Reduces opcode dispatch overhead
- Harder to identify individual instruction boundaries
- Combines local variable declarations
- Cannot cross control flow boundaries (jumps, branches)
- Skips closure upvalue pseudoinstructions
- Requires exact sequence match
Opcode Dispatch
Opcodes are dispatched using a binary search tree for O(log n) performance:Instruction Format
Instructions in the VM use a 4-element array:- Register operands: 0-255
- Constant operands: > 255 (index - 255 after mutation)
Complete Opcode List
The following opcodes are implemented (based on Lua 5.1 instruction set):| Category | Opcodes |
|---|---|
| Arithmetic | Add, Sub, Mul, Div, Mod, Pow, Unm |
| Comparison | Eq, Lt, Le, Gt, Ge, Ne |
| Logical | Not, Test, TestSet |
| Data Movement | Move, LoadK, LoadStr, LoadNil, LoadBool |
| Tables | GetTable, SetTable, NewTable, SetList, Self |
| Functions | Call, TailCall, Return, Closure, VarArg |
| Control Flow | Jmp, ForLoop, ForPrep, TForLoop |
| Environment | GetGlobal, SetGlobal, GetUpval, SetUpval, SetFEnv, Close |
| Stack | SetTop, NewStk, PushStk |
| Utility | Len, Concat |
| Special | Mutated, SuperOperator |
Example: OpAdd Transformation
Original Lua:Related
- Generator - VM generation orchestration
- Serializer - Bytecode encoding
- ObfuscationContext - Shared state