Skip to content

❄️ Firewall Groups & Rules Dumper — Converts "Allow" rules to applicable commands, for Windows (PowerShell) ☂️

Notifications You must be signed in to change notification settings

tester1010101/Get-Rules-Groups

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Get-Rules & Groups (v1.2) ♻️ 🔰

  • 💠 Dumps ALL ("Allow") Firewall Rules from Windows Defender Firewall with Advanced Security.
  • 💠 Reconverts them into applicables one through "netsh advfirewall firewall add rule".
  • 💠 Will get dumped & converted in: %USERPROFILE%\Rules\FWCommands.txt
  • 💠 Prompts user to open the dump/rules location, for analysis/learning/re-apply/backups.
  • 📂 To-do: Add to extraction/conversion: Deny rules ⛔

  • ⚠️ Packages in rules won't be applied/converted/extracted to rules (to-do)

image

Instructions:

  • Right-click the script, run in PowerShell 🔂

Get-Rules Block 🎦

  1. Creates the Rules folder in %USERPROFILE%\Rules if not present
  2. Dumps all "allowed" firewall rules into a textfile at %USERPROFILE%\Rules\FW-Rules.txt
  3. Stock the rules into a variable from the file dumped (user can use custom file/path)
  4. Parse each rules ending at '(?<=Action: Allow)'
  5. Create a .txt of each rules at %USERPROFILE%\Rules$i.txt
  6. Increment until none left

image

Conversion (Rules, Groups) 🔄

  1. Gets the last item of the rules dumped, then starts the loop until last rule
  2. Starting from rule #1, it'll extract all rule's parameters into variables
  3. Then create a netsh command to re-enter it as needed, with rule's variables
  4. Each set of variables creates a command which is added to a command file
  5. Final textfile contains all commands ready to be applied, in the 'netsh' format.

image image image

I created this dumper to easily re-create multiple rules I needed. Be sure to note the packages or you may be missing some stuff, lemme know if anything is wrong! With the "Export Policy" option, you can't select which to export/import, (like the predefined firewall rules) you have to overwrite the whole set ❌