public override void Command(MenuItem menuItem, string UserInput) { WmicLauncherMenuItem wmicMenuItem = (WmicLauncherMenuItem)menuItem; string[] commands = UserInput.Split(" "); if (commands.Length < 1 || commands.Length > 2 || commands[0].ToLower() != "code") { menuItem.PrintInvalidOptionError(UserInput); return; } else if (commands.Length == 2 && (!new List <string> { "stager", "gruntstager", "scriptlet" }.Contains(commands[1].ToLower()))) { EliteConsole.PrintFormattedErrorLine("Type must be one of: \"Stager\"\\\"GruntStager\" or \"Scriptlet\""); menuItem.PrintInvalidOptionError(UserInput); return; } wmicMenuItem.Refresh(); if (wmicMenuItem.wmicLauncher.LauncherString == "") { wmicMenuItem.CovenantClient.ApiLaunchersWmicPost(); wmicMenuItem.Refresh(); EliteConsole.PrintFormattedHighlightLine("Generated WmicLauncher: " + wmicMenuItem.wmicLauncher.LauncherString); } if (commands.Length == 1 || (commands.Length == 2 && (commands[1].ToLower() == "stager" || commands[1].ToLower() == "gruntstager"))) { EliteConsole.PrintInfoLine(wmicMenuItem.wmicLauncher.StagerCode); } else if (commands.Length == 2 && commands[1].ToLower() == "scriptlet") { EliteConsole.PrintInfoLine(wmicMenuItem.wmicLauncher.DiskCode); } }
public override void Command(MenuItem menuItem, string UserInput) { WmicLauncherMenuItem wmicLauncherMenuItem = ((WmicLauncherMenuItem)menuItem); string[] commands = UserInput.Split(" "); if (commands.Length != 2 || commands[0].ToLower() != "write") { menuItem.PrintInvalidOptionError(UserInput); } else { wmicLauncherMenuItem.Refresh(); if (wmicLauncherMenuItem.wmicLauncher.LauncherString == "") { wmicLauncherMenuItem.CovenantClient.ApiLaunchersBinaryPost(); wmicLauncherMenuItem.Refresh(); EliteConsole.PrintFormattedHighlightLine("Generated WscriptLauncher: " + wmicLauncherMenuItem.wmicLauncher.LauncherString); } string OutputFilePath = Common.EliteDataFolder + String.Concat(commands[1].Split(System.IO.Path.GetInvalidFileNameChars())); System.IO.File.WriteAllText(OutputFilePath, wmicLauncherMenuItem.wmicLauncher.DiskCode); EliteConsole.PrintFormattedHighlightLine("Wrote WscriptLauncher to: \"" + OutputFilePath + "\""); } }