예제 #1
0
        /// <summary>
        /// Kill a process with a given PID.
        /// </summary>
        /// <param name="job">
        /// Job associated with this task. The process to kill
        /// is located in job.Task.parameters and should be a
        /// valid unsigned 32-bit integer.
        /// </param>
        /// <param name="agent">Agent to run this command on.</param>
        public static void Execute(Job job, Agent agent)
        {
            Task           task = job.Task;
            KillParameters args = JsonConvert.DeserializeObject <KillParameters>(task.parameters);
            int            pid  = args.pid;

            try
            {
                System.Diagnostics.Process target = System.Diagnostics.Process.GetProcessById(pid);
                target.Kill();
                ApolloTaskResponse resp = new ApolloTaskResponse(job.Task, $"Killed process with PID {pid}")
                {
                    artifacts = new Mythic.Structs.Artifact[]
                    {
                        new Mythic.Structs.Artifact()
                        {
                            base_artifact = "Process Terminated", artifact = $"{target.ProcessName} (PID: {pid})"
                        }
                    }
                };
                job.SetComplete(resp);
            }
            catch (Exception e)
            {
                job.SetError(String.Format("Error killing process with PID {0}. Reason: {1}\nStack Trace:\n{2}", pid, e.Message, e.StackTrace));
            }
        }
예제 #2
0
파일: Kill.cs 프로젝트: hatchetxuexi/Apollo
        /// <summary>
        /// Kill a process with a given PID.
        /// </summary>
        /// <param name="job">
        /// Job associated with this task. The process to kill
        /// is located in job.Task.parameters and should be a
        /// valid unsigned 32-bit integer.
        /// </param>
        /// <param name="agent">Agent to run this command on.</param>
        public static void Execute(Job job, Agent agent)
        {
            Task           task = job.Task;
            KillParameters args = JsonConvert.DeserializeObject <KillParameters>(task.parameters);
            int            pid  = args.pid;

            try
            {
                System.Diagnostics.Process target = System.Diagnostics.Process.GetProcessById(pid);
                target.Kill();
                job.SetComplete($"Killed process with PID {pid}");
            }
            catch (Exception e)
            {
                job.SetError(String.Format("Error killing process with PID {0}. Reason: {1}\nStack Trace:\n{2}", pid, e.Message, e.StackTrace));
            }
        }