From b17eaeb9f19128cf6003df497f17c66e4ed3ff13 Mon Sep 17 00:00:00 2001 From: aetsu Date: Tue, 23 Feb 2021 00:13:53 +0100 Subject: [PATCH] basic logging capabilities --- OffensivePipeline/Build.cs | 2 +- OffensivePipeline/GitPoc.csproj | 0 OffensivePipeline/Helpers.cs | 28 +++++++- OffensivePipeline/OffensivePipeline.csproj | 2 +- .../OffensivePipeline.csproj.user | 0 OffensivePipeline/OffensivePipeline.sln | 0 OffensivePipeline/Program.cs | 66 ++++++++++++------- .../PublishProfiles/FolderProfile.pubxml | 0 .../PublishProfiles/FolderProfile.pubxml.user | 0 .../Resources/template_build.bat | 0 .../Resources/template_confuserEx.crproj | 0 .../Tools/Internal-Monologue.yml | 0 OffensivePipeline/Tools/InveighZero.yml | 0 OffensivePipeline/Tools/Rubeus.yml | 0 OffensivePipeline/Tools/Seatbelt.yml | 0 OffensivePipeline/Tools/Sharp-SMBExec.yml | 0 OffensivePipeline/Tools/SharpChromium.yml | 0 OffensivePipeline/Tools/SharpDPAPI.yml | 0 OffensivePipeline/Tools/SharpGPOAbuse.yml | 0 OffensivePipeline/Tools/SharpHound3.yml | 0 OffensivePipeline/Tools/SharpMove.yml | 0 OffensivePipeline/Tools/SharpRDP.yml | 0 OffensivePipeline/Tools/SharpSpray.yml | 0 OffensivePipeline/Tools/SharpStay.yml | 0 OffensivePipeline/Tools/SharpUp.yml | 0 OffensivePipeline/Tools/SharpView.yml | 0 OffensivePipeline/Tools/SharpWMI.yml | 0 OffensivePipeline/Tools/ThreatCheck.yml | 0 OffensivePipeline/Tools/Watson.yml | 0 OffensivePipeline/Tools/winPEAS.yml | 0 README.md | 4 +- 31 files changed, 73 insertions(+), 29 deletions(-) mode change 100755 => 100644 OffensivePipeline/Build.cs mode change 100755 => 100644 OffensivePipeline/GitPoc.csproj mode change 100755 => 100644 OffensivePipeline/Helpers.cs mode change 100755 => 100644 OffensivePipeline/OffensivePipeline.csproj mode change 100755 => 100644 OffensivePipeline/OffensivePipeline.csproj.user mode change 100755 => 100644 OffensivePipeline/OffensivePipeline.sln mode change 100755 => 100644 OffensivePipeline/Program.cs mode change 100755 => 100644 OffensivePipeline/Properties/PublishProfiles/FolderProfile.pubxml mode change 100755 => 100644 OffensivePipeline/Properties/PublishProfiles/FolderProfile.pubxml.user mode change 100755 => 100644 OffensivePipeline/Resources/template_build.bat mode change 100755 => 100644 OffensivePipeline/Resources/template_confuserEx.crproj mode change 100755 => 100644 OffensivePipeline/Tools/Internal-Monologue.yml mode change 100755 => 100644 OffensivePipeline/Tools/InveighZero.yml mode change 100755 => 100644 OffensivePipeline/Tools/Rubeus.yml mode change 100755 => 100644 OffensivePipeline/Tools/Seatbelt.yml mode change 100755 => 100644 OffensivePipeline/Tools/Sharp-SMBExec.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpChromium.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpDPAPI.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpGPOAbuse.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpHound3.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpMove.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpRDP.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpSpray.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpStay.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpUp.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpView.yml mode change 100755 => 100644 OffensivePipeline/Tools/SharpWMI.yml mode change 100755 => 100644 OffensivePipeline/Tools/ThreatCheck.yml mode change 100755 => 100644 OffensivePipeline/Tools/Watson.yml mode change 100755 => 100644 OffensivePipeline/Tools/winPEAS.yml diff --git a/OffensivePipeline/Build.cs b/OffensivePipeline/Build.cs old mode 100755 new mode 100644 index 4d4c923..46c5dac --- a/OffensivePipeline/Build.cs +++ b/OffensivePipeline/Build.cs @@ -51,7 +51,7 @@ public static string BuildTool(string solutionPath, string toolName) if (Helpers.ExecuteCommand(@"Resources\nuget.exe restore " + solutionPath) != 0) { Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("Error -> nuget.exe: {0}", solutionPath); + Console.WriteLine(" Error -> nuget.exe: {0}", solutionPath); Console.ResetColor(); } finalPath = Path.Combine(new string[] { outputDir, toolName + "_" + Helpers.GetRandomString() }); diff --git a/OffensivePipeline/GitPoc.csproj b/OffensivePipeline/GitPoc.csproj old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Helpers.cs b/OffensivePipeline/Helpers.cs old mode 100755 new mode 100644 index c2b1728..156d625 --- a/OffensivePipeline/Helpers.cs +++ b/OffensivePipeline/Helpers.cs @@ -5,6 +5,7 @@ using System.IO.Compression; using System.Net; using System.Security.Cryptography; +using Microsoft.Win32; namespace OffensivePipeline { @@ -27,13 +28,22 @@ public static int ExecuteCommand(string command) string output = process.StandardOutput.ReadToEnd(); string error = process.StandardError.ReadToEnd(); exitCode = process.ExitCode; + if (!String.IsNullOrEmpty(output)) + { + LogToFile("ExecuteCommand", "INFO", output); + } + if (!String.IsNullOrEmpty(error)) + { + LogToFile("ExecuteCommand", "ERROR", error); + } //Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output)); //Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error)); //Console.WriteLine("ExitCode: " + exitCode.ToString(), "ExecuteCommand"); process.Close(); } catch (Exception ex) { - Console.WriteLine("Error executing command <" + command + "> - " + ex.ToString()); + Console.WriteLine(" Error -> Executing command <" + command + "> - " + ex.ToString()); + LogToFile("ExecuteCommand", "ERROR", command + "-> " + ex.ToString()); return 1; } @@ -57,7 +67,8 @@ public static int DownloadResources(string url, string outputName, string output } catch (Exception ex) { - Console.WriteLine("Error downloading <" + url + "> - " + ex.ToString()); + Console.WriteLine(" Error -> Downloading <" + url + "> - " + ex.ToString()); + LogToFile("DownloadResources", "ERROR", url + "-> " + ex.ToString()); return 1; } return 0; @@ -72,7 +83,8 @@ public static int UnzipFile(string filePath, string outputFolder) } catch (Exception ex) { - Console.WriteLine("Error unzipping <" + filePath + "> - " + ex.ToString()); + Console.WriteLine(" Error -> Unzipping <" + filePath + "> - " + ex.ToString()); + LogToFile("UnzipFile", "ERROR", filePath + "-> " + ex.ToString()); return 1; } return 0; @@ -111,5 +123,15 @@ public static void CalculateMD5Files(string folder) } File.WriteAllLines(Path.Combine(new string[] { folder, "md5.txt" }), md5List); } + + public static void LogToFile(string source, string logType, string messsage) + { + string FilePath = "log.txt"; + DateTime localDate = DateTime.Now; + using var fileStream = new FileStream(FilePath, FileMode.Append); + using var writter = new StreamWriter(fileStream); + writter.WriteLine("{0} | {1} | {2} -- {3}", localDate.ToString(), logType, source, messsage); + } + } } diff --git a/OffensivePipeline/OffensivePipeline.csproj b/OffensivePipeline/OffensivePipeline.csproj old mode 100755 new mode 100644 index 5f44613..aedc740 --- a/OffensivePipeline/OffensivePipeline.csproj +++ b/OffensivePipeline/OffensivePipeline.csproj @@ -6,7 +6,7 @@ Aetsu https://github.com/aetsu false - 0.8 + 0.8.1 diff --git a/OffensivePipeline/OffensivePipeline.csproj.user b/OffensivePipeline/OffensivePipeline.csproj.user old mode 100755 new mode 100644 diff --git a/OffensivePipeline/OffensivePipeline.sln b/OffensivePipeline/OffensivePipeline.sln old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Program.cs b/OffensivePipeline/Program.cs old mode 100755 new mode 100644 index 00d95da..12a5d8d --- a/OffensivePipeline/Program.cs +++ b/OffensivePipeline/Program.cs @@ -43,7 +43,8 @@ item.Children[new YamlScalarNode("solutionPath")].ToString(), if (Helpers.ExecuteCommand("RMDIR \"" + toolPath + "\" /S /Q") != 0) { Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("Error -> RMDIR: {0}", toolPath); + Console.WriteLine(" Error -> RMDIR: {0}", toolPath); + Helpers.LogToFile("AnalyzeTools", "ERROR", "RMDIR: <" + toolPath + ">"); Console.ResetColor(); } Build.Confuse(outputFolder); @@ -54,7 +55,8 @@ item.Children[new YamlScalarNode("solutionPath")].ToString(), } catch (Exception ex) { - Console.WriteLine("Error analyzing: <{0}> -> {1}", item.Children[new YamlScalarNode("name")], ex.ToString()); + Console.WriteLine(" Error -> Analyzing: <{0}> -> {1}", item.Children[new YamlScalarNode("name")], ex.ToString()); + Helpers.LogToFile("AnalyzeTools", "ERROR", "Analyzing: <" + item.Children[new YamlScalarNode("name")] + "> -> " + ex.ToString()); } } } @@ -68,7 +70,8 @@ static void AnalyzeTools(string toolName) if (!File.Exists(@"Tools\" + toolName + ".yml")) { Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("- Error: {0} tool not supported", toolName); + Console.WriteLine(" Error -> {0} tool not supported", toolName); + Helpers.LogToFile("AnalyzeTools", "ERROR", "<" + toolName + "> not supported"); Console.ResetColor(); return; } @@ -90,23 +93,31 @@ static void AnalyzeTools(string toolName) item.Children[new YamlScalarNode("description")], item.Children[new YamlScalarNode("gitLink")], item.Children[new YamlScalarNode("solutionPath")]); - - toolPath = Build.DownloadRepository(item.Children[new YamlScalarNode("name")].ToString() - , item.Children[new YamlScalarNode("gitLink")].ToString()); - outputFolder = Build.BuildTool( - item.Children[new YamlScalarNode("solutionPath")].ToString(), - item.Children[new YamlScalarNode("name")].ToString()); - //if (Helpers.ExecuteCommand("RMDIR \"" + toolPath + "\" /S /Q") != 0) - //{ - // Console.ForegroundColor = ConsoleColor.Red; - // Console.WriteLine("Error -> RMDIR: {0}", toolPath); - // Console.ResetColor(); - //} - Build.Confuse(outputFolder); - Helpers.CalculateMD5Files(outputFolder); - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine(" Output folder: {0}", outputFolder); - Console.ResetColor(); + try + { + toolPath = Build.DownloadRepository(item.Children[new YamlScalarNode("name")].ToString() + , item.Children[new YamlScalarNode("gitLink")].ToString()); + outputFolder = Build.BuildTool( + item.Children[new YamlScalarNode("solutionPath")].ToString(), + item.Children[new YamlScalarNode("name")].ToString()); + if (Helpers.ExecuteCommand("RMDIR \"" + toolPath + "\" /S /Q") != 0) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(" Error -> RMDIR: {0}", toolPath); + Helpers.LogToFile("AnalyzeTools", "ERROR", "RMDIR: <" + toolPath + ">"); + Console.ResetColor(); + } + Build.Confuse(outputFolder); + Helpers.CalculateMD5Files(outputFolder); + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine(" Output folder: {0}", outputFolder); + Console.ResetColor(); + } + catch (Exception ex) + { + Console.WriteLine(" Error -> Analyzing: <{0}> -> {1}", item.Children[new YamlScalarNode("name")], ex.ToString()); + Helpers.LogToFile("AnalyzeTools", "ERROR", "Analyzing: <" + item.Children[new YamlScalarNode("name")] + "> -> " + ex.ToString()); + } } } @@ -150,9 +161,20 @@ static void CheckStart() } catch (Exception ex) { - Console.WriteLine("Error deleting <" + Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }) + "> - " + ex.ToString()); + Console.WriteLine(" Error -> deleting <" + Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }) + "> - " + ex.ToString()); + Helpers.LogToFile("CheckStart", "ERROR", "Deleting: <" + Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }) + "> - " + ex.ToString()); } } + string buildToolsPath = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"; + if (!File.Exists(buildToolsPath)) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(" Error -> File not found: {0}", buildToolsPath); + Console.WriteLine(" Install -> Build Tools for Visual Studio 2019"); + Helpers.LogToFile("CheckStart", "ERROR", "File not found: <" + buildToolsPath + ">"); + Console.ResetColor(); + System.Environment.Exit(1); + } } static void ListTools() @@ -198,9 +220,9 @@ M Mooooso. ooo @aetsu + v0.8.1 "; Console.WriteLine(banner); - var app = new CommandLineApplication(); app.Name = "OffensivePipeline"; app.HelpOption("-?|-h|--help"); diff --git a/OffensivePipeline/Properties/PublishProfiles/FolderProfile.pubxml b/OffensivePipeline/Properties/PublishProfiles/FolderProfile.pubxml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Properties/PublishProfiles/FolderProfile.pubxml.user b/OffensivePipeline/Properties/PublishProfiles/FolderProfile.pubxml.user old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Resources/template_build.bat b/OffensivePipeline/Resources/template_build.bat old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Resources/template_confuserEx.crproj b/OffensivePipeline/Resources/template_confuserEx.crproj old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/Internal-Monologue.yml b/OffensivePipeline/Tools/Internal-Monologue.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/InveighZero.yml b/OffensivePipeline/Tools/InveighZero.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/Rubeus.yml b/OffensivePipeline/Tools/Rubeus.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/Seatbelt.yml b/OffensivePipeline/Tools/Seatbelt.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/Sharp-SMBExec.yml b/OffensivePipeline/Tools/Sharp-SMBExec.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpChromium.yml b/OffensivePipeline/Tools/SharpChromium.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpDPAPI.yml b/OffensivePipeline/Tools/SharpDPAPI.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpGPOAbuse.yml b/OffensivePipeline/Tools/SharpGPOAbuse.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpHound3.yml b/OffensivePipeline/Tools/SharpHound3.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpMove.yml b/OffensivePipeline/Tools/SharpMove.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpRDP.yml b/OffensivePipeline/Tools/SharpRDP.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpSpray.yml b/OffensivePipeline/Tools/SharpSpray.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpStay.yml b/OffensivePipeline/Tools/SharpStay.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpUp.yml b/OffensivePipeline/Tools/SharpUp.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpView.yml b/OffensivePipeline/Tools/SharpView.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/SharpWMI.yml b/OffensivePipeline/Tools/SharpWMI.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/ThreatCheck.yml b/OffensivePipeline/Tools/ThreatCheck.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/Watson.yml b/OffensivePipeline/Tools/Watson.yml old mode 100755 new mode 100644 diff --git a/OffensivePipeline/Tools/winPEAS.yml b/OffensivePipeline/Tools/winPEAS.yml old mode 100755 new mode 100644 diff --git a/README.md b/README.md index 06d59a4..23e6c84 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ tool: ## Requirements for the release version (Visual Studio 2019 is not required) -- Microsoft .NET Framework 3.5 Service Pack 1 (for some tools): https://www.microsoft.com/es-es/download/details.aspx?id=22 +- Microsoft .NET Framework 3.5 Service Pack 1 (for some tools): https://www.microsoft.com/en-us/download/details.aspx?id=22 - Build Tools for Visual Studio 2019: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16 - Install .NET desktop build tools ![](img/lib01.png) @@ -44,7 +44,7 @@ tool: ## Requirements for build -- Net framework 3.5.1 (for some tools): https://www.microsoft.com/es-es/download/details.aspx?id=22 +- Net framework 3.5.1 (for some tools): https://www.microsoft.com/en-us/download/details.aspx?id=22 - Visual Studio 2019 -> https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16 - Install .NET desktop build tools