From 2f456e0223dd3afd9648c1e96681a21e49d3dde9 Mon Sep 17 00:00:00 2001 From: aetsu Date: Thu, 4 Mar 2021 21:25:07 +0100 Subject: [PATCH] bug fixed: some tools could not be obfuscated --- OffensivePipeline/Build.cs | 39 ++++++++++++++++++++-- OffensivePipeline/GitPoc.csproj | 4 --- OffensivePipeline/OffensivePipeline.csproj | 3 +- README.md | 6 ---- 4 files changed, 39 insertions(+), 13 deletions(-) delete mode 100644 OffensivePipeline/GitPoc.csproj diff --git a/OffensivePipeline/Build.cs b/OffensivePipeline/Build.cs index 46c5dac..5649e7d 100644 --- a/OffensivePipeline/Build.cs +++ b/OffensivePipeline/Build.cs @@ -1,6 +1,10 @@ using LibGit2Sharp; using System; using System.IO; +using Microsoft.Build.Construction; +using System.Xml.Linq; +using System.Collections.Generic; +using System.Linq; namespace OffensivePipeline { @@ -55,6 +59,7 @@ public static string BuildTool(string solutionPath, string toolName) Console.ResetColor(); } finalPath = Path.Combine(new string[] { outputDir, toolName + "_" + Helpers.GetRandomString() }); + text = text.Replace("{{SOLUTION_PATH}}", solutionPath); text = text.Replace("{{BUILD_OPTIONS}}", buildOptions); text = text.Replace("{{OUTPUT_DIR}}", finalPath); @@ -68,12 +73,42 @@ public static string BuildTool(string solutionPath, string toolName) Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" Error -> msbuild.exe: {0}", solutionPath); Console.ResetColor(); - } else + } + else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(" No errors!"); Console.ResetColor(); } + + //Gets all references to the project to obfuscate it with confuser + SolutionFile s = SolutionFile.Parse(solutionPath); + foreach (ProjectInSolution p in s.ProjectsInOrder) + { + if (File.Exists(p.AbsolutePath)) + { + XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003"; + XDocument projDefinition = XDocument.Load(p.AbsolutePath); + IEnumerable references = projDefinition + .Element(msbuild + "Project") + .Elements(msbuild + "ItemGroup") + .Elements(msbuild + "Reference") + .Elements(msbuild + "HintPath") + .Select(refElem => refElem.Value); + foreach (string reference in references) + { + string referenceFile = reference.Replace(@"..\", ""); + if (File.Exists(Path.Combine(new string[] { Path.GetDirectoryName(solutionPath), referenceFile }))) + { + File.Copy( + Path.Combine(new string[] { Path.GetDirectoryName(solutionPath), referenceFile }), + Path.Combine(new string[] { finalPath, Path.GetFileName(referenceFile) }), + true); + } + } + } + + } } return finalPath; } @@ -98,7 +133,7 @@ public static void Confuse(string folder) Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" Error -> ConfuserEx: {0}", exe); Console.ResetColor(); - } + } else { Console.ForegroundColor = ConsoleColor.Green; diff --git a/OffensivePipeline/GitPoc.csproj b/OffensivePipeline/GitPoc.csproj deleted file mode 100644 index 0f14913..0000000 --- a/OffensivePipeline/GitPoc.csproj +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/OffensivePipeline/OffensivePipeline.csproj b/OffensivePipeline/OffensivePipeline.csproj index aedc740..bad9aaf 100644 --- a/OffensivePipeline/OffensivePipeline.csproj +++ b/OffensivePipeline/OffensivePipeline.csproj @@ -6,7 +6,8 @@ Aetsu https://github.com/aetsu false - 0.8.1 + 0.8.2 + 0.8.2.0 diff --git a/README.md b/README.md index 23e6c84..e00c1d8 100644 --- a/README.md +++ b/README.md @@ -107,9 +107,3 @@ tool: - winPEAS: - Description: Privilege Escalation Awesome Scripts SUITE - GitLink: https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite - - -## TODO -- [ ] Some tools have problems when they are obfuscated (ConfuserEx does not find the dependencies). In a future release of OffensivePipeline this will be patched. -- [ ] Add more tools -- [ ] Bugs?