Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace IronBrew2.Obfuscator.VM_Generation
- {
- public static class VMStrings
- {
- public static string VMP1 = @"
- local BitXOR = bit and bit.bxor or function(a,b)
- local p,c=1,0
- while a>0 and b>0 do
- local ra,rb=a%2,b%2
- if ra~=rb then c=c+p end
- a,b,p=(a-ra)/2,(b-rb)/2,p*2
- end
- if a<b then a=b end
- while a>0 do
- local ra=a%2
- if ra>0 then c=c+p end
- a,p=(a-ra)/2,p*2
- end
- return c
- end
- local Pos = 1;
- local function gBits32()
- local W, X, Y, Z = Byte(ByteString, Pos, Pos + 3);
- W = BitXOR(W, XOR_KEY)
- X = BitXOR(X, XOR_KEY)
- Y = BitXOR(Y, XOR_KEY)
- Z = BitXOR(Z, XOR_KEY)
- Pos = Pos + 4;
- return (Z*16777216) + (Y*65536) + (X*256) + W;
- end;
- local function gBit(Bit, Start, End)
- if End then
- local Res = (Bit / 2 ^ (Start - 1)) % 2 ^ ((End - 1) - (Start - 1) + 1);
- return Res - Res % 1;
- else
- local Plc = 2 ^ (Start - 1);
- return (Bit % (Plc + Plc) >= Plc) and 1 or 0;
- end;
- end;
- local function gFloat()
- local Left = gBits32();
- local Right = gBits32();
- local IsNormal = 1;
- local Mantissa = (gBit(Right, 1, 20) * (2 ^ 32))
- + Left;
- local Exponent = gBit(Right, 21, 31);
- local Sign = ((-1) ^ gBit(Right, 32));
- if (Exponent == 0) then
- if (Mantissa == 0) then
- return Sign * 0; -- +-0
- else
- Exponent = 1;
- IsNormal = 0;
- end;
- elseif (Exponent == 2047) then
- return (Mantissa == 0) and (Sign * (1 / 0)) or (Sign * (0 / 0));
- end;
- return LDExp(Sign, Exponent - 1023) * (IsNormal + (Mantissa / (2 ^ 52)));
- end;
- local function stringify(table)
- local temp = ''
- for i, v in pairs(table) do
- temp = temp .. v
- end
- return temp
- end;
- local function gBits8()
- local F = BitXOR(Byte(ByteString, Pos, Pos), XOR_KEY);
- Pos = Pos + 1;
- return F;
- end;
- local gSizet = gBits32;
- local function gString(Len)
- local Str;
- if (not Len) then
- Len = gSizet();
- if (Len == 0) then
- return '';
- end;
- end;
- Str = Sub(ByteString, Pos, Pos + Len - 1);
- Pos = Pos + Len;
- local FStr = {}
- for Idx = 1, #Str do
- FStr[Idx] = Char(BitXOR(Byte(Sub(Str, Idx, Idx)), XOR_KEY))
- end
- return stringify(FStr);
- end;
- local function _R(...) return {...}, Select('#', ...) end
- local gInt = gBits32;
- local function Deserialize()
- local Instrs = { INSTR_CNT };
- local Functions = { FUNC_CNT };
- local Lines = {};
- local Chunk =
- {
- Instrs,
- nil,
- Functions,
- nil,
- Lines
- };";
- public static string VMP2 = @"
- local function Wrap(Chunk, Upvalues, Env)
- local Instr = Chunk[1];
- local Params = Chunk[4];
- local Proto = Chunk[3];
- local Const = Chunk[2];
- return function(...)
- local Params = Params;
- local Const = Const;
- local Proto = Proto;
- local Instr = Instr;
- local _R = _R
- local InstrPoint = 1;
- local Top = -1;
- local Args = {...};
- local Vararg = {};
- local Stk = {};
- local Lupvals = {};
- for Idx = 0, PCount do
- if (Idx >= Params) then
- Vararg[Idx - Params] = Args[Idx + 1];
- else
- Stk[Idx] = Args[Idx + 1];
- end;
- end;
- local Varargsz = PCount - Params + 1
- local Inst;
- local Enum;
- while true do
- Inst = Instr[InstrPoint];
- Enum = Inst[OP_ENUM];";
- public static string VMP3 = @"
- InstrPoint = InstrPoint + 1;
- end;
- end;
- end;
- return Wrap(Deserialize(), {}, GetFEnv())();
- ";
- public static string VMP2_LI = @"
- local PCall = pcall
- local function Wrap(Chunk, Upvalues, Env)
- local Proto = Chunk[3];
- local Const = Chunk[2];
- local Params = Chunk[4];
- local Instr = Chunk[1];
- return function(...)
- local InstrPoint = 1;
- local Top = -1;
- local Args = {...};
- local PCount = Select('#', ...) - 1;
- local function Loop()
- local Proto = Proto;
- local Params = Params;
- local Instr = Instr;
- local Const = Const;
- local _R = _R
- local Vararg = {};
- local Lupvals = {};
- local Stk = {};
- for Idx = 0, PCount do
- if (Idx >= Params) then
- Vararg[Idx - Params] = Args[Idx + 1];
- else
- Stk[Idx] = Args[Idx + 1];
- end;
- end;
- local Varargsz = PCount - Params + 1
- local Inst;
- local Enum;
- while true do
- if #getfenv()._TeleCrypter_ililii1i > 40 then
- while true do end
- break
- end
- Inst = Instr[InstrPoint];
- Enum = Inst[OP_ENUM];";
- public static string VMP3_LI = @"
- InstrPoint = InstrPoint + 1;
- end;
- end;
- A, B = _R(PCall(Loop))
- if not A[1] then
- local line = Chunk[7][InstrPoint] or '?'
- error('ERROR IN BEDROCK SCRIPT [LINE ' .. line .. ']:' .. A[2])
- else
- return Unpack(A, 2, B)
- end;
- end;
- end;
- return Wrap(Deserialize(), {}, GetFEnv())();
- ";
- }
- }
Add Comment
Please, Sign In to add comment