public override void Command(MenuItem menuItem, string UserInput) { PowerShellLauncherMenuItem powershellMenuItem = (PowerShellLauncherMenuItem)menuItem; powershellMenuItem.powerShellLauncher = this.CovenantClient.ApiLaunchersPowershellPost(); EliteConsole.PrintFormattedHighlightLine("Generated PowerShellLauncher: " + powershellMenuItem.powerShellLauncher.LauncherString); }
public override void Command(MenuItem menuItem, string UserInput) { PowerShellLauncherMenuItem powershellMenuItem = (PowerShellLauncherMenuItem)menuItem; powershellMenuItem.powerShellLauncher = this.CovenantClient.ApiLaunchersPowershellGet(); PowerShellLauncher launcher = powershellMenuItem.powerShellLauncher; Listener listener = this.CovenantClient.ApiListenersGet().FirstOrDefault(L => L.Id == powershellMenuItem.powerShellLauncher.ListenerId); EliteConsoleMenu menu = new EliteConsoleMenu(EliteConsoleMenu.EliteConsoleMenuType.Parameter, "PowerShellLauncher"); menu.Rows.Add(new List <string> { "Name:", launcher.Name }); menu.Rows.Add(new List <string> { "Description:", launcher.Description }); menu.Rows.Add(new List <string> { "ListenerName:", listener == null ? "" : listener.Name }); menu.Rows.Add(new List <string> { "ParameterString:", launcher.ParameterString }); menu.Rows.Add(new List <string> { "DotNetFramework:", launcher.DotNetFrameworkVersion == DotNetVersion.Net35 ? "v3.5" : "v4.0" }); menu.Rows.Add(new List <string> { "Delay:", (launcher.Delay ?? default).ToString() });
public override void Command(MenuItem menuItem, string UserInput) { PowerShellLauncherMenuItem powershellMenuItem = (PowerShellLauncherMenuItem)menuItem; string[] commands = UserInput.Split(" "); if (commands.Length != 2 || commands[0].ToLower() != "host") { menuItem.PrintInvalidOptionError(UserInput); return; } powershellMenuItem.powerShellLauncher = this.CovenantClient.ApiLaunchersPowershellPost(); HttpListener listener = this.CovenantClient.ApiListenersHttpByIdGet(powershellMenuItem.powerShellLauncher.ListenerId ?? default); if (listener == null) { EliteConsole.PrintFormattedErrorLine("Can only host a file on a valid HttpListener."); menuItem.PrintInvalidOptionError(UserInput); return; } HostedFile fileToHost = new HostedFile { ListenerId = listener.Id, Path = commands[1], Content = Convert.ToBase64String(Common.CovenantEncoding.GetBytes(powershellMenuItem.powerShellLauncher.PowerShellCode)) }; fileToHost = this.CovenantClient.ApiListenersByIdHostedfilesPost(listener.Id ?? default, fileToHost); powershellMenuItem.powerShellLauncher = this.CovenantClient.ApiLaunchersPowershellHostedPost(fileToHost); Uri hostedLocation = new Uri(listener.Url + fileToHost.Path); EliteConsole.PrintFormattedHighlightLine("PowerShellLauncher hosted at: " + hostedLocation); EliteConsole.PrintFormattedInfoLine("Launcher (Command): " + powershellMenuItem.powerShellLauncher.LauncherString); EliteConsole.PrintFormattedInfoLine("Launcher (EncodedCommand): " + powershellMenuItem.powerShellLauncher.EncodedLauncherString); }
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 + "\""); } }