public override void Command(MenuItem menuItem, string UserInput) { PowerShellLauncherMenuItem powerShellMenuItem = (PowerShellLauncherMenuItem)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", "powershell" }.Contains(commands[1].ToLower()))) { EliteConsole.PrintFormattedErrorLine("Type must be one of: \"Stager\"\\\"GruntStager\" or \"PowerShell\""); menuItem.PrintInvalidOptionError(UserInput); return; } powerShellMenuItem.Refresh(); if (powerShellMenuItem.powerShellLauncher.LauncherString == "") { powerShellMenuItem.CovenantClient.ApiLaunchersPowershellPost(); powerShellMenuItem.Refresh(); EliteConsole.PrintFormattedHighlightLine("Generated PowerShellLauncher: " + powerShellMenuItem.powerShellLauncher.LauncherString); } if (commands.Length == 1 || (commands.Length == 2 && (commands[1].ToLower() == "stager" || commands[1].ToLower() == "gruntstager"))) { EliteConsole.PrintInfoLine(powerShellMenuItem.powerShellLauncher.StagerCode); } else if (commands.Length == 2 && commands[1].ToLower() == "powershell") { EliteConsole.PrintInfoLine(powerShellMenuItem.powerShellLauncher.PowerShellCode); } }
public override void Command(MenuItem menuItem, string UserInput) { PowerShellLauncherMenuItem PowerShellLauncherMenuItem = ((PowerShellLauncherMenuItem)menuItem); string[] commands = UserInput.Split(" "); if (commands.Length != 2 || commands[0].ToLower() != "write") { menuItem.PrintInvalidOptionError(UserInput); } else { PowerShellLauncherMenuItem.Refresh(); if (PowerShellLauncherMenuItem.powerShellLauncher.LauncherString == "") { PowerShellLauncherMenuItem.CovenantClient.ApiLaunchersBinaryPost(); PowerShellLauncherMenuItem.Refresh(); EliteConsole.PrintFormattedHighlightLine("Generated PowerShellLauncher: " + PowerShellLauncherMenuItem.powerShellLauncher.LauncherString); } string OutputFilePath = Common.EliteDataFolder + String.Concat(commands[1].Split(System.IO.Path.GetInvalidFileNameChars())); System.IO.File.WriteAllText(OutputFilePath, PowerShellLauncherMenuItem.powerShellLauncher.LauncherString); EliteConsole.PrintFormattedHighlightLine("Wrote PowerShellLauncher to: \"" + OutputFilePath + "\""); } }