Advertisement
InfinityExistz

UbVMware

Jan 18th, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.50 KB | None | 0 0
  1. //http://ZeroSecurity.org
  2. Imports System
  3. Imports System.Collections.Generic
  4. Imports System.Linq
  5. Imports System.Text
  6. Imports uVM
  7. Imports System.IO
  8. Imports uVM.Virtual_Machine.Structs__Enums__Interfaces
  9. Imports uVM.Virtual_Machine.Debugger
  10. Imports uVM.Virtual_Machine.Engine.Classes
  11. Imports uVM.Virtual_Machine
  12.  
  13.  
  14. Namespace uVM_Test
  15.         Class Program
  16.                 Shared vmDebugger As VMDebugger
  17.  
  18.                 Private Shared Sub Main(args As String())
  19.                         Dim uVM As uVirtualMachine
  20.                         Dim vmOptions As New VMOptionSet()
  21.  
  22.                         vmOptions.AllowDebug = True
  23.                         vmOptions.DisplayConsole = True
  24.                         vmOptions.DisplayLogo = True
  25.                         vmOptions.JITOptimize = False
  26.                         vmOptions.ExecSecurity = VMExecutionSecurity.Safe
  27.  
  28.                         uVM = New uVirtualMachine(vmOptions)
  29.                         vmDebugger = New VMDebugger(uVM)
  30.                         uVM.AttachDebugger(vmDebugger)
  31.  
  32.                        
  33.                         DebuggerEvents.OnBreakPoint += New uVM.Virtual_Machine.Debugger.DebuggerEvents.BreakPointHandler(BreakPoint)
  34.                         VMEvents.OnBeforeJITCompilation += New uVM.Virtual_Machine.VMEvents.JITCompilerHandler(BeforeJIT)
  35.  
  36.                        
  37.                         uVM.LoadImage(Encoding.[Default].GetBytes("maxstacksize = 5" & vbLf + "loadstr correct" & vbLf + "break" & vbLf + "loadstr correct" & vbLf + "comp" & vbLf + "jie.c 9" & vbLf + "loadstr You failed! :)" & vbLf + "println" & vbLf + "wait" & vbLf + "end" & vbLf + "loadstr Success! :D" & vbLf + "println" & vbLf + "wait" & vbLf + "end"))
  38.  
  39.                         uVM.QuickExecute()
  40.                 End Sub
  41.  
  42.                 Public Shared Sub BeforeJIT(o As Object, e As JITCompilerEventArgs)
  43.                         'You can "Hook" JIT engine so that you can decrypt encrypted functions BEFORE they get JITed.
  44.                         'With this you can create a CodeVeil/CliSecure like obfuscator for uCode :)
  45.                         Dim evil As Byte() = e.FunctionBody
  46.                 End Sub
  47.  
  48.                 Public Shared Sub BreakPoint(o As Object)
  49.                         Console.WriteLine("Current Instruction:" & vbLf & vbLf & "Opcode: {0}" & vbLf & "Operand: {1}" & vbLf & "Size: {2}" & vbLf & "Index: {3}" & vbLf & "ParentFunction: {4}", vmDebugger.CurrentInstruction.OpCode.ToString().ToLower(), vmDebugger.CurrentInstruction.Operand.ToString(), vmDebugger.CurrentInstruction.RequiredBytes, vmDebugger.CurrentInstruction.Index, vmDebugger.CurrentInstruction.ParentFunction.Name)
  50.  
  51.                         Console.WriteLine(vbLf & "Current Function:" & vbLf & vbLf & "Name: {0}" & vbLf & "Size: {1}" & vbLf & "StackCount: {2}" & vbLf & "MaxStackSize: {3}" & vbLf & "Instruction Count: {4}" & vbLf & "Entry Point?: {5}", vmDebugger.CurrentFunction.Name, vmDebugger.CurrentFunction.Size, vmDebugger.CurrentFunction.Stack.Count, vmDebugger.CurrentFunction.MaxStackSize, vmDebugger.CurrentFunction.Instructions.Count, _
  52.                                 vmDebugger.CurrentFunction.EntryPoint)
  53.  
  54.                         Console.WriteLine()
  55.                         Dim tmp As uInstruction = Nothing
  56.  
  57.                         Console.WriteLine("Example; get first instruction from current function with opcode END:" & vbLf & vbLf & "Name: {0}" & vbLf & "Index: {1}", (InlineAssignHelper(tmp, vmDebugger.RetrieveInstruction(vmDebugger.CurrentFunction, _OpCodes.[END]))).OpCode.ToString(), tmp.Index)
  58.  
  59.                         Console.WriteLine()
  60.  
  61.                         Console.WriteLine("Example; get second instruction from current function with opcode LOADSTR:" & vbLf & vbLf & "Name: {0}" & vbLf & "Index: {1}", (InlineAssignHelper(tmp, vmDebugger.RetrieveInstruction(vmDebugger.CurrentFunction, _OpCodes.LOADSTR, 1))).OpCode.ToString(), tmp.Index)
  62.  
  63.                         Console.ReadLine()
  64.  
  65.                         vmDebugger.ResumeExecution()
  66.                 End Sub
  67.                 Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
  68.                         target = value
  69.                         Return value
  70.                 End Function
  71.         End Class
  72. End Namespace
  73.  
  74. '=======================================================
  75. 'Service provided by Telerik (www.telerik.com)
  76. 'Conversion powered by NRefactory.
  77. 'Twitter: @telerik, @toddanglin
  78. 'Facebook: facebook.com/telerik
  79. '=======================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement