Advertisement
midlow

Untitled

Dec 28th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. Imports System.IO
  2. Public Class Form1
  3. Private TargetProcessHandle As Integer
  4. Private pfnStartAddr As Integer
  5. Private pszLibFileRemote As String
  6. Private TargetBufferSize As Integer
  7. Public Const PROCESS_VM_READ = &H10
  8. Public Const TH32CS_SNAPPROCESS = &H2
  9. Public Const MEM_COMMIT = 4096
  10. Public Const PAGE_READWRITE = 4
  11. Public Const PROCESS_CREATE_THREAD = (&H2)
  12. Public Const PROCESS_VM_OPERATION = (&H8)
  13. Public Const PROCESS_VM_WRITE = (&H20)
  14. Dim DLLFileName As String
  15. Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As String, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
  16. Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Integer
  17. Public 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
  18. Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As String, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
  19. Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Integer, ByVal lpProcName As String) As Integer
  20. Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Integer
  21. Public 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, ByRef lpThreadId As Integer) As Integer
  22. Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
  23. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
  24. Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" (ByVal hObject As Integer) As Integer
  25. Dim ExeName As String = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
  26. Private Sub Inject()
  27. On Error GoTo 1
  28. Dim TargetProcess As Process() = Process.GetProcessesByName("csgo")
  29. TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
  30. pszLibFileRemote = Directory.GetCurrentDirectory() + "\" + ComboBox1.SelectedItem.ToString + ".dll"
  31. pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
  32. TargetBufferSize = 1 + Len(pszLibFileRemote)
  33. Dim Rtn As Integer
  34. Dim LoadLibParamAdr As Integer
  35. LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
  36. Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
  37. CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
  38. CloseHandle(TargetProcessHandle)
  39. 1: Me.Show()
  40. End Sub
  41. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  42. ezinjector.Name = "ezinjector"
  43. ezinjector.Text = "ezinjector"
  44. Dim tempthing As String = ""
  45. Dim tempthing2 As String = ""
  46. Dim files() As String = IO.Directory.GetFiles(Directory.GetCurrentDirectory())
  47. For Each file As String In files
  48. tempthing2 = Path.GetExtension(file)
  49. tempthing = file.Replace(Directory.GetCurrentDirectory() + "\", "")
  50. tempthing = tempthing.Replace(tempthing2, "")
  51. If tempthing2 = ".dll" Then
  52. If tempthing.EndsWith(".x32") Then
  53. Else
  54. ComboBox1.Items.Add(tempthing)
  55. End If
  56. End If
  57. Next
  58. End Sub
  59. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  60.  
  61. End Sub
  62.  
  63. Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
  64.  
  65. End Sub
  66.  
  67. Private Sub ezinjector_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  68.  
  69. End Sub
  70.  
  71. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  72. Dim TargetProcess As Process() = Process.GetProcessesByName("csgo")
  73. If TargetProcess.Length = 0 Then
  74. Me.Label1.Text = ("Status: Waiting")
  75. Else
  76. Me.Label1.Text = "Status: Injected"
  77. Call Inject()
  78. End If
  79. End Sub
  80. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement