Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://ZeroSecurity.org
- Imports System
- Imports System.Collections.Generic
- Imports System.Linq
- Imports System.Text
- Imports uVM
- Imports System.IO
- Imports uVM.Virtual_Machine.Structs__Enums__Interfaces
- Imports uVM.Virtual_Machine.Debugger
- Imports uVM.Virtual_Machine.Engine.Classes
- Imports uVM.Virtual_Machine
- Namespace uVM_Test
- Class Program
- Shared vmDebugger As VMDebugger
- Private Shared Sub Main(args As String())
- Dim uVM As uVirtualMachine
- Dim vmOptions As New VMOptionSet()
- vmOptions.AllowDebug = True
- vmOptions.DisplayConsole = True
- vmOptions.DisplayLogo = True
- vmOptions.JITOptimize = False
- vmOptions.ExecSecurity = VMExecutionSecurity.Safe
- uVM = New uVirtualMachine(vmOptions)
- vmDebugger = New VMDebugger(uVM)
- uVM.AttachDebugger(vmDebugger)
- DebuggerEvents.OnBreakPoint += New uVM.Virtual_Machine.Debugger.DebuggerEvents.BreakPointHandler(BreakPoint)
- VMEvents.OnBeforeJITCompilation += New uVM.Virtual_Machine.VMEvents.JITCompilerHandler(BeforeJIT)
- 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"))
- uVM.QuickExecute()
- End Sub
- Public Shared Sub BeforeJIT(o As Object, e As JITCompilerEventArgs)
- 'You can "Hook" JIT engine so that you can decrypt encrypted functions BEFORE they get JITed.
- 'With this you can create a CodeVeil/CliSecure like obfuscator for uCode :)
- Dim evil As Byte() = e.FunctionBody
- End Sub
- Public Shared Sub BreakPoint(o As Object)
- 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)
- 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, _
- vmDebugger.CurrentFunction.EntryPoint)
- Console.WriteLine()
- Dim tmp As uInstruction = Nothing
- 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)
- Console.WriteLine()
- 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)
- Console.ReadLine()
- vmDebugger.ResumeExecution()
- End Sub
- Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
- target = value
- Return value
- End Function
- End Class
- End Namespace
- '=======================================================
- 'Service provided by Telerik (www.telerik.com)
- 'Conversion powered by NRefactory.
- 'Twitter: @telerik, @toddanglin
- 'Facebook: facebook.com/telerik
- '=======================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement