Skip to content

Commit 7c233ff

Browse files
Release 1.0 (#3)
- Implemented code signing - Finalized the documentation - Improved script logic
1 parent 3bdc5c8 commit 7c233ff

28 files changed

+2121
-789
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ jobs:
3838
cache: pip
3939
cache-dependency-path: Generators/mkdocs/requirements.txt
4040

41-
- name: Install MKDocs
42-
run: pip install mkdocs
43-
4441
- name: Build site with MKDocs
4542
run: Generators/mkdocs/mkdocs.sh
4643
env:

.github/workflows/generate-whitepaper.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
paths:
66
- 'ADDS/README.md'
7+
- Generators/pandoc/*
78
- '.github/workflows/generate-whitepaper.yml'
89

910
jobs:
@@ -20,33 +21,23 @@ jobs:
2021
run: echo "date=$(date '+%B %e, %Y')" > $GITHUB_OUTPUT
2122

2223
- name: Generate the whitepaper using Pandoc
23-
uses: docker://pandoc/extra:3.1.1
24+
uses: docker://pandoc/extra:3.5.0
2425
with:
2526
args: >-
2627
--output=Domain_Controller_Firewall.pdf
27-
--from=markdown
28-
--to=pdf
2928
--pdf-engine=xelatex
29+
--template=eisvogel
30+
--resource-path="ADDS:/.pandoc/templates"
31+
--lua-filter=Generators/pandoc/pandoc.lua
32+
--include-in-header=Generators/pandoc/header.tex
33+
--metadata-file=Generators/pandoc/metadata.yml
3034
--shift-heading-level-by=-1
3135
--top-level-division=section
3236
--table-of-contents
3337
--toc-depth=2
3438
--number-sections
35-
--template=eisvogel
36-
--lua-filter=Generators/pandoc/pandoc.lua
37-
--variable=lof:true
38-
--variable=classoption:oneside
39-
--variable=geometry:a4paper,margin=2cm
40-
--variable=colorlinks:true
4139
--variable=linkcolor:"[HTML]{4077C0}"
42-
--variable=titlepage:true
43-
--variable=titlepage-rule-color:de0000
44-
--variable=titlepage-rule-height:40
45-
--variable=header-includes:"\usepackage{sectsty} \sectionfont{\clearpage}"
46-
--variable=caption-justification:centering
47-
--variable=listings-disable-line-numbers:true
4840
--metadata date="${{ steps.get_date.outputs.date }}"
49-
--resource-path="ADDS:/.pandoc/templates"
5041
ADDS/README.md
5142
5243
- name: Publish the whitepaper as artifact

.github/workflows/sign-scripts.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Sign PowerShell Scripts
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- 'ADDS/DCFWTool/*.ps1'
8+
- '.github/workflows/sign-scripts.yml'
9+
10+
permissions:
11+
id-token: write
12+
13+
jobs:
14+
sign:
15+
name: Sign and Publish Scripts
16+
runs-on: windows-latest
17+
timeout-minutes: 10
18+
steps:
19+
- name: Checkout the repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install Azure KeyVault Code Signing Tool
23+
shell: cmd
24+
run: dotnet tool install --global AzureSignTool
25+
26+
- name: Azure Login
27+
uses: azure/login@v2
28+
with:
29+
client-id: ${{ secrets.SIGNING_CLIENT_ID }}
30+
tenant-id: ${{ secrets.SIGNING_TENANT_ID }}
31+
allow-no-subscriptions: true
32+
33+
- name: Sign PowerShell scripts
34+
shell: cmd
35+
env:
36+
SIGNING_VAULT_URL: ${{ secrets.SIGNING_VAULT_URL }}
37+
SIGNING_CERTIFICATE_NAME: ${{ secrets.SIGNING_CERTIFICATE_NAME }}
38+
working-directory: ADDS/DCFWTool
39+
timeout-minutes: 1
40+
run: |
41+
for /f %%i in ('az account get-access-token --resource "https://vault.azure.net" --query accessToken --output tsv') do set KEYVAULT_TOKEN=%%i
42+
AzureSignTool sign ^
43+
Set-ADDSFirewallPolicy.ps1 ^
44+
Show-WindowsFirewallLog.ps1 ^
45+
--file-digest sha256 ^
46+
--timestamp-digest sha256 ^
47+
--timestamp-rfc3161 http://timestamp.digicert.com ^
48+
--azure-key-vault-url "%SIGNING_VAULT_URL%" ^
49+
--azure-key-vault-accesstoken "%KEYVAULT_TOKEN%" ^
50+
--azure-key-vault-certificate "%SIGNING_CERTIFICATE_NAME%"
51+
52+
- name: Upload PowerShell scripts as Artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: DCFWTool
56+
path: ADDS/DCFWTool

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
# Website generated by MkDocs
66
/docs/
77
/site/
8+
9+
# Python virtual environment
10+
/venv/

.markdownlint.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json",
3+
"MD007": {
4+
"$comment": "Increase unordered list indentation for MkDocs compatibility.",
5+
"indent": 4
6+
},
7+
"MD013": {
8+
"$comment": "Allow long lines for code blocks.",
9+
"line_length": 120,
10+
"tables": false
11+
}
12+
}

ADDS/DCFWTool/CustomRules.Sample.ps1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ List of client IP adresses from which inbound traffic should be allowed. This li
2020
2121
.NOTES
2222
Author: Michael Grafnetter
23-
Version: 2.5
23+
Version: 2.6
2424
2525
#>
2626

@@ -32,12 +32,6 @@ param(
3232
[Parameter(Mandatory = $true)]
3333
[string] $GPOSession,
3434

35-
[ValidateNotNullOrEmpty()]
36-
[string[]] $ClientAddresses = @('Any'),
37-
38-
[ValidateNotNullOrEmpty()]
39-
[string[]] $ManagementAddresses = @('Any'),
40-
4135
[ValidateNotNullOrEmpty()]
4236
[string[]] $DomainControllerAddresses = @('Any'),
4337

@@ -58,7 +52,7 @@ Feel free to add your custom firewall rules below to match your environment.
5852
#>
5953

6054
# Create Inbound rule "File and Printer Sharing over SMBDirect (iWARP-In)"
61-
New-NetFirewallRule -GPOSession $gpoSession `
55+
New-NetFirewallRule -GPOSession $GPOSession `
6256
-Name 'FPSSMBD-iWARP-In-TCP' `
6357
-DisplayName 'File and Printer Sharing over SMBDirect (iWARP-In)' `
6458
-Group 'File and Printer Sharing over SMBDirect' `

ADDS/DCFWTool/RpcNamedPipesFilters.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Synopsis: This NETSH script is part of the Domain Controller Firewall project.
22
# Author: Michael Grafnetter
3-
# Version: 2.0
3+
# Version: 2.1
44
# Usage: netsh.exe -f RpcNamedPipesFilters.txt
55
# Rollback: netsh.exe rpc filter delete filter filterkey=all
66
# Check: netsh.exe rpc filter show filter
@@ -96,18 +96,6 @@ add rule layer=um actiontype=block filterkey=0a239867-73db-45e6-b287-d006fe3c8b1
9696
add condition field=if_uuid matchtype=equal data=4FC742E0-4A10-11CF-8273-00AA004AE673
9797
add filter
9898

99-
# Restrict [MS-FSRVP]: File Server Remote VSS Protocol, Named pipe: \PIPE\FssagentRpc
100-
# Limit access to Domain Admins only.
101-
add rule layer=um actiontype=permit filterkey=869a3c6c-60dd-4558-a58b-8d9e86b0da5f
102-
add condition field=if_uuid matchtype=equal data=a8e0653c-2744-4389-a61d-7373df8b2292
103-
add condition field=remote_user_token matchtype=equal data=D:(A;;CC;;;DA)
104-
add filter
105-
106-
# Block MS-FSRVP by default
107-
add rule layer=um actiontype=block filterkey=4bce314a-d956-41cf-86f1-75067362cae6
108-
add condition field=if_uuid matchtype=equal data=a8e0653c-2744-4389-a61d-7373df8b2292
109-
add filter
110-
11199
# Block [MS-DNSP]: Domain Name Service (DNS) Server Management Protocol, Named pipe: \PIPE\DNSSERVER
112100
# This rule only blocks RPC over Named Pipes, while RPC over TCP is still allowed.
113101
add rule layer=um actiontype=block filterkey=50754fe4-aa2d-42ff-8196-e90ea8fd2527

ADDS/DCFWTool/Set-ADDSFirewallPolicy.ps1

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Online documentation: https://github.com/MichaelGrafnetter/active-directory-fire
1818
1919
.NOTES
2020
Author: Michael Grafnetter
21-
Version: 2.5
21+
Version: 2.7
2222
2323
#>
2424

@@ -254,14 +254,18 @@ if($configuration.EnableNetbiosNameService -or $configuration.EnableNetbiosDatag
254254
Write-Warning -Message 'NetBIOS is a legacy protocol and should be disabled in modern networks.'
255255
}
256256

257-
if(-not($configuration.DisableLLMNR -and $configuration.DisableMDNS -and $configuration.DisableNetbiosBroadcasts)) {
258-
Write-Warning -Message 'Only the DNS protocol should be used for name resolution in modern networks.'
257+
if(-not($configuration.DisableLLMNR -and $configuration.DisableMDNS)) {
258+
Write-Warning -Message 'Only the DNS protocol should be used for name resolution in modern networks. Protocols using distributed name resolution, including LLMNR and mDNS, should be disabled on DCs.'
259259
}
260260

261261
if(-not($configuration.LogMaxSizeKilobytes -ge 16384 -and $configuration.LogDroppedPackets -and $configuration.LogAllowedPackets)) {
262262
Write-Warning -Message 'The firewall log settings do not meet the standardized security baselines.'
263263
}
264264

265+
if($configuration.BlockWmiCommandExecution -eq $true) {
266+
Write-Warning -Message 'SCCM client and DP do not work properly on systems where command execution over WMI is blocked.'
267+
}
268+
265269
#endregion Configuration Validation
266270

267271
#region Create and Configure the GPO
@@ -1697,44 +1701,6 @@ Save-NetGPO -GPOSession $gpoSession
16971701

16981702
#region Registry Settings
16991703

1700-
# Set the Delivery Optimization Download Mode to Simple
1701-
# DCs should not be downloading updates from peers.
1702-
Set-GPRegistryValue -Guid $gpo.Id `
1703-
-Key 'HKLM\Software\Policies\Microsoft\Windows\DeliveryOptimization' `
1704-
-ValueName 'DODownloadMode' `
1705-
-Value 99 `
1706-
-Type DWord `
1707-
-Domain $domain.DNSRoot `
1708-
-Server $targetDomainController `
1709-
-Verbose:$isVerbose > $null
1710-
1711-
# Set Allow Telemetry to Security [Enterprise Only]
1712-
Set-GPRegistryValue -Guid $gpo.Id `
1713-
-Key 'HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection' `
1714-
-ValueName 'AllowTelemetry' `
1715-
-Value 0 `
1716-
-Type DWord `
1717-
-Domain $domain.DNSRoot `
1718-
-Server $targetDomainController `
1719-
-Verbose:$isVerbose > $null
1720-
1721-
# Turn off Application Telemetry
1722-
Set-GPRegistryValue -Guid $gpo.Id `
1723-
-Key 'HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat' `
1724-
-ValueName 'AITEnable' `
1725-
-Value 0 `
1726-
-Type DWord `
1727-
-Domain $domain.DNSRoot `
1728-
-Server $targetDomainController `
1729-
-Verbose:$isVerbose > $null
1730-
1731-
<#
1732-
TODO: Add more registry settings
1733-
- OneSettings
1734-
- Allow Diagnostic Data to Disabled.
1735-
Administrative Template > Windows Components > Data Collection and Preview Builds
1736-
#>
1737-
17381704
# Prevent users and apps from accessing dangerous websites
17391705
# (Enables Microsoft Defender Exploit Guard Network Protection)
17401706
# This might block some Internet C2 traffic.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@ECHO OFF
2+
REM Synopsis: This script resets the unmanaged domain controller policy settings to their default values.
3+
REM It is intended to be executed locally on all domain controllers in the domain.
4+
REM Author: Michael Grafnetter
5+
REM Version: 1.0
6+
7+
gupdate /force
8+
9+
echo Make sure that GPO settings are applied.
10+
gpupdate.exe /Target:Computer
11+
12+
echo Move the WMI service into the shared Svchost process.
13+
winmgmt.exe /sharedhost
14+
15+
echo Configure the DFS Replication service to use a dynamic RPC port.
16+
dfsrdiag.exe StaticRPC /Port:0
17+
18+
echo Remove all RPC filters.
19+
netsh.exe rpc filter delete filter filterkey=all
20+
21+
echo Configure the Active Directory service to use a dynamic RPC port.
22+
reg.exe delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters" /v "TCP/IP Port" /f
23+
24+
echo Configure the Netlogon service to use a dynamic RPC port.
25+
reg.exe delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters" /DCTcpipPort /f
26+
27+
echo Configure the legacy FRS service to use a dynamic RPC port.
28+
reg.exe delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTFRS\Parameters" /v "RPC TCP/IP Port Assignment" /f
29+
30+
echo Reset mDNS settings.
31+
reg.exe delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" /v EnableMDNS /f
32+
33+
echo Reset ICMP settings.
34+
reg.exe delete "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v EnableICMPRedirect /f
35+
reg.exe delete "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v PerformRouterDiscovery /f
36+
reg.exe delete "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v DisableIPSourceRouting /f
37+
reg.exe delete "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip6\Parameters" /v DisableIPSourceRouting /f
38+
39+
echo Reset NetBIOS settings.
40+
reg.exe delete "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Parameters" /v NoNameReleaseOnDemand /f
41+
reg.exe delete "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Parameters" /v NodeType /f
42+
43+
echo Restart the NTDS service.
44+
net.exe stop NTDS
45+
net.exe start NTDS
46+
47+
echo Restart the NtFrs service.
48+
net.exe stop NtFrs
49+
net.exe start NtFrs

ADDS/GPOReport.html

36.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)