diff --git a/Private/ConvertTo-XMLWindowsFirewall.ps1 b/Private/ConvertTo-XMLWindowsFirewall.ps1 new file mode 100644 index 0000000..9e4ab01 --- /dev/null +++ b/Private/ConvertTo-XMLWindowsFirewall.ps1 @@ -0,0 +1,124 @@ +function ConvertTo-XMLWindowsFirewall { + [cmdletBinding()] + param( + [PSCustomObject] $GPO, + [switch] $SingleObject + ) + if ($SingleObject) { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + #GpoCategory = $GPOEntry.GpoCategory + #GpoSettings = $GPOEntry.GpoSettings + Count = 0 + Settings = $null + } + [Array] $CreateGPO['Settings'] = foreach ($Folder in $GPO.DataSet) { + foreach ($Location in $Folder.Location) { + [PSCustomObject] @{ + DestinationPath = $Location.DestinationPath + SecuritySID = $Location.SecurityGroup.SID.'#text' + SecurityName = $Location.SecurityGroup.Name.'#text' + GrantExclusiveRights = if ($Folder.GrantExclusiveRights -eq 'true') { $true } else { $false } + MoveContents = if ($Folder.MoveContents -eq 'true') { $true } else { $false } + FollowParent = if ($Folder.FollowParent -eq 'true') { $true } else { $false } + ApplyToDownLevel = if ($Folder.ApplyToDownLevel -eq 'true') { $true } else { $false } + DoNotCare = if ($Folder.DoNotCare -eq 'true') { $true } else { $false } + RedirectToLocal = if ($Folder.RedirectToLocal -eq 'true') { $true } else { $false } + PolicyRemovalBehavior = $Folder.PolicyRemovalBehavior # : LeaveContents + ConfigurationControl = if ($Folder.ConfigurationControl -eq 'GP') { 'Group Policy' } else { $Folder.ConfigurationControl } # : GP + PrimaryComputerEvaluation = $Folder.PrimaryComputerEvaluation # : PrimaryComputerPolicyDisabled + } + } + } + $CreateGPO['Count'] = $CreateGPO['Settings'].Count + $CreateGPO['Linked'] = $GPO.Linked + $CreateGPO['LinksCount'] = $GPO.LinksCount + $CreateGPO['Links'] = $GPO.Links + [PSCustomObject] $CreateGPO + } else { + foreach ($Rule in $GPO.DataSet) { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + Version = $Rule.Version + Type = if ($Rule.Dir -eq 'In') { 'Inbound' } elseif ($Rule.Dir -eq 'Out') { 'Outbound' } else { $Rule.Dir } + Name = $Rule.Name + Action = $Rule.Action + Enabled = if ($Rule.Active -eq 'true') { $true } else { $false } + Profile = $Rule.Profile + Svc = $Rule.Svc + LocalAddressIPv4 = $Rule.LA4 + LocalAddressIPv6 = $Rule.LA6 + RemoteAddressIPV4 = $Rule.RA4 + RemoteAddressIPV6 = $Rule.RA6 + LocalPort = $Rule.LPort + RemotePort = $Rule.RPort + Description = $Rule.Desc + EmbedCtxt = $Rule.EmbedCtxt + Edge = $Rule.Edge + IFType = $Rule.IFType + Security = $Rule.Security + + App = $Rule.App + Protocol = $Rule.Protocol + RMAuth = $Rule.RMAuth + RUAuth = $Rule.RUAuth + ICMP4 = $Rule.ICMP4 + LocalName = $Rule.LocalName + Linked = $GPO.Linked + LinksCount = $GPO.LinksCount + Links = $GPO.Links + } + [PSCustomObject] $CreateGPO + } + } +} +<# +Version : 2.30 +Action : Allow +Name : @%SystemRoot%\system32\firewallapi.dll,-37303 +Dir : In +App : %SystemRoot%\system32\svchost.exe +Svc : dnscache +Profile : Public +RA4 : LocalSubnet +RA6 : LocalSubnet +LPort : 5353 +Protocol : 17 +Desc : @%SystemRoot%\system32\firewallapi.dll,-37304 +Active : true +EmbedCtxt : @%SystemRoot%\system32\firewallapi.dll,-37302 + + +Version : 2.30 +Action : Allow +Name : TEST APP +Dir : In +App : C:\Test\exe.exe +Active : true + +Version : 2.30 +Action : Block +Name : Blo +Dir : Out +App : dfdff +Active : true + +Version : 2.30 +Action : Block +Name : @FirewallAPI.dll,-36012 +Dir : Out +App : %SystemRoot%\system32\svchost.exe +Svc : Qwave +Profile : {Private, Public} +RPort : 2177 +Protocol : 17 +Desc : @FirewallAPI.dll,-36013 +Active : true +EmbedCtxt : @FirewallAPI.dll,-36001 +#> \ No newline at end of file diff --git a/Private/Script.GPODictionary.ps1 b/Private/Script.GPODictionary.ps1 index e0cf910..64b1e32 100644 --- a/Private/Script.GPODictionary.ps1 +++ b/Private/Script.GPODictionary.ps1 @@ -1162,6 +1162,36 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Microsoft Defender Antivirus/Microsoft Defender Exploit Guard*' -SingleObject } } + WindowsFirewall = @{ + Types = @( + @{ + Category = 'WindowsFirewallSettings' + Settings = 'InboundFirewallRules' + } + @{ + Category = 'WindowsFirewallSettings' + Settings = 'OutboundFirewallRules' + } + <# + ---- ----- + ConnectionSecurityRules {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=ConnectionSecurityRules; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlEleme... + DomainProfile {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=DomainProfile; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlElement; Filter... + GlobalSettings {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=GlobalSettings; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlElement; Filte... + InboundFirewallRules {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=InboundFirewallRules; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlElement;... + OutboundFirewallRules {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=OutboundFirewallRules; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlElement... + Phase1AuthenticationSets {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=Phase1AuthenticationSets; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlElem... + Phase2AuthenticationSets {@{DisplayName=TEST | Windows Firewall; DomainName=ad.evotec.xyz; GUID=540020A2-61AD-468A-AB61-2F8E7429A9DD; GpoType=Computer; GpoCategory=WindowsFirewallSettings; GpoSettings=Phase2AuthenticationSets; Linked=False; LinksCount=0; Links=; IncludeComments=True; CreatedTime=10.02.2021 17:29:35; ModifiedTime=10.02.2021 19:18:45; ReadTime=10.02.2021 20:23:26; SecurityDescriptor=System.Xml.XmlElem... + PublicProfile + #> + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Windows Firewall with Advanced Security -> ' + Code = { + ConvertTo-XMLWindowsFirewall -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLWindowsFirewall -GPO $GPO -SingleObject + } + } WindowsHelloForBusiness = @{ Types = @( @{