Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Injector
- Dim dlls As New Dictionary(Of String, String)
- Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
- 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
- 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
- Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Integer, ByVal lpProcName As String) As Integer
- Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Integer
- 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
- Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer
- Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
- Private Function InjectDLL(ByVal pID As Integer, ByVal dllLocation As String) As Boolean
- Dim hProcess As Integer = OpenProcess(&H1F0FFF, 1, pID)
- If hProcess = 0 Then Return False
- Dim dllBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(dllLocation)
- Dim allocAddress As Integer = VirtualAllocEx(hProcess, 0, dllBytes.Length, &H1000, &H4)
- If allocAddress = Nothing Then Return False
- Dim kernelMod As Integer = GetModuleHandle("kernel32.dll")
- Dim loadLibAddr = GetProcAddress(kernelMod, "LoadLibraryA")
- If kernelMod = 0 OrElse loadLibAddr = 0 Then Return False
- WriteProcessMemory(hProcess, allocAddress, dllBytes, dllBytes.Length, 0)
- Dim libThread As Integer = CreateRemoteThread(hProcess, 0, 0, loadLibAddr, allocAddress, 0, 0)
- If libThread = 0 Then
- Return False
- Else
- WaitForSingleObject(libThread, 5000)
- CloseHandle(libThread)
- End If
- CloseHandle(hProcess)
- Return True
- End Function
- 'Junk Start
- 'Junk End
- Private Sub Injector_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Timer1.Stop()
- Timer2.Stop()
- Me.TopMost = True
- End Sub
- Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
- Dim FileName As String = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
- Dim DllFileName As String = FileName.Replace("\", "")
- DLL.AddItem(DllFileName)
- dlls.Add(DllFileName, OpenFileDialog1.FileName)
- End Sub
- 'Junk Start
- 'Junk End
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- If DLL.Items.Count > 0 Then
- Dim TargetProcess As Process() = System.Diagnostics.Process.GetProcessesByName(Process.Text)
- If TargetProcess.Length = 0 Then
- Else
- Dim ProcID As Integer = System.Diagnostics.Process.GetProcessesByName(Process.Text)(0).Id
- Timer1.Stop()
- Timer2.Stop()
- For Each inj As KeyValuePair(Of String, String) In dlls
- InjectDLL(ProcID, inj.Value)
- Next
- End If
- End If
- End Sub
- 'Junk Start
- 'Junk End
- Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
- If Process.Text = "" Then
- Timer1.Stop()
- ElseIf DLL.Items.Count = 0 Then
- Timer1.Stop()
- Else
- Dim TargetProcess As Process() = System.Diagnostics.Process.GetProcessesByName(Process.Text)
- If TargetProcess.Length = 0 Then
- Else
- Timer1.Start()
- End If
- End If
- End Sub
- Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
- OpenFileDialog1.Filter = "DLL (*.dll) |*.dll"
- OpenFileDialog1.ShowDialog()
- End Sub
- Private Sub InjectButton_Click(sender As Object, e As EventArgs) Handles InjectButton.Click
- Dim CloseProcess As Process()
- CloseProcess = System.Diagnostics.Process.GetProcessesByName(Process.Text)
- If CloseProcess.Count > 0 Then
- My.Settings.injectdll = "auto"
- My.Settings.Save()
- My.Settings.Reload()
- Timer1.Start()
- My.Settings.close = 1
- My.Settings.Save()
- My.Settings.Reload()
- Timer3.Start()
- Timer4.Start()
- Else
- MessageBox.Show("Process not found.", "Obsiphase's DLL Injector", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End If
- End Sub
- 'Junk Start
- 'Junk End
- Private Sub CopyInfo1_Click(sender As Object, e As EventArgs) Handles CopyInfo1.Click
- My.Computer.Clipboard.SetText("http://steamcommunity.com/id/Obsiphase")
- End Sub
- Private Sub CopyInfo2_Click(sender As Object, e As EventArgs) Handles CopyInfo2.Click
- My.Computer.Clipboard.SetText("Obsiphase#2318")
- End Sub
- Private Sub Title_Click(sender As Object, e As EventArgs) Handles Title.Click
- End Sub
- Private Sub Close_Click(sender As Object, e As EventArgs) Handles Close.Click
- Application.Exit()
- End Sub
- Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
- Progress.Value += 25
- End Sub
- Private Sub Timer4_Tick(sender As Object, e As EventArgs) Handles Timer4.Tick
- If Progress.Maximum Then
- Application.Exit()
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement