Exemplo n.º 1
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            TaskMenuItem taskMenuItem = (TaskMenuItem)menuItem;

            // Refresh the task object
            taskMenuItem.task = this.CovenantClient.ApiGruntTasksByIdGet(taskMenuItem.task.Id ?? default);
            GruntTask task = taskMenuItem.task;

            EliteConsoleMenu menu = new EliteConsoleMenu(EliteConsoleMenu.EliteConsoleMenuType.Parameter, "Task: " + task.Name);

            menu.Rows.Add(new List <string> {
                "Name:", task.Name
            });
            menu.Rows.Add(new List <string> {
                "Description:", task.Description
            });
            menu.Rows.Add(new List <string> {
                "ReferenceAssemblies:", task.ReferenceAssemblies
            });
            task.Options.ToList().ForEach(O =>
            {
                menu.Rows.Add(new List <string> {
                    O.Name + ":", O.Value
                });
            });
            menu.Print();
        }
Exemplo n.º 2
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            TaskMenuItem            taskMenuItem = ((TaskMenuItem)menuItem);
            List <string>           commands     = UserInput.Split(" ").ToList();
            IList <GruntTaskOption> options      = taskMenuItem.task.Options;
            GruntTaskOption         option       = options.FirstOrDefault(O => O.Name.ToLower() == commands[1].ToLower());

            if (commands.Count() < 3 || commands.First().ToLower() != "set")
            {
                menuItem.PrintInvalidOptionError(UserInput);
            }
            else if (commands[1].ToLower() == "FilePath".ToLower())
            {
                string FilePath = Path.Combine(Common.EliteDataFolder, commands[2]);
                if (!File.Exists(FilePath))
                {
                    menuItem.PrintInvalidOptionError(UserInput);
                    EliteConsole.PrintFormattedErrorLine("File: \"" + FilePath + "\" does not exist on the local system.");
                    return;
                }
                options.FirstOrDefault(O => O.Name == "FileContents").Value = Convert.ToBase64String(File.ReadAllBytes(FilePath));
                options.FirstOrDefault(O => O.Name == "FileName").Value     = Path.GetFileName(FilePath);
                CovenantClient.ApiGruntTasksByIdPut(taskMenuItem.task.Id ?? default, taskMenuItem.task);
            }
            else if (option == null)
            {
                menuItem.PrintInvalidOptionError(UserInput);
                EliteConsole.PrintFormattedErrorLine("Invalid Set option: \"" + commands[1] + "\"");
            }
            else
            {
                option.Value = String.Join(" ", commands.GetRange(2, commands.Count() - 2));
                CovenantClient.ApiGruntTasksByIdPut(taskMenuItem.task.Id ?? default, taskMenuItem.task);
            }
        }
Exemplo n.º 3
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            TaskMenuItem    taskMenuItem = ((TaskMenuItem)menuItem);
            List <string>   commands     = UserInput.Split(" ").ToList();
            GruntTaskOption option       = taskMenuItem.task.Options.FirstOrDefault(O => O.Name.ToLower() == commands[1].ToLower());

            if (commands.Count() < 3 || commands.First().ToLower() != "set")
            {
                menuItem.PrintInvalidOptionError(UserInput);
            }
            else if (option == null)
            {
                EliteConsole.PrintFormattedErrorLine("Invalid Set option: \"" + commands[1] + "\"");
            }
            else
            {
                option.Value = String.Join(" ", commands.GetRange(2, commands.Count() - 2));
                this.CovenantClient.ApiGruntTasksByIdPut(taskMenuItem.task.Id ?? default, taskMenuItem.task);
            }
        }