예제 #1
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            menuItem.Refresh();
            GruntsMenuItem gruntsMenu = ((GruntsMenuItem)menuItem);

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 3 || commands[0].ToLower() != "rename")
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }

            Grunt grunt = gruntsMenu.Grunts.FirstOrDefault(G => G.Name.ToLower() == commands[1]);

            if (grunt == null)
            {
                EliteConsole.PrintFormattedErrorLine("Grunt with name: " + commands[1] + " does not exist.");
                menuItem.PrintInvalidOptionError(UserInput);
            }
            else if (gruntsMenu.Grunts.Where(G => G.Name.ToLower() == commands[2].ToLower()).Any())
            {
                EliteConsole.PrintFormattedErrorLine("Grunt with name: " + commands[2] + " already exists.");
                menuItem.PrintInvalidOptionError(UserInput);
            }
            else
            {
                grunt.Name = commands[2];
                this.CovenantClient.ApiGruntsPut(grunt);
            }
        }
예제 #2
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 2 || commands[0].ToLower() != "hide")
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            if (commands[1].ToLower() == "all")
            {
                gruntsMenuItem.HiddenGruntNames.AddRange(gruntsMenuItem.Grunts.Select(G => G.Name));
            }
            Grunt grunt = gruntsMenuItem.Grunts.FirstOrDefault(G => G.Name == commands[1]);

            if (grunt == null)
            {
                EliteConsole.PrintFormattedErrorLine("Invalid GruntName: \"" + commands[1] + "\"");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            EliteConsole.PrintFormattedWarning("Hide Grunt: " + commands[1] + "? [y/N] ");
            string input = EliteConsole.Read();

            if (!input.ToLower().StartsWith("y"))
            {
                return;
            }
            gruntsMenuItem.HiddenGruntNames.Add(grunt.Name);
        }
예제 #3
0
        public override async void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenu = ((GruntsMenuItem)menuItem);

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 3 || !commands[0].Equals("rename", StringComparison.OrdinalIgnoreCase))
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }

            Grunt grunt = gruntsMenu.Grunts.FirstOrDefault(G => G.Name.Equals(commands[1], StringComparison.OrdinalIgnoreCase));

            if (grunt == null)
            {
                EliteConsole.PrintFormattedErrorLine("Grunt with name: " + commands[1] + " does not exist.");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            if (gruntsMenu.Grunts.Any(G => G.Name.Equals(commands[2], StringComparison.OrdinalIgnoreCase)))
            {
                EliteConsole.PrintFormattedErrorLine("Grunt with name: " + commands[2] + " already exists.");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            grunt.Name = commands[2];
            try
            {
                await this.CovenantClient.ApiGruntsPutAsync(grunt);
            }
            catch (HttpOperationException e)
            {
                EliteConsole.PrintFormattedWarningLine("CovenantException: " + e.Response.Content);
            }
        }
예제 #4
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 2 || !commands[0].Equals("unhide", StringComparison.OrdinalIgnoreCase))
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            if (commands[1].Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                gruntsMenuItem.HiddenGruntNames.Clear();
                return;
            }
            string gruntName = gruntsMenuItem.HiddenGruntNames.FirstOrDefault(HGN => HGN == commands[1]);

            if (string.IsNullOrEmpty(gruntName))
            {
                EliteConsole.PrintFormattedErrorLine("Invalid GruntName: \"" + commands[1] + "\"");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            gruntsMenuItem.HiddenGruntNames.Remove(gruntName);
        }
예제 #5
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 2 || commands[0].ToLower() != "kill")
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            if (commands[1].ToLower() == "all")
            {
                EliteConsole.PrintFormattedWarning("Kill all Grunts? [y/N] ");
                string input1 = EliteConsole.Read();
                if (!input1.ToLower().StartsWith("y"))
                {
                    return;
                }
                gruntsMenuItem.HiddenGruntNames.AddRange(gruntsMenuItem.Grunts.Select(G => G.Name));
                foreach (Grunt g in gruntsMenuItem.Grunts)
                {
                    GruntTasking gt = new GruntTasking {
                        Type = GruntTaskingType.Kill, GruntId = g.Id
                    };
                    this.CovenantClient.ApiGruntsByIdTaskingsPost(g.Id ?? default, gt);
                }
            }
            Grunt grunt = gruntsMenuItem.Grunts.FirstOrDefault(G => G.Name == commands[1]);

            if (grunt == null)
            {
                EliteConsole.PrintFormattedErrorLine("Invalid GruntName: \"" + commands[1] + "\"");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            EliteConsole.PrintFormattedWarning("Kill Grunt: " + commands[1] + "? [y/N] ");
            string input2 = EliteConsole.Read();

            if (!input2.ToLower().StartsWith("y"))
            {
                return;
            }
            GruntTasking gruntTasking = new GruntTasking {
                Type = GruntTaskingType.Kill, GruntId = grunt.Id
            };

            this.CovenantClient.ApiGruntsByIdTaskingsPost(grunt.Id ?? default, gruntTasking);
        }
예제 #6
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 2 || commands[0].ToLower() != "unhide")
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            if (commands[1].ToLower() == "all")
            {
                gruntsMenuItem.HiddenGruntNames.Clear();
            }
            string gruntName = gruntsMenuItem.HiddenGruntNames.FirstOrDefault(HGN => HGN == commands[1]);

            if (gruntName == null || gruntName == "")
            {
                EliteConsole.PrintFormattedErrorLine("Invalid GruntName: \"" + commands[1] + "\"");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            gruntsMenuItem.HiddenGruntNames.Remove(gruntName);
        }
예제 #7
0
        public override void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;

            gruntsMenuItem.ValidateMenuParameters();
            List <Grunt>     displayGrunts = gruntsMenuItem.Grunts.Where(G => G.Status != GruntStatus.Uninitialized && !gruntsMenuItem.HiddenGruntNames.Contains(G.Name)).ToList();
            EliteConsoleMenu menu          = new EliteConsoleMenu(EliteConsoleMenu.EliteConsoleMenuType.List, "Grunts");

            menu.Columns.Add("Name");
            menu.Columns.Add("User");
            menu.Columns.Add("Integrity");
            menu.Columns.Add("ComputerName");
            menu.Columns.Add("OperatingSystem");
            menu.Columns.Add("Process");
            menu.Columns.Add("Status");
            menu.Columns.Add("Last Check In");
            displayGrunts.ForEach(G =>
            {
                menu.Rows.Add(new List <string> {
                    G.Name, G.UserDomainName + "\\" + G.UserName, G.Integrity.ToString(), G.IpAddress, G.OperatingSystem, G.Process, G.Status.ToString(), G.LastCheckIn
                });
            });
            menu.Print();
        }
예제 #8
0
        public override async void Command(MenuItem menuItem, string UserInput)
        {
            GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;

            string[] commands = UserInput.Split(" ");
            if (commands.Length != 2 || !commands[0].Equals("kill", StringComparison.OrdinalIgnoreCase))
            {
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            if (commands[1].Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                EliteConsole.PrintFormattedWarning("Kill all Grunts? [y/N] ");
                string input1 = EliteConsole.Read();
                if (!input1.StartsWith("y", StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
                foreach (Grunt g in gruntsMenuItem.Grunts)
                {
                    GruntTasking gt = new GruntTasking
                    {
                        Id             = 0,
                        GruntId        = g.Id,
                        TaskId         = 1,
                        Name           = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10),
                        Status         = GruntTaskingStatus.Uninitialized,
                        Type           = GruntTaskingType.Kill,
                        TaskingCommand = UserInput,
                        TokenTask      = false
                    };
                    try
                    {
                        await this.CovenantClient.ApiGruntsByIdTaskingsPostAsync(g.Id ?? default, gt);
                    }
                    catch (HttpOperationException e)
                    {
                        EliteConsole.PrintFormattedWarningLine("CovenantException: " + e.Response.Content);
                    }
                }
                return;
            }
            Grunt grunt = gruntsMenuItem.Grunts.FirstOrDefault(G => G.Name == commands[1]);

            if (grunt == null)
            {
                EliteConsole.PrintFormattedErrorLine("Invalid GruntName: \"" + commands[1] + "\"");
                menuItem.PrintInvalidOptionError(UserInput);
                return;
            }
            EliteConsole.PrintFormattedWarning("Kill Grunt: " + commands[1] + "? [y/N] ");
            string input2 = EliteConsole.Read();

            if (!input2.StartsWith("y", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            GruntTasking gruntTasking = new GruntTasking
            {
                Id             = 0,
                GruntId        = grunt.Id,
                TaskId         = 1,
                Name           = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10),
                Status         = GruntTaskingStatus.Uninitialized,
                Type           = GruntTaskingType.Kill,
                TaskingCommand = UserInput,
                TokenTask      = false
            };

            try
            {
                await this.CovenantClient.ApiGruntsByIdTaskingsPostAsync(grunt.Id ?? default, gruntTasking);
            }
            catch (HttpOperationException e)
            {
                EliteConsole.PrintFormattedWarningLine("CovenantException: " + e.Response.Content);
            }
        }