YT_REALmrsiniac

Untitled

Apr 9th, 2022 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.75 KB | None | 0 0
  1. namespace IronBrew2.Obfuscator.VM_Generation
  2. {
  3.     public static class VMStrings
  4.     {
  5.  
  6.         public static string VMP1 = @"
  7.  
  8. local BitXOR = bit and bit.bxor or function(a,b)
  9.    local p,c=1,0
  10.    while a>0 and b>0 do
  11.        local ra,rb=a%2,b%2
  12.        if ra~=rb then c=c+p end
  13.        a,b,p=(a-ra)/2,(b-rb)/2,p*2
  14.    end
  15.  
  16.    if a<b then a=b end
  17.    while a>0 do
  18.        local ra=a%2
  19.        if ra>0 then c=c+p end
  20.        a,p=(a-ra)/2,p*2
  21.    end
  22.    return c
  23. end
  24.  
  25. local Pos = 1;
  26.  
  27. local function gBits32()
  28.     local W, X, Y, Z = Byte(ByteString, Pos, Pos + 3);
  29.     W = BitXOR(W, XOR_KEY) 
  30.     X = BitXOR(X, XOR_KEY) 
  31.     Y = BitXOR(Y, XOR_KEY) 
  32.     Z = BitXOR(Z, XOR_KEY)
  33.     Pos = Pos + 4;
  34.    return (Z*16777216) + (Y*65536) + (X*256) + W;
  35. end;
  36.  
  37. local function gBit(Bit, Start, End)
  38.     if End then    
  39.         local Res = (Bit / 2 ^ (Start - 1)) % 2 ^ ((End - 1) - (Start - 1) + 1);
  40.         return Res - Res % 1;
  41.     else       
  42.         local Plc = 2 ^ (Start - 1);
  43.        return (Bit % (Plc + Plc) >= Plc) and 1 or 0;
  44.     end;
  45. end;
  46.  
  47. local function gFloat()
  48.     local Left = gBits32();
  49.     local Right = gBits32();
  50.     local IsNormal = 1;
  51.     local Mantissa = (gBit(Right, 1, 20) * (2 ^ 32))
  52.                     + Left;
  53.     local Exponent = gBit(Right, 21, 31);
  54.     local Sign = ((-1) ^ gBit(Right, 32));
  55.     if (Exponent == 0) then
  56.         if (Mantissa == 0) then
  57.             return Sign * 0; -- +-0
  58.         else
  59.             Exponent = 1;
  60.             IsNormal = 0;
  61.         end;
  62.     elseif (Exponent == 2047) then
  63.        return (Mantissa == 0) and (Sign * (1 / 0)) or (Sign * (0 / 0));
  64.     end;
  65.     return LDExp(Sign, Exponent - 1023) * (IsNormal + (Mantissa / (2 ^ 52)));
  66. end;
  67.  
  68. local function stringify(table)
  69.     local temp = ''
  70.     for i, v in pairs(table) do
  71.         temp = temp .. v
  72.     end
  73.  
  74.    return temp
  75. end;
  76.  
  77. local function gBits8()
  78.     local F = BitXOR(Byte(ByteString, Pos, Pos), XOR_KEY);  
  79.     Pos = Pos + 1;
  80.    return F;
  81. end;
  82.  
  83. local gSizet = gBits32;
  84. local function gString(Len)
  85.     local Str;
  86.    if (not Len) then
  87.        Len = gSizet();      
  88.     if (Len == 0) then
  89.            return '';
  90.        end;
  91.    end;
  92.    
  93.     Str = Sub(ByteString, Pos, Pos + Len - 1);
  94.     Pos = Pos + Len;
  95.     local FStr = {}
  96.     for Idx = 1, #Str do       
  97.         FStr[Idx] = Char(BitXOR(Byte(Sub(Str, Idx, Idx)), XOR_KEY))
  98.     end
  99.     return stringify(FStr);
  100. end;
  101.  
  102.  
  103. local function _R(...) return {...}, Select('#', ...) end
  104. local gInt = gBits32;
  105. local function Deserialize()
  106.    local Instrs = { INSTR_CNT };  
  107.     local Functions = { FUNC_CNT };
  108.     local Lines = {};
  109.     local Chunk =
  110.     {
  111.         Instrs,
  112.         nil,
  113.         Functions,
  114.         nil,
  115.         Lines
  116.     };";
  117.  
  118.         public static string VMP2 = @"
  119. local function Wrap(Chunk, Upvalues, Env)  
  120.     local Instr  = Chunk[1];   
  121.     local Params = Chunk[4];   
  122.     local Proto  = Chunk[3];   
  123.     local Const  = Chunk[2];
  124.     return function(...)       
  125.         local Params = Params;     
  126.         local Const  = Const;
  127.         local Proto  = Proto;
  128.         local Instr  = Instr;
  129.         local _R = _R
  130.         local InstrPoint = 1;
  131.         local Top = -1;
  132.         local Args  = {...};
  133.         local Vararg = {};
  134.         local Stk       = {};
  135.         local Lupvals   = {};
  136.  
  137.         for Idx = 0, PCount do
  138.             if (Idx >= Params) then            
  139.                 Vararg[Idx - Params] = Args[Idx + 1];
  140.             else               
  141.                 Stk[Idx] = Args[Idx + 1];
  142.             end;
  143.         end;
  144.         local Varargsz = PCount - Params + 1
  145.         local Inst;    
  146.         local Enum;
  147.         while true do
  148.             Inst        = Instr[InstrPoint];
  149.             Enum        = Inst[OP_ENUM];";
  150.  
  151.         public static string VMP3 = @"             
  152.             InstrPoint  = InstrPoint + 1;
  153.         end;
  154.     end;
  155. end;   
  156. return Wrap(Deserialize(), {}, GetFEnv())();
  157. ";
  158.         public static string VMP2_LI = @"
  159.  
  160. local PCall = pcall
  161.  
  162. local function Wrap(Chunk, Upvalues, Env)
  163.     local Proto = Chunk[3];
  164.     local Const = Chunk[2];
  165.     local Params = Chunk[4];
  166.     local Instr = Chunk[1];
  167.  
  168.     return function(...)   
  169.         local InstrPoint = 1;  
  170.         local Top = -1;
  171.         local Args = {...};
  172.         local PCount = Select('#', ...) - 1;
  173.         local function Loop()
  174.                        
  175.             local Proto  = Proto;  
  176.             local Params = Params; 
  177.             local Instr  = Instr;  
  178.             local Const  = Const;
  179.             local _R = _R  
  180.             local Vararg = {};
  181.             local Lupvals   = {};  
  182.             local Stk       = {};
  183.    
  184.             for Idx = 0, PCount do
  185.                 if (Idx >= Params) then    
  186.                     Vararg[Idx - Params] = Args[Idx + 1];
  187.                 else               
  188.                     Stk[Idx] = Args[Idx + 1];
  189.                 end;
  190.             end;
  191.    
  192.             local Varargsz = PCount - Params + 1
  193.             local Inst;
  194.             local Enum;
  195.             while true do
  196.                 if #getfenv()._TeleCrypter_ililii1i > 40 then
  197.                     while true do end
  198.                     break
  199.                 end
  200.                 Inst        = Instr[InstrPoint];           
  201.                 Enum        = Inst[OP_ENUM];";
  202.  
  203.         public static string VMP3_LI = @"      
  204.                 InstrPoint  = InstrPoint + 1;
  205.             end;
  206.         end;
  207.  
  208.         A, B = _R(PCall(Loop))
  209.         if not A[1] then
  210.             local line = Chunk[7][InstrPoint] or '?'       
  211.             error('ERROR IN BEDROCK SCRIPT [LINE ' .. line .. ']:' .. A[2])
  212.         else       
  213.             return Unpack(A, 2, B)
  214.         end;
  215.     end;
  216. end;   
  217. return Wrap(Deserialize(), {}, GetFEnv())();
  218. ";
  219.     }
  220. }
Add Comment
Please, Sign In to add comment