XenocodeRCE

Untitled

Jun 24th, 2014
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.13 KB | None | 0 0
  1. Imports Mono.Cecil
  2. Imports Mono.Cecil.Cil
  3. Imports System.Reflection
  4.  
  5. Public Class Patcher
  6.     Public Shared Function PatchNetSeal(ByVal asm As AssemblyDefinition) As Boolean
  7.         Try
  8.             Dim enumerator As IEnumerator(Of TypeDefinition)
  9.             Try
  10.                 enumerator = asm.MainModule.Types.GetEnumerator
  11.                 Do While enumerator.MoveNext
  12.                     Dim current As TypeDefinition = enumerator.Current
  13.                     Try
  14.                         Dim enumerator2 As IEnumerator(Of MethodDefinition)
  15.                         Try
  16.                             enumerator2 = current.Methods.GetEnumerator
  17.                             Do While enumerator2.MoveNext
  18.                                 Dim definition2 As MethodDefinition = enumerator2.Current
  19.                                 Try
  20.                                     If definition2.HasBody Then
  21.                                         Dim enumerator3 As IEnumerator(Of Instruction)
  22.                                         Dim iLProcessor As ILProcessor = definition2.Body.GetILProcessor
  23.                                         Try
  24.                                             enumerator3 = iLProcessor.Body.Instructions.GetEnumerator
  25.                                             Do While enumerator3.MoveNext
  26.                                                 Dim instruction As Instruction = enumerator3.Current
  27.                                                 If ((instruction.OpCode = OpCodes.Ldstr) AndAlso instruction.Operand.ToString.Contains("Unable to initialize due to missing Net Seal ID.")) Then
  28.                                                     Console.WriteLine(("NetSeal Initialize Path Found: " & current.Name & "." & definition2.Name))
  29.                                                     iLProcessor.Replace(iLProcessor.Body.Instructions.Item(0), iLProcessor.Create(OpCodes.Ret))
  30.                                                     Return True
  31.                                                 End If
  32.                                             Loop
  33.                                         Finally
  34.                                             enumerator3.Dispose()
  35.                                         End Try
  36.                                     End If
  37.                                 Catch exception1 As Exception
  38.                                     Console.WriteLine("Error :" & vbNewLine)
  39.                                     Console.WriteLine(exception1)
  40.                                 End Try
  41.                             Loop
  42.                         Finally
  43.                             enumerator2.Dispose()
  44.                         End Try
  45.                     Catch exception2 As Exception
  46.                         Console.WriteLine("Error :" & vbNewLine)
  47.                         Console.WriteLine(exception2)
  48.                     End Try
  49.                 Loop
  50.             Finally
  51.                 enumerator.Dispose()
  52.             End Try
  53.         Catch exception3 As Exception
  54.             Console.WriteLine("Error :" & vbNewLine)
  55.             Console.WriteLine(exception3)
  56.         End Try
  57.         Return False
  58.     End Function
  59. End Class
Advertisement
Add Comment
Please, Sign In to add comment