This is an OPEN SOURCE injector.
What it does:
- Multiple .dll injection
- Only inject selected .dll
- Clear listbox
- Remove selected item from listbox
- Timer checking for process
- Save listbox content
- Load listbox content
- Close after injection
- Checkbox/textbox settings save
- Only adds items to the listbox if they are not duplicated/do not contain "OpenFileDialog1"
- error handling
- commented code
What you should add:
- Multiple selection when selecting .dlls =D Can't be bothered to do that nao
"to select add" for sure is meant to be "to add".
Virus Scan
[php]Public Class Form1
'for reading/writing the listbox content
Dim sFile As String
'declare stuffz for the injection
Private TargetProcessHandle As Integer
Private pfnStartAddr As Integer
Private pszLibFileRemote As String
Private TargetBufferSize As Integer
Public Const PROCESS_VM_READ = &H10
Public Const TH32CS_SNAPPROCESS = &H2
Public Const MEM_COMMIT = 4096
Public Const PAGE_READWRITE = 4
Public Const PROCESS_CREATE_THREAD = (&H2)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_VM_WRITE = (&H20)
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
Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Integer
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
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
Public 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
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
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" (ByVal hObject As Integer) As Integer
Private Sub inject()
Dim LoadLibParamAdr As Integer
Dim Rtn As Integer
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
On Error GoTo 1 ' If error occurs, app will go below to "1:"
TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
'count each listbox item
For i = 0 To ListBox1.Items.Count - 1
If selected.Checked = True Then
pszLibFileRemote = ListBox1.SelectedItem
Else
pszLibFileRemote = ListBox1.Items.Item(i)
End If
TargetBufferSize = 1 + Len(pszLibFileRemote)
LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
Next i
CloseHandle(TargetProcessHandle)
1: labelx24.ForeColor = Color.Red
labelx24.Text = "Error occured" 'error
End Sub
Public Sub ListBox_Save(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamWriter
Dim i As Short
'create a new streamwriter
oStream = New IO.StreamWriter(sFile)
'count each listbox item
For i = 0 To ListBox.Items.Count - 1
oStream.WriteLine(ListBox.Items(i))
Next
'close streamwriter
oStream.Close()
End Sub
Public Sub ListBox_Read(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamReader
Dim sLine As String
' Clear listbox
ListBox.Items.Clear()
' Check if file exists
Dim oFile As New IO.FileInfo(sFile)
'if the list.dat exists then read it...
If oFile.Exists() = True Then
oStream = New IO.StreamReader(sFile)
' read file
Do
'read each line
sLine = oStream.ReadLine()
If IsNothing(sLine) Then Exit Do
'add items to the listbox
ListBox.Items.Add(sLine)
'loop until it's done
Loop
'close the stream
oStream.Close()
End If
End Sub
Private Sub savelb()
'save a list.dat with listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Save(ListBox1, sFile)
End Sub
Private Sub loadlb()
'load a list.dat to fill in listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Read(ListBox1, sFile)
End Sub
Public Function IsProcessOpen(ByVal name As String) As Boolean
'if isprocessopen("process") then...
'if not isprocessopen("process") then...
'get all current running processes
For Each clsProcess As Process In Process.GetProcesses
If clsProcess.ProcessName.Contains(name) Then
Return True
End If
Next
' Do nothing
Return False
End Function
Private Sub checkprocess_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'check if process is running
If Not IsProcessOpen(txtprocess.Text) Then
labelx24.ForeColor = Color.Red
labelx24.Text = "Please start the process..."
Else
labelx24.ForeColor = Color.Green
labelx24.Text = "Process Found!"
End If
End Sub
Private Sub txtprocess_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtprocess.TextChanged
'save current process textbox text in settings
My.Settings.processs = txtprocess.Text
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub inject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdinject.Click
'declare a process
Try
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
'if txtprocess.text = ""
If TargetProcess.Length = 0 Then
MsgBox("Waiting for " & txtprocess.Text)
Else
'do injection
Call inject()
labelx24.Text = "Dll File Injected!"
Timer1.Stop()
End If
Catch
End Try
'save listbox content
savelb()
'set the process
My.Settings.processs = txtprocess.Text
'save settings
My.Settings.Save()
My.Settings.Reload()
'close if 'close checkbox' is checked
If closebox.Checked = True Then
Me.Close()
End If
End Sub
Private Sub selectdll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dll.Click
'only .dlls files are selectable
opf.Title = "Select a .dll"
opf.Filter = "DLL (*.DLL)|*.Dll"
opf.Multiselect = True
'open the open file dialog
opf.ShowDialog()
'add the .dll to the listbox
For Each item As String In opf.FileNames
If Not ListBox1.Items.Contains(item) Then
If Not opf.FileName = "OpenFileDialog1" Then
ListBox1.Items.Add(item)
' dll.Text = System.IO.Path.GetFileName(opf.FileName)
End If
End If
Next item
'save listbox content
savelb()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'load listbox content
loadlb()
'process textbox
txtprocess.Text = My.Settings.processs
'check/uncheck checkboxes
selected.Checked = My.Settings.selectedonly
closebox.Checked = My.Settings.close
End Sub
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclear.Click
'clear listbox(obviously)
ListBox1.Items.Clear()
'save listbox content
savelb()
End Sub
Private Sub removeselected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrs.Click
'remove the selected item
Try
If ListBox1.SelectedIndex <> -1 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
Catch
End Try
'save listbox content
savelb()
End Sub
Private Sub selected_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selected.CheckedChanged
'save checkbox setting
My.Settings.selectedonly = selected.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub closebox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closebox.CheckedChanged
'save checkbox setting
My.Settings.close = closebox.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
End Class
[/php]
Sorry I cannot upload any further virusscan, those sites are rarely working for me -.-
Enjoy.