Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Region "Guidelines & Agreements"
  2. ' This Source is Developed & Maintained by Innovators World Wide
  3. ' It is intended for use my the members of MPGH
  4. ' however, this agreement must remain in the source, and credits
  5. ' to both Innovators World Wide & MPGH
  6. ' This is offered as open source to be edited & added to
  7. ' however again, this original statement must be left here.
  8. ' If you contribute anything to this source code, please
  9. ' add a comment with your name and what it is you added,
  10. ' then submit it to the thread on MPGH.net which this is originally posted.
  11. #End Region
  12. #Region "NameSpace_Imports"
  13. Imports System.Collections.Generic
  14. Imports System.Text
  15. Imports System.Runtime.InteropServices
  16. Imports System.Diagnostics
  17. Imports System.ComponentModel
  18. Imports System.Data
  19. Imports System.Drawing
  20. Imports System.Windows.Forms
  21. Imports System.Threading
  22. #End Region
  23. #Region "AIOSDK"
  24. Public Class AIOSDK
  25. #Region "<DllImports-Notes"
  26.     ' Add any needed notes here.
  27. #End Region
  28. #Region "Injector_<DllImports_API_P/nvoke (API PACK)"
  29.     <DllImport("User32.dll")> _
  30.     Public Shared Function MessageBox(ByVal h As Integer, ByVal m As String, ByVal c As String, ByVal type As Integer) As Integer
  31.     End Function
  32.     <DllImport("kernel32.dll")> _
  33.     Public Shared Function OpenProcess(ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
  34.     End Function
  35.     <DllImport("kernel32.dll")> _
  36.     Public Shared Function VirtualAllocEx(ByVal hProcess As Integer, ByVal lpAddress As Integer, ByVal dwSize As Integer, ByVal flAllocationType As Integer, ByVal flProtect As Integer) As Integer
  37.     End Function
  38.     <DllImport("kernel32.dll")> _
  39.     Public Shared Function WriteProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Byte(), ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As UInteger) As Boolean
  40.     End Function
  41.     <DllImport("kernel32.dll")> _
  42.     Public Shared Function GetProcAddress(ByVal hModule As Integer, ByVal lpProcName As String) As Integer
  43.     End Function
  44.     <DllImport("kernel32.dll")> _
  45.     Public Shared Function CreateRemoteThread(ByVal hProcess As Integer, ByVal lpThreadAttributes As Integer, ByVal dwStackSize As Integer, ByVal lpStartAddress As Integer, ByVal lpParameter As Integer, ByVal dwCreationFlags As Integer, _
  46.    ByVal lpThreadId As Integer) As Integer
  47.     End Function
  48.     <DllImport("kernel32.dll")> _
  49.     Public Shared Function WaitForSingleObject(ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer
  50.     End Function
  51.     <DllImport("kernel32.dll")> _
  52.     Public Shared Function CloseHandle(ByVal hObject As Integer) As Integer
  53.     End Function
  54.     <DllImport("User32.dll")> _
  55.     Public Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
  56.     End Function
  57.     <DllImport("User32.dll")> _
  58.     Public Shared Function GetWindowThreaProcessId(ByVal hWnd As Integer, ByRef lpdwProcessId As Integer) As Integer
  59.     End Function
  60.     <DllImport("kernel32")> _
  61.     Public Shared Function CreateRemoteThread(ByVal hProcess As IntPtr, ByVal lpThreadAttributes As IntPtr, ByVal dwStackSize As UInteger, ByVal lpStartAddress As UIntPtr, ByVal lpParameter As IntPtr, ByVal dwCreationFlags As UInteger, _
  62.     ByRef lpThreadId As IntPtr) As IntPtr
  63.     End Function
  64.     <DllImport("kernel32.dll")> _
  65.     Public Shared Function OpenProcess(ByVal dwDesiredAccess As UInt32, ByVal bInheritHandle As Int32, ByVal dwProcessId As Int32) As IntPtr
  66.     End Function
  67.     <DllImport("kernel32.dll")> _
  68.     Public Shared Function CloseHandle(ByVal hObject As IntPtr) As Int32
  69.     End Function
  70.     Private Declare Auto Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As UIntPtr, ByVal dwFreeType As UInteger) As Boolean
  71.     Private Declare Auto Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As UInteger, ByVal flAllocationType As UInteger, ByVal flProtect As UInteger) As IntPtr
  72.     <DllImport("kernel32.dll")> _
  73.     Private Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As String, ByVal nSize As UIntPtr, ByRef lpNumberOfBytesWritten As IntPtr) As Boolean
  74.     End Function
  75.     <DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
  76.     Public Shared Function GetModuleHandle(ByVal lpModuleName As String) As IntPtr
  77.     End Function
  78. #End Region
  79. #Region "Injector Source"
  80.     '''<remarks>Written By Jason Of Mpgh.net</remarks>
  81.    Public Shared Function GetPID(ByVal procName As String) As Integer
  82.         Dim output As Integer
  83.         Dim p As Process() = Process.GetProcessesByName(procName.Replace(".exe", ""))
  84.         If p.Length > 0 Then
  85.             output = Integer.Parse(p(0).Id)
  86.         Else
  87.             output = -1
  88.         End If
  89.         Return output
  90.     End Function
  91.     '''<remarks>Ends Jasons Code </remarks>
  92.    Public Shared Function Inject(ByVal ProcessID As Integer, ByVal DLLPath As String) As [Boolean]
  93.         Dim Proc As Integer
  94.         Dim Addr As Integer
  95.         Dim i As Integer
  96.         Proc = OpenProcess(&H1F0FFF, 1, ProcessID)
  97.         Addr = VirtualAllocEx(Proc, 0, DLLPath.Length, &H1000, &H4)
  98.         If Addr > 0 Then
  99.             Dim ByteP As Byte() = New Byte(DLLPath.Length - 1) {}
  100.             For i = 0 To DLLPath.Length - 1
  101.                 Dim tmp1 As String = DLLPath.Substring(i, 1)
  102.                 Dim tmp2 As Char = Convert.ToChar(tmp1)
  103.                 Dim tmp3 As Integer = Convert.ToInt32(tmp2)
  104.                 ByteP(i) = Convert.ToByte(tmp3)
  105.             Next
  106.             Dim Fwrite As UInteger
  107.             WriteProcessMemory(Proc, Addr, ByteP, DLLPath.Length, Fwrite)
  108.             Dim ALLtmp As Integer
  109.             Dim GetMH As Integer
  110.             ALLtmp = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA")
  111.             GetMH = CreateRemoteThread(Proc, 0, 0, ALLtmp, Addr, 0, _
  112.              0)
  113.             If GetMH > 0 Then
  114.                 WaitForSingleObject(GetMH, 20000)
  115.                 CloseHandle(GetMH)
  116.                 Return True
  117.             Else
  118.                 Return False
  119.             End If
  120.         Else
  121.             Return False
  122.         End If
  123.     End Function
  124. #End Region
  125.  
  126.  
  127. End Class
  128. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement