public override void Command(MenuItem menuItem, string UserInput) { MSBuildLauncherMenuItem msbuildMenuItem = (MSBuildLauncherMenuItem)menuItem; msbuildMenuItem.msbuildLauncher = this.CovenantClient.ApiLaunchersMsbuildPost(); EliteConsole.PrintFormattedHighlightLine("Generated MSBuildLauncher: " + msbuildMenuItem.msbuildLauncher.LauncherString); }
public override void Command(MenuItem menuItem, string UserInput) { MSBuildLauncherMenuItem msbuildMenuItem = (MSBuildLauncherMenuItem)menuItem; msbuildMenuItem.msbuildLauncher = this.CovenantClient.ApiLaunchersMsbuildGet(); MSBuildLauncher launcher = msbuildMenuItem.msbuildLauncher; Listener listener = this.CovenantClient.ApiListenersGet().FirstOrDefault(L => L.Id == msbuildMenuItem.msbuildLauncher.ListenerId); EliteConsoleMenu menu = new EliteConsoleMenu(EliteConsoleMenu.EliteConsoleMenuType.Parameter, "MSBuildLauncher"); 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> { "TargetName:", launcher.TargetName }); menu.Rows.Add(new List <string> { "TaskName:", launcher.TaskName }); menu.Rows.Add(new List <string> { "DotNetFramework:", launcher.DotNetFrameworkVersion.ToString() }); menu.Rows.Add(new List <string> { "Delay:", (launcher.Delay ?? default).ToString() });
public override void Command(MenuItem menuItem, string UserInput) { MSBuildLauncherMenuItem msbuildMenuItem = (MSBuildLauncherMenuItem)menuItem; string[] commands = UserInput.Split(" "); if (commands.Length != 2 || commands[0].ToLower() != "host") { menuItem.PrintInvalidOptionError(UserInput); return; } msbuildMenuItem.msbuildLauncher = this.CovenantClient.ApiLaunchersMsbuildPost(); HttpListener listener = this.CovenantClient.ApiListenersHttpByIdGet(msbuildMenuItem.msbuildLauncher.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(msbuildMenuItem.msbuildLauncher.DiskCode)) }; fileToHost = this.CovenantClient.ApiListenersByIdHostedfilesPost(listener.Id ?? default, fileToHost); msbuildMenuItem.msbuildLauncher = this.CovenantClient.ApiLaunchersMsbuildHostedPost(fileToHost); Uri hostedLocation = new Uri(listener.Url + fileToHost.Path); EliteConsole.PrintFormattedHighlightLine("MSBuildLauncher hosted at: " + hostedLocation); EliteConsole.PrintFormattedWarningLine("msbuild.exe cannot execute remotely hosted files, the payload must first be written to disk"); EliteConsole.PrintFormattedInfoLine("Launcher: " + msbuildMenuItem.msbuildLauncher.LauncherString); }
public override void Command(MenuItem menuItem, string UserInput) { MSBuildLauncherMenuItem msbuildMenuItem = (MSBuildLauncherMenuItem)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", "xml" }.Contains(commands[1].ToLower()))) { EliteConsole.PrintFormattedErrorLine("Type must be one of: \"Stager\"\\\"GruntStager\" or \"XML\""); menuItem.PrintInvalidOptionError(UserInput); return; } msbuildMenuItem.Refresh(); if (msbuildMenuItem.msbuildLauncher.LauncherString == "") { msbuildMenuItem.CovenantClient.ApiLaunchersMsbuildPost(); msbuildMenuItem.Refresh(); EliteConsole.PrintFormattedHighlightLine("Generated MSBuildLauncher: " + msbuildMenuItem.msbuildLauncher.LauncherString); } if (commands.Length == 1 || (commands.Length == 2 && (commands[1].ToLower() == "stager" || commands[1].ToLower() == "gruntstager"))) { EliteConsole.PrintInfoLine(msbuildMenuItem.msbuildLauncher.StagerCode); } else if (commands.Length == 2 && commands[1].ToLower() == "xml") { EliteConsole.PrintInfoLine(msbuildMenuItem.msbuildLauncher.DiskCode); } }
public override void Command(MenuItem menuItem, string UserInput) { MSBuildLauncherMenuItem msbuildLauncherMenuItem = ((MSBuildLauncherMenuItem)menuItem); string[] commands = UserInput.Split(" "); if (commands.Length != 2 || commands[0].ToLower() != "write") { menuItem.PrintInvalidOptionError(UserInput); } else { msbuildLauncherMenuItem.Refresh(); if (msbuildLauncherMenuItem.msbuildLauncher.LauncherString == "") { msbuildLauncherMenuItem.CovenantClient.ApiLaunchersBinaryPost(); msbuildLauncherMenuItem.Refresh(); EliteConsole.PrintFormattedHighlightLine("Generated MSBuildLauncher: " + msbuildLauncherMenuItem.msbuildLauncher.LauncherString); } string OutputFilePath = Common.EliteDataFolder + String.Concat(commands[1].Split(System.IO.Path.GetInvalidFileNameChars())); System.IO.File.WriteAllText(OutputFilePath, msbuildLauncherMenuItem.msbuildLauncher.DiskCode); EliteConsole.PrintFormattedHighlightLine("Wrote MSBuildLauncher to: \"" + OutputFilePath + "\""); } }