Example #1
0
        private async void ButtonInject_ClickAsync(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(DLLPath))
            {
                MessageBox.Show("No DLL selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(cBProcesses.SelectedItem.ToString()))
            {
                MessageBox.Show("No process selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var process = cBProcesses.SelectedItem.ToString();

            Log("Started injection...");
            Log($"DLL: {DLLPath}");
            Log($"Process: {process}");

            Obfuscator.ClearTemp();

            if (cBRndName.Checked)
            {
                Log("Randomizing DLL name ...");
                DLLPath = Obfuscator.RenameDll(DLLPath);
            }
            if (cBRndHash.Checked)
            {
                Log("Randomizing DLL HashSum...");
                DLLPath = Obfuscator.ChangeHashSumDll(DLLPath);
            }

            DLLInjector injector = new();
            await Task.Run(() =>
            {
                try
                {
                    if (rBLoadLibrary.Checked)
                    {
                        injector.InjectDll(DLLPath, process, InjectionType.Kernell);
                    }
                    else if (rBManualMap.Checked)
                    {
                        injector.InjectDll(DLLPath, process, InjectionType.Manual);
                    }
                    else if (rBNtCreateProc.Checked)
                    {
                        injector.InjectDll(DLLPath, process, InjectionType.NtCreateThread);
                    }
                    else
                    {
                        throw new ArgumentException("Undefined injection type");
                    }
                    MessageBox.Show("Injected successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error while injecting DLL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    Obfuscator.ClearTemp();
                }
            });
        }