Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. Public Class Injector
  2.  
  3. Dim dlls As New Dictionary(Of String, String)
  4.  
  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.  
  14. Private Function InjectDLL(ByVal pID As Integer, ByVal dllLocation As String) As Boolean
  15.  
  16. Dim hProcess As Integer = OpenProcess(&H1F0FFF, 1, pID)
  17. If hProcess = 0 Then Return False
  18. Dim dllBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(dllLocation)
  19. Dim allocAddress As Integer = VirtualAllocEx(hProcess, 0, dllBytes.Length, &H1000, &H4)
  20. If allocAddress = Nothing Then Return False
  21. Dim kernelMod As Integer = GetModuleHandle("kernel32.dll")
  22. Dim loadLibAddr = GetProcAddress(kernelMod, "LoadLibraryA")
  23. If kernelMod = 0 OrElse loadLibAddr = 0 Then Return False
  24. WriteProcessMemory(hProcess, allocAddress, dllBytes, dllBytes.Length, 0)
  25. Dim libThread As Integer = CreateRemoteThread(hProcess, 0, 0, loadLibAddr, allocAddress, 0, 0)
  26.  
  27. If libThread = 0 Then
  28. Return False
  29. Else
  30. WaitForSingleObject(libThread, 5000)
  31. CloseHandle(libThread)
  32. End If
  33. CloseHandle(hProcess)
  34. Return True
  35. End Function
  36.  
  37. 'Junk Start
  38. 'Junk End
  39.  
  40. Private Sub Injector_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  41. Timer1.Stop()
  42. Timer2.Stop()
  43. Me.TopMost = True
  44. End Sub
  45.  
  46. Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
  47. Dim FileName As String = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
  48. Dim DllFileName As String = FileName.Replace("\", "")
  49. DLL.AddItem(DllFileName)
  50. dlls.Add(DllFileName, OpenFileDialog1.FileName)
  51. End Sub
  52.  
  53. 'Junk Start
  54. 'Junk End
  55.  
  56. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  57. If DLL.Items.Count > 0 Then
  58. Dim TargetProcess As Process() = System.Diagnostics.Process.GetProcessesByName(Process.Text)
  59. If TargetProcess.Length = 0 Then
  60.  
  61. Else
  62. Dim ProcID As Integer = System.Diagnostics.Process.GetProcessesByName(Process.Text)(0).Id
  63. Timer1.Stop()
  64. Timer2.Stop()
  65.  
  66. For Each inj As KeyValuePair(Of String, String) In dlls
  67. InjectDLL(ProcID, inj.Value)
  68. Next
  69. End If
  70. End If
  71. End Sub
  72.  
  73. 'Junk Start
  74. 'Junk End
  75.  
  76. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  77. If Process.Text = "" Then
  78.  
  79. Timer1.Stop()
  80. ElseIf DLL.Items.Count = 0 Then
  81. Timer1.Stop()
  82. Else
  83. Dim TargetProcess As Process() = System.Diagnostics.Process.GetProcessesByName(Process.Text)
  84. If TargetProcess.Length = 0 Then
  85.  
  86. Else
  87. Timer1.Start()
  88. End If
  89. End If
  90. End Sub
  91.  
  92. Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
  93. OpenFileDialog1.Filter = "DLL (*.dll) |*.dll"
  94. OpenFileDialog1.ShowDialog()
  95. End Sub
  96.  
  97. Private Sub InjectButton_Click(sender As Object, e As EventArgs) Handles InjectButton.Click
  98.  
  99. Dim CloseProcess As Process()
  100. CloseProcess = System.Diagnostics.Process.GetProcessesByName(Process.Text)
  101. If CloseProcess.Count > 0 Then
  102. My.Settings.injectdll = "auto"
  103. My.Settings.Save()
  104. My.Settings.Reload()
  105. Timer1.Start()
  106.  
  107. My.Settings.close = 1
  108. My.Settings.Save()
  109. My.Settings.Reload()
  110.  
  111. Timer3.Start()
  112. Timer4.Start()
  113. Else
  114. MessageBox.Show("Process not found.", "Obsiphase's DLL Injector", MessageBoxButtons.OK, MessageBoxIcon.Error)
  115. End If
  116. End Sub
  117.  
  118. 'Junk Start
  119. 'Junk End
  120.  
  121. Private Sub CopyInfo1_Click(sender As Object, e As EventArgs) Handles CopyInfo1.Click
  122. My.Computer.Clipboard.SetText("http://steamcommunity.com/id/Obsiphase")
  123. End Sub
  124.  
  125. Private Sub CopyInfo2_Click(sender As Object, e As EventArgs) Handles CopyInfo2.Click
  126. My.Computer.Clipboard.SetText("Obsiphase#2318")
  127. End Sub
  128.  
  129. Private Sub Title_Click(sender As Object, e As EventArgs) Handles Title.Click
  130.  
  131. End Sub
  132.  
  133. Private Sub Close_Click(sender As Object, e As EventArgs) Handles Close.Click
  134. Application.Exit()
  135. End Sub
  136.  
  137. Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
  138. Progress.Value += 25
  139.  
  140. End Sub
  141.  
  142. Private Sub Timer4_Tick(sender As Object, e As EventArgs) Handles Timer4.Tick
  143. If Progress.Maximum Then
  144. Application.Exit()
  145. End If
  146. End Sub
  147. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement