-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer depends on WDACConfig, everything is included natively.
- Loading branch information
Showing
8 changed files
with
434 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Harden-Windows-Security Module/Main files/C#/Others/PolicyToCIPConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace HardenWindowsSecurity; | ||
|
||
internal static class PolicyToCIPConverter | ||
{ | ||
/// <summary> | ||
/// Converts a XML policy file to CIP binary file using the ConvertFrom-CIPolicy cmdlet of the ConfigCI module | ||
/// </summary> | ||
/// <param name="XmlFilePath"></param> | ||
/// <param name="BinaryFilePath"></param> | ||
internal static void Convert(string XmlFilePath, string BinaryFilePath) | ||
{ | ||
|
||
// Escape the output policy path for PowerShell | ||
string escapedXMLFile = $"\\\"{XmlFilePath}\\\""; | ||
|
||
// Escape the output policy path for PowerShell | ||
string escapedOutputCIP = $"\\\"{BinaryFilePath}\\\""; | ||
|
||
// Construct the PowerShell script | ||
string script = $"ConvertFrom-CIPolicy -XmlFilePath {escapedXMLFile} -BinaryFilePath {escapedOutputCIP}"; | ||
|
||
Logger.LogMessage($"PowerShell code that will be executed: {script}", LogTypeIntel.Information); | ||
|
||
// Execute the command | ||
ProcessStarter.RunCommand("powershell.exe", $"-NoProfile -Command \"{script}\""); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.