Guest User

Untitled

a guest
May 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.15 KB | None | 0 0
  1. class Program
  2.     {
  3.         static VMDebugger vmDebugger;
  4.  
  5.         static void Main(string[] args)
  6.         {
  7.             uVirtualMachine uVM;
  8.             VMOptionSet vmOptions = new VMOptionSet();
  9.  
  10.             vmOptions.AllowDebug = true;
  11.             vmOptions.DisplayConsole = true;
  12.             vmOptions.DisplayLogo = true;
  13.             vmOptions.JITOptimize = false;
  14.             vmOptions.ExecSecurity = VMExecutionSecurity.Safe;
  15.             vmOptions.CallSecurity = VMCallSecurity.LocalFramework;
  16.  
  17.  
  18.             uVM = new uVirtualMachine(vmOptions);
  19.             vmDebugger = new VMDebugger(uVM);
  20.             uVM.AttachDebugger(vmDebugger);
  21.  
  22.             vmDebugger.OnBreakPoint += new uVM.Virtual_Machine.Debugger.DebuggerEvents.BreakPointHandler(BreakPoint);
  23.             uVM.OnBeforeJITCompilation += new uVM.Virtual_Machine.Events.JITCompilerHandler(BeforeJIT);
  24.  
  25.             uVM.LoadImage(Encoding.Default.GetBytes(
  26.                 "maxstacksize = 5\n" +
  27.                 "loadstr correct\n" +
  28.                 "loadstr correct\n" +
  29.                 "comp\n" +
  30.                 "jie 4\n" +
  31.                 "loadstr You failed! :)\n" +
  32.                 "println\n" +
  33.                 "wait\n" +
  34.                 "end\n" +
  35.                 "loadstr Success! :D\n" +
  36.                 "println\n" +
  37.                 "wait\n" +
  38.                 "end"
  39.                 ));
  40.  
  41.  
  42.             uVM.QuickExecute();
  43.         }
  44.  
  45.         public static void BeforeJIT(object o, JITCompilerEventArgs e)
  46.         {
  47.             //You can "Hook" JIT engine so that you can decrypt encrypted functions BEFORE they get JITed. Like in CodeVeil or CliSecure.
  48.             byte[] evil = e.FunctionBody;
  49.         }
  50.  
  51.         public static void BreakPoint(object o)
  52.         {
  53.             Console.WriteLine("Current Instruction:\n\nOpcode: {0}\nOperand: {1}\nSize: {2}\nIndex: {3}\nParentFunction: {4}", vmDebugger.CurrentInstruction.OpCode.ToString().ToLower(), vmDebugger.CurrentInstruction.Operand.ToString(), vmDebugger.CurrentInstruction.RequiredBytes, vmDebugger.CurrentInstruction.Index, vmDebugger.CurrentInstruction.ParentFunction.Name);
  54.             Console.WriteLine("\nCurrent Function:\n\nName: {0}\nSize: {1}\nStackCount: {2}\nMaxStackSize: {3}\nInstruction Count: {4}\nEntry Point?: {5}", vmDebugger.CurrentFunction.Name, vmDebugger.CurrentFunction.Size, vmDebugger.CurrentFunction.Stack.Count, vmDebugger.CurrentFunction.MaxStackSize, vmDebugger.CurrentFunction.Instructions.Count, vmDebugger.CurrentFunction.EntryPoint);
  55.             Console.WriteLine();
  56.             uInstruction tmp = null;
  57.             Console.WriteLine("Example; get first instruction from current function with opcode END:\n\nName: {0}\nIndex: {1}", (tmp = vmDebugger.RetrieveInstruction(vmDebugger.CurrentFunction, _OpCodes.END)).OpCode.ToString(), tmp.Index);
  58.             Console.WriteLine();
  59.             Console.WriteLine("Example; get second instruction from current function with opcode LOADSTR:\n\nName: {0}\nIndex: {1}", (tmp = vmDebugger.RetrieveInstruction(vmDebugger.CurrentFunction, _OpCodes.LOADSTR, 1)).OpCode.ToString(), tmp.Index);
  60.             Console.ReadLine();
  61.  
  62.             vmDebugger.Resume();
  63.         }
Add Comment
Please, Sign In to add comment