-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Significantly more conversion to C#
- Loading branch information
Showing
76 changed files
with
4,568 additions
and
1,740 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
| ||
#pragma warning disable | ||
|
||
namespace WDACConfig | ||
{ | ||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
// Some test | ||
// List<WDACConfig.AllCertificatesGrabber.AllFileSigners> Certificates = WDACConfig.AllCertificatesGrabber.WinTrust.GetAllFileSigners(@""); | ||
|
||
} | ||
|
||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
WDACConfig/WDACConfig Module Files/C#/Shared Logics/CheckPolicyDeploymentStatus.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,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Xml; | ||
|
||
#nullable enable | ||
|
||
namespace WDACConfig | ||
{ | ||
|
||
public class CheckPolicyDeploymentStatus | ||
{ | ||
|
||
/// <summary> | ||
/// Check if a policy is deployed on the system | ||
/// </summary> | ||
/// <param name="policyXMLFile"></param> | ||
/// <returns></returns> | ||
public static bool IsDeployed(string policyXMLFile) | ||
{ | ||
|
||
// Create a new HashSet with case-insensitive string comparison | ||
var currentPolicyIDs = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase); | ||
|
||
// Get all of the deployed policies on the system | ||
var policies = CiToolHelper.GetPolicies(false, true, true); | ||
|
||
// Loop through each policy and add its ID to the HashSet | ||
foreach (WDACConfig.CiPolicyInfo item in policies) | ||
{ | ||
_ = currentPolicyIDs.Add(item.PolicyID!); | ||
} | ||
|
||
// Load XML document | ||
XmlDocument xmlDoc = new(); | ||
xmlDoc.Load(policyXMLFile); | ||
|
||
// Create namespace manager and add the default namespace with a prefix | ||
XmlNamespaceManager namespaceManager = new(xmlDoc.NameTable); | ||
namespaceManager.AddNamespace("ns", "urn:schemas-microsoft-com:sipolicy"); | ||
|
||
// Retrieve BasePolicyID and PolicyID | ||
// XmlNode? basePolicyNode = xmlDoc.SelectSingleNode("//ns:BasePolicyID", namespaceManager); | ||
XmlNode? policyNode = xmlDoc.SelectSingleNode("//ns:PolicyID", namespaceManager); | ||
|
||
if (policyNode is not null) | ||
{ | ||
// string basePolicyID = basePolicyNode.InnerText; | ||
|
||
string policyID = policyNode.InnerText; | ||
|
||
// Make sure the ID is in correct comparable format | ||
policyID = policyID.Trim('"', '"'); | ||
policyID = policyID.Trim('{', '}'); | ||
policyID = policyID.Trim('"', '"'); | ||
policyID = $"{policyID}"; | ||
policyID = policyID.ToLowerInvariant(); | ||
|
||
// If the PolicyID of the currently selected XML is in the HashSet of the deployed policy IDs, then it is deployed | ||
return currentPolicyIDs.Contains(policyID); | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} |
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
70 changes: 0 additions & 70 deletions
70
WDACConfig/WDACConfig Module Files/C#/Shared Logics/DriversBlockRulesFetcher.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.