Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. 'Credits CopyrightPhilly :)
  2. Imports System.Runtime.InteropServices
  3. Imports System.Text
  4. Module Inject
  5. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
  6. Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Integer, ByVal lpAddress As Integer, ByVal dwSize As Integer, ByVal flAllocationType As Integer, ByVal flProtect As Integer) As Integer
  7. Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer() As Byte, ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As UInteger) As Boolean
  8. Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Integer, ByVal lpProcName As String) As Integer
  9. Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Integer
  10. Private Declare Function CreateRemoteThread Lib "kernel32" (ByVal hProcess As Integer, ByVal lpThreadAttributes As Integer, ByVal dwStackSize As Integer, ByVal lpStartAddress As Integer, ByVal lpParameter As Integer, ByVal dwCreationFlags As Integer, ByVal lpThreadId As Integer) As Integer
  11. Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer
  12. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
  13. Public Function inject0r(ByVal ProcessID As Long, ByVal DLLPath As String) As Boolean
  14. On Error GoTo exiterror
  15. Dim DProc As Integer
  16. Dim DAdd As Integer
  17. Dim DWrote As UInteger
  18. Dim DAll As Integer
  19. Dim DThe As Integer
  20. Dim DMHD As Integer
  21. DProc = OpenProcess(&H1F0FFF, 1, ProcessID)
  22. DAdd = VirtualAllocEx(DProc, 0, DLLPath.Length, &H1000, &H4)
  23. If (DAdd > 0) Then
  24. Dim DByte() As Byte
  25. DByte = StrChar(DLLPath)
  26. WriteProcessMemory(DProc, DAdd, DByte, DLLPath.Length, DWrote)
  27. DMHD = GetModuleHandle("kernel32.dll")
  28. DAll = GetProcAddress(DMHD, "LoadLibraryA")
  29. DThe = CreateRemoteThread(DProc, 0, 0, DAll, DAdd, 0, 0)
  30. If (DThe > 0) Then
  31. WaitForSingleObject(DThe, &HFFFF)
  32. CloseHandle(DThe)
  33. Return True
  34. Else
  35. GoTo exiterror
  36. End If
  37. Else
  38. GoTo exiterror
  39. End If
  40. inject0r = True
  41. Exit Function
  42. exiterror:
  43. inject0r = False
  44. End Function
  45. Private Function StrChar(ByRef strString As String) As Byte()
  46. Dim bytTemp() As Byte
  47. Dim i As Short
  48. ReDim bytTemp(0)
  49. For i = 1 To Len(strString)
  50. If bytTemp(UBound(bytTemp)) <> 0 Then ReDim Preserve bytTemp(UBound(bytTemp) + 1)
  51. bytTemp(UBound(bytTemp)) = Asc(Mid(strString, i, 1))
  52. Next i
  53. ReDim Preserve bytTemp(UBound(bytTemp) + 1)
  54. bytTemp(UBound(bytTemp)) = 0
  55. StrChar = bytTemp
  56. End Function
  57. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement