Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.52 KB | None | 0 0
  1. Public Class Form3
  2.  
  3.     Private TargetProcessHandle As Integer
  4.     Private pfnStartAddr As Integer
  5.     Private pszLibFileRemote As String
  6.     Private TargetBufferSize As Integer
  7.  
  8.     Public Const PROCESS_VM_READ = &H10
  9.     Public Const TH32CS_SNAPPROCESS = &H2
  10.     Public Const MEM_COMMIT = 4096
  11.     Public Const PAGE_READWRITE = 4
  12.     Public Const PROCESS_CREATE_THREAD = (&H2)
  13.     Public Const PROCESS_VM_OPERATION = (&H8)
  14.     Public Const PROCESS_VM_WRITE = (&H20)
  15.     Dim DLLFileName As String
  16.     Public Declare Function ReadProcessMemory Lib "kernel32" ( _
  17.     ByVal hProcess As Integer, _
  18.     ByVal lpBaseAddress As Integer, _
  19.     ByVal lpBuffer As String, _
  20.     ByVal nSize As Integer, _
  21.     ByRef lpNumberOfBytesWritten As Integer) As Integer
  22.  
  23.     Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" ( _
  24.     ByVal lpLibFileName As String) As Integer
  25.  
  26.     Public Declare Function VirtualAllocEx Lib "kernel32" ( _
  27.     ByVal hProcess As Integer, _
  28.     ByVal lpAddress As Integer, _
  29.     ByVal dwSize As Integer, _
  30.     ByVal flAllocationType As Integer, _
  31.     ByVal flProtect As Integer) As Integer
  32.  
  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.  
  40.     Public Declare Function GetProcAddress Lib "kernel32" ( _
  41.     ByVal hModule As Integer, ByVal lpProcName As String) As Integer
  42.  
  43.     Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _
  44.     ByVal lpModuleName As String) As Integer
  45.  
  46.     Public Declare Function CreateRemoteThread Lib "kernel32" ( _
  47.     ByVal hProcess As Integer, _
  48.     ByVal lpThreadAttributes As Integer, _
  49.     ByVal dwStackSize As Integer, _
  50.     ByVal lpStartAddress As Integer, _
  51.     ByVal lpParameter As Integer, _
  52.     ByVal dwCreationFlags As Integer, _
  53.     ByRef lpThreadId As Integer) As Integer
  54.  
  55.     Public Declare Function OpenProcess Lib "kernel32" ( _
  56.     ByVal dwDesiredAccess As Integer, _
  57.     ByVal bInheritHandle As Integer, _
  58.     ByVal dwProcessId As Integer) As Integer
  59.  
  60.     Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
  61.     ByVal lpClassName As String, _
  62.     ByVal lpWindowName As String) As Integer
  63.  
  64.     Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" ( _
  65.     ByVal hObject As Integer) As Integer
  66.  
  67.  
  68.     Dim ExeName As String = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
  69.  
  70.     Private Sub Inject()
  71.         On Error GoTo 1
  72.         Timer1.Stop()
  73.         Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  74.         TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
  75.         pszLibFileRemote = OpenFileDialog1.FileName
  76.         pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
  77.         TargetBufferSize = 1 + Len(pszLibFileRemote)
  78.         Dim Rtn As Integer
  79.         Dim LoadLibParamAdr As Integer
  80.         LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
  81.         Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
  82.         CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
  83.         CloseHandle(TargetProcessHandle)
  84. 1:      Me.Show()
  85.     End Sub
  86.  
  87.     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  88.         button1.text = "browse"
  89.         Label1.Text = "Waiting for users input"
  90.         timer1.interval = 50
  91.         timer1.start()
  92.     End Sub
  93.  
  94.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  95.         If IO.File.Exists("VIPHack.dll") Then
  96.             Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  97.             If TargetProcess.Length = 0 Then
  98.                 Me.Label1.Text = ("Waiting for " + TextBox1.Text + ".exe")
  99.  
  100.             Else
  101.                 Timer1.Stop()
  102.                 Me.Label1.Text = "Successfully Injected!"
  103.                 Call Inject()
  104.             End If
  105.         Else
  106.  
  107.         End If
  108.     End Sub
  109.  
  110.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  111.         OpenFileDialog1.Filter = "DLL (*.dll) |*.dll|(*.*) |*.*"
  112.         OpenFileDialog1.ShowDialog()
  113.         Dim FileName As String
  114.         FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
  115.         Dim DllFileName As String = FileName.Replace("\", "")
  116.         Me.TextBox2.Text = (FileName)
  117.     End Sub
  118.  
  119.     Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
  120.         Timer1.Stop()
  121.     End Sub
  122.  
  123.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  124.         Timer1.Start()
  125.  
  126.         If IO.File.Exists(OpenFileDialog1.FileName) Then
  127.             Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  128.             If TargetProcess.Length = 0 Then
  129.                 Me.Label1.Text = ("Waiting for " + TextBox1.Text + ".exe")
  130.  
  131.             Else
  132.                 Timer1.Stop()
  133.                 Me.Label1.Text = "Successfully Injected!"
  134.                 Call Inject()
  135.             End If
  136.         Else
  137.  
  138.         End If
  139.     End Sub
  140. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement