Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. --------------------------------------------------
  2. CODINGZA DLL INJECT
  3. ------------------------------------------------
  4. '''''Imports
  5. Imports System.Threading
  6.  
  7. ''''Class
  8. Private TargetProcessHandle As Integer
  9. Private pfnStartAddr As Integer
  10. Private pszLibFileRemote As String
  11. Private TargetBufferSize As Integer
  12. Public Const PROCESS_VM_READ = &H10
  13. Public Const TH32CS_SNAPPROCESS = &H2
  14. Public Const MEM_COMMIT = 4096
  15. Public Const PAGE_READWRITE = 4
  16. Public Const PROCESS_CREATE_THREAD = (&H2)
  17. Public Const PROCESS_VM_OPERATION = (&H8)
  18. Public Const PROCESS_VM_WRITE = (&H20)
  19. Public Declare Function ReadProcessMemory Lib "kernel32" ( _
  20. ByVal hProcess As Integer, _
  21. ByVal lpBaseAddress As Integer, _
  22. ByVal lpBuffer As String, _
  23. ByVal nSize As Integer, _
  24. ByRef lpNumberOfBytesWritten As Integer) As Integer
  25. Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" ( _
  26. ByVal lpLibFileName As String) As Integer
  27. Public Declare Function VirtualAllocEx Lib "kernel32" ( _
  28. ByVal hProcess As Integer, _
  29. ByVal lpAddress As Integer, _
  30. ByVal dwSize As Integer, _
  31. ByVal flAllocationType As Integer, _
  32. ByVal flProtect As Integer) As Integer
  33. Public Declare Function WriteProcessMemory Lib "kernel32" ( _
  34. ByVal hProcess As Integer, _
  35. ByVal lpBaseAddress As Integer, _
  36. ByVal lpBuffer As String, _
  37. ByVal nSize As Integer, _
  38. ByRef lpNumberOfBytesWritten As Integer) As Integer
  39. Public Declare Function GetProcAddress Lib "kernel32" ( _
  40. ByVal hModule As Integer, ByVal lpProcName As String) As Integer
  41. Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _
  42. ByVal lpModuleName As String) As Integer
  43. Public Declare Function CreateRemoteThread Lib "kernel32" ( _
  44. ByVal hProcess As Integer, _
  45. ByVal lpThreadAttributes As Integer, _
  46. ByVal dwStackSize As Integer, _
  47. ByVal lpStartAddress As Integer, _
  48. ByVal lpParameter As Integer, _
  49. ByVal dwCreationFlags As Integer, _
  50. ByRef lpThreadId As IntPtr) As Integer
  51. Public Declare Function OpenProcess Lib "kernel32" ( _
  52. ByVal dwDesiredAccess As Integer, _
  53. ByVal bInheritHandle As Integer, _
  54. ByVal dwProcessId As Integer) As Integer
  55. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
  56. ByVal lpClassName As String, _
  57. ByVal lpWindowName As String) As Integer
  58. Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" ( _
  59. ByVal hObject As Integer) As Integer
  60. Dim ExeName As String = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
  61. Dim SCurrentDll As String
  62. Dim objMutex As Mutex
  63.  
  64. Private Sub Inject()
  65. On Error GoTo 1
  66. InjectTimer.Stop()
  67. 'Inject Dll
  68. Dim TargetProcess As Process() = Process.GetProcessesByName(ProcessTextBox.Text)
  69. Dim lpThreadId As IntPtr
  70. TargetProcessHandle = OpenProcess(&H1F0FFF, 0, TargetProcess(0).Id)
  71. Dim FileDll = SCurrentDll
  72. pszLibFileRemote = (FileDll)
  73. pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
  74. TargetBufferSize = 1 + Len(pszLibFileRemote)
  75. Dim Rtn As Integer
  76. Dim LoadLibParamAdr As Integer
  77. LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
  78. Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
  79. CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, lpThreadId)
  80. 1: Me.Show()
  81. End Sub
  82.  
  83. ''''''''FormLoad
  84. objMutex = New Mutex(False, "ST70R")
  85. If objMutex.WaitOne(0, False) = False Then
  86. objMutex.Close()
  87. objMutex = Nothing
  88. MessageBox.Show("Error !!")
  89. End
  90. End If
  91.  
  92.  
  93. '''''''InjectTimer
  94. If IO.File.Exists(OpenFileDialog1.FileName) Then
  95. Dim TargetProcess As Process() = Process.GetProcessesByName(ProcessTextBox.Text)
  96. If TargetProcess.Length = 0 Then
  97. StatusLabel.ForeColor = Color.Red
  98. StatusLabel.Text = ("Waiting for " + ProcessTextBox.Text + ".exe")
  99. Else
  100. InjectTimer.Stop()
  101. DelayTimer.Start()
  102. End If
  103. Else
  104. End If
  105.  
  106. ''''''DelayTimer
  107. If DelayNumeric.Value = 0 Then
  108. DelayTimer.Enabled = False
  109. StatusLabel.ForeColor = Color.Lime
  110. StatusLabel.Text = "Successfully Injected!"
  111. For i = 0 To (DllListBox.Items.Count + -1)
  112. SCurrentDll = DllListBox.Items(i)
  113. Call Inject()
  114. If CloseCheckBox.Checked = True Then
  115.  
  116. End
  117. Else
  118. End If
  119. Next i
  120. Else
  121. DelayNumeric.Value = DelayNumeric.Value - 1
  122. End If
  123.  
  124. '''''''InjectButton
  125. If IO.File.Exists(OpenFileDialog1.FileName) Then
  126. Dim TargetProcess As Process() = Process.GetProcessesByName(ProcessTextBox.Text)
  127. If TargetProcess.Length = 0 Then
  128. StatusLabel.ForeColor = Color.Red
  129. StatusLabel.Text = ("Waiting for " + ProcessTextBox.Text + ".exe")
  130. Else
  131. InjectTimer.Stop()
  132. DelayTimer.Start()
  133. End If
  134. Else
  135. End If
  136.  
  137. ''''''BrowseButton
  138. OpenFileDialog1.Filter = "DLL (*.dll) |*.dll"
  139. OpenFileDialog1.ShowDialog()
  140.  
  141. ''''''RemoveButton
  142. For i As Integer = (DllListBox.SelectedItems.Count - 1) To 0 Step -1
  143. DllListBox.Items.Remove(DllListBox.SelectedItems(i))
  144. Next
  145.  
  146. ''''''ClearAllButton
  147. DllListBox.Items.Clear()
  148.  
  149. ''''''OpenFileDialog
  150. Dim FileName As String
  151. FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
  152. Dim DllFileName As String = FileName.Replace("\", "")
  153. DllListBox.Items.Add(DllFileName)
  154.  
  155. ''''''AutoRadioButton
  156. InjectButton.Enabled = False
  157. InjectTimer.Enabled = True
  158.  
  159. ''''''ManualRadioButton
  160. InjectButton.Enabled = True
  161. InjectTimer.Enabled = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement