Skip to content

Commit

Permalink
basic logging capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Aetsu committed Feb 22, 2021
1 parent c1e456d commit b17eaeb
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 29 deletions.
2 changes: 1 addition & 1 deletion OffensivePipeline/Build.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
Expand Down
Empty file modified OffensivePipeline/GitPoc.csproj
100755 → 100644
Empty file.
28 changes: 25 additions & 3 deletions OffensivePipeline/Helpers.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO.Compression;
using System.Net;
using System.Security.Cryptography;
using Microsoft.Win32;

namespace OffensivePipeline
{
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

}
}
2 changes: 1 addition & 1 deletion OffensivePipeline/OffensivePipeline.csproj
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Authors>Aetsu</Authors>
<Company>https://github.com/aetsu</Company>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>0.8</Version>
<Version>0.8.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
Empty file modified OffensivePipeline/OffensivePipeline.csproj.user
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/OffensivePipeline.sln
100755 → 100644
Empty file.
66 changes: 44 additions & 22 deletions OffensivePipeline/Program.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
}
}
}
Expand All @@ -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;
}
Expand All @@ -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());
}
}
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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");
Expand Down
Empty file.
Empty file.
Empty file modified OffensivePipeline/Resources/template_build.bat
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Resources/template_confuserEx.crproj
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/Internal-Monologue.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/InveighZero.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/Rubeus.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/Seatbelt.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/Sharp-SMBExec.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpChromium.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpDPAPI.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpGPOAbuse.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpHound3.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpMove.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpRDP.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpSpray.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpStay.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpUp.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpView.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/SharpWMI.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/ThreatCheck.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/Watson.yml
100755 → 100644
Empty file.
Empty file modified OffensivePipeline/Tools/winPEAS.yml
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit b17eaeb

Please sign in to comment.