emS-St1ks

Injector modify st1ks

Jun 15th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Threading
  2. Public Class Form1
  3.  
  4.     Private TargetProcessHandle As Integer
  5.     Private pfnStartAddr As Integer
  6.     Private pszLibFileRemote As String
  7.     Private TargetBufferSize As Integer
  8.  
  9.     Public Const PROCESS_VM_READ = &H10
  10.     Public Const TH32CS_SNAPPROCESS = &H2
  11.     Public Const MEM_COMMIT = 4096
  12.     Public Const PAGE_READWRITE = 4
  13.     Public Const PROCESS_CREATE_THREAD = (&H2)
  14.     Public Const PROCESS_VM_OPERATION = (&H8)
  15.     Public Const PROCESS_VM_WRITE = (&H20)
  16.     Dim DLLFileName As String
  17.     Public Declare Function ReadProcessMemory Lib "kernel32" ( _
  18.     ByVal hProcess As Integer, _
  19.     ByVal lpBaseAddress As Integer, _
  20.     ByVal lpBuffer As String, _
  21.     ByVal nSize As Integer, _
  22.     ByRef lpNumberOfBytesWritten As Integer) As Integer
  23.  
  24.     Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" ( _
  25.     ByVal lpLibFileName As String) As Integer
  26.  
  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.  
  34.     Public Declare Function WriteProcessMemory Lib "kernel32" ( _
  35.     ByVal hProcess As Integer, _
  36.     ByVal lpBaseAddress As Integer, _
  37.     ByVal lpBuffer As String, _
  38.     ByVal nSize As Integer, _
  39.     ByRef lpNumberOfBytesWritten As Integer) As Integer
  40.  
  41.     Public Declare Function GetProcAddress Lib "kernel32" ( _
  42.     ByVal hModule As Integer, ByVal lpProcName As String) As Integer
  43.  
  44.     Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _
  45.     ByVal lpModuleName As String) As Integer
  46.  
  47.     Public Declare Function CreateRemoteThread Lib "kernel32" ( _
  48.     ByVal hProcess As Integer, _
  49.     ByVal lpThreadAttributes As Integer, _
  50.     ByVal dwStackSize As Integer, _
  51.     ByVal lpStartAddress As Integer, _
  52.     ByVal lpParameter As Integer, _
  53.     ByVal dwCreationFlags As Integer, _
  54.     ByRef lpThreadId As Integer) As Integer
  55.  
  56.     Public Declare Function OpenProcess Lib "kernel32" ( _
  57.     ByVal dwDesiredAccess As Integer, _
  58.     ByVal bInheritHandle As Integer, _
  59.     ByVal dwProcessId As Integer) As Integer
  60.  
  61.     Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
  62.     ByVal lpClassName As String, _
  63.     ByVal lpWindowName As String) As Integer
  64.  
  65.     Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" ( _
  66.     ByVal hObject As Integer) As Integer
  67.  
  68.  
  69.     Dim ExeName As String = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
  70.  
  71.     Private Sub Inject()
  72.         On Error GoTo 1
  73.         Timer1.Stop()
  74.         Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  75.         TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
  76.         pszLibFileRemote = OpenFileDialog1.FileName
  77.         pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
  78.         TargetBufferSize = 1 + Len(pszLibFileRemote)
  79.         Dim Rtn As Integer
  80.         Dim LoadLibParamAdr As Integer
  81.         LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
  82.         Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
  83.         CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
  84.         CloseHandle(TargetProcessHandle)
  85. 1:      Me.Show()
  86.         MsgBox("Injection Sucessful!!!", MsgBoxStyle.OkOnly)
  87.     End Sub
  88.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  89.         Button1.Text = "Select Hack"
  90.         Label1.Text = "Awaiting Input"
  91.         Timer1.Interval = 50
  92.         Timer1.Start()
  93.         Timer1.Enabled = True
  94.     End Sub
  95.  
  96.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  97.         Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  98.         If IO.File.Exists(OpenFileDialog1.FileName) And (TargetProcess.Length = 0) Then
  99.             Label1.ForeColor = Color.YellowGreen
  100.             Me.Label1.Text = ("Searching for " + TextBox1.Text)
  101.             ProgressBar1.Visible = True
  102.             ProgressBar1.Enabled = True
  103.         Else
  104.             If IO.File.Exists(OpenFileDialog1.FileName) And (TargetProcess.Length) < 0 Then
  105.                 Label1.ForeColor = Color.Lime
  106.                 Me.Label1.Text = (TextBox1.Text + " Successfully Injected!")
  107.                 ProgressBar1.Visible = False
  108.                 ProgressBar1.Enabled = False
  109.                 Call Inject()
  110.                 Thread.Sleep(50)
  111.                 Timer1.Stop()
  112.                 exitme()
  113.             End If
  114.         End If
  115.     End Sub
  116.  
  117.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  118.  
  119.         OpenFileDialog1.Filter = "Dll Files (*.dll) |*.dll|All files (*.*) |*.*"
  120.         If Me.OpenFileDialog1.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub
  121.         Dim FileName As String
  122.         FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
  123.         Dim DllFileName As String = FileName.Replace("\", "")
  124.         If TextBox2.Text <= "" Then
  125.             Me.TextBox2.Text = (DllFileName)
  126.         ElseIf TextBox2.Text > "" Then
  127.             Me.TextBox3.Text = (DllFileName)
  128.         End If
  129.     End Sub
  130.  
  131.     Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
  132.         Label1.ForeColor = Color.Red
  133.         If ComboBox1.SelectedItem = "Vindictus" Then
  134.             TextBox1.Text = "Vindictus"
  135.             Label1.Text = "Select your hack to inject"
  136.         Else
  137.             If ComboBox1.SelectedItem = "Combat Arms" Then
  138.                 TextBox1.Text = "Engine"
  139.                 Label1.Text = "Select your hack to inject"
  140.             ElseIf ComboBox1.SelectedItem = "Modern Warfare 2" Then
  141.                 Label1.Text = "Select your hack to inject"
  142.             End If
  143.         End If
  144.     End Sub
  145.  
  146.     Public Sub startgame()
  147.         If ComboBox1.SelectedItem = "Vindictus" Then
  148.             Shell("C:\Nexon\Vindictus\en-US\Vindictus.exe")
  149.         ElseIf ComboBox1.SelectedItem = "Combat Arms" Then
  150.             Shell("C:\Nexon\Combat Arms\CombatArms_Direct.exe")
  151.         ElseIf ComboBox1.SelectedItem = "Modern Warfare 2" Then
  152.             Shell("C:\Program Files\Activision\Modern Warfare 2\iw4sp.exe")
  153.         End If
  154.     End Sub
  155.     Public Sub exitme()
  156.  
  157.         Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  158.         If TargetProcess.Length > 0 Then
  159.             Label1.Text = "Exiting"
  160.             Thread.Sleep(50)
  161.             Close()
  162.         End If
  163.     End Sub
  164.  
  165.     Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
  166.         Label1.Text = "Exiting"
  167.         Thread.Sleep(50)
  168.         Close()
  169.     End Sub
  170.  
  171.     Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
  172.         Form3.Show()
  173.     End Sub
  174.  
  175.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  176.        
  177.         If IO.File.Exists(OpenFileDialog1.FileName) Then
  178.             Dim TargetProcess As Process() = Process.GetProcessesByName(TextBox1.Text)
  179.             If TargetProcess.Length = 0 Then
  180.                 Label1.ForeColor = Color.Lime
  181.                 Me.Label1.Text = (TextBox1.Text + " Injection started!!!")
  182.                 ProgressBar1.Visible = False
  183.                 ProgressBar1.Enabled = False
  184.                 startgame()
  185.                 Inject()
  186.                 Thread.Sleep(50)
  187.  
  188.                 exitme()
  189.             Else
  190.                 Label1.ForeColor = Color.Red
  191.                 Label1.Text = "Failed to launch, retrying"
  192.                 Thread.Sleep(50)
  193.                 startgame()
  194.                 Call Inject()
  195.  
  196.             End If
  197.         End If
  198.     End Sub
  199. End Class
Advertisement
Add Comment
Please, Sign In to add comment