Giter VIP home page Giter VIP logo

windows-firewall's Introduction

Windows Firewall Helper

Overview

Project helping to setup Windows Firewall to block Outbound traffic by default and manage the Allow-rules.

Project Goals

  • Configure Windows Firewall to block Outbound traffic by default and setup needed Auditing to detect what is getting blocked
  • Manage block/unblock not by rules, but by Entities like Program, Service, App.
  • Manage the Custom firewall Allow-rules by desired state config files
  • Identify what Entity is being blocked and create applyable config files to create needed rules to unblock the traffic. By default unblock all destinations, ports and protocols for an Entity.
  • Maintain Common config with standard Allow-rules in categories
  • Detect changes in the Firewall rules and report what is changed and what is the impact (Snapshot baseline files are created)
  • To be able to compare current rules vs Baseline file of previous rules state

Project non-goals

  • Restrict Windows services communication
  • Create rules in a way that they are not modifyable by standard tools

Note: Windows Firewall claims to support rules based on Service, but they do not seem to be working. Windows can differenciate between services using same executable (like svchost.exe) by checking PID and service token, if Service's SID is not of type NONE (https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/configure). Anyway Windows Firewall Rules do not recogcnize the traffic, so blocking in this project is by Program (exe path) and all Windows services use same executable.

Prerquisites

Setup

On high level steps to setup and manage the Outbound Firewall are:

  • (Optional) Create Rules by using Common rules config part of the project
  • Enable Firewall Outbound blocking and Audit events to track what is blocked
  • Analyze Audit events and create own Custom rules for the machine
  • Apply the own custom rules
  • If something is not yet working go back to Analyze Audit events step

When software is being installed it can crate Allow-rules. To make sure that is not the case:

  • Update Baseline snapshot of the Rules before installation
  • (Optional) Enable Deny-all outbound rule
  • Install software
  • Compare current state with Baseline
  • Disable any rules added by the installer
  • (Optional) Disble Deny-all outbound rule

List of Cmdlets are available in helper.ps1. Script is not intended to be run, but specific lines to be executed or copy-pased. Open the script with IDE (VSCode) in Administrator mode and use "Run selection" (F8) to run currently selected code.

Config file format

Config for a rule generated by the project looks like the row below.

    {
      "Description": "Product: Google Update. FileDescription: Google Installer. Associated services: gupdate, gupdatem. ",
      "Program": "c:\\program files (x86)\\google\\update\\googleupdate.exe"
    }

Keys from this config are put on top of default Parameter values and are passed to Cmdlet creating Firewall rules.

Default parameter values are:

    CommonParams = @{
      Enabled       = "True"
      PolicyStore   = "PersistentStore"
      Direction     = "Outbound"
      Action        = "Allow"
      Group         = "AFirewallHelper"
      Profile       = "Any"
      LocalAddress  = "Any"
      LocalPort     = "Any"
      Protocol      = "Any"
      RemoteAddress = "Any"
      RemotePort    = "Any"
      Description   = "Rule Created by Firewall Helper script"
    }

And any of them can be overwrten in the config. If DisplayName of the rule is not defined it will be set by code:

    # create DisplayName
    if (-not $params.DisplayName) {
      if ($params.Program) {
        $params.DisplayName = "FH-" + (Covert-FHStringToSha1 -InputString $params.Program) + "-" + ($params.Program -split '\\')[-1]
      }
      if ($params.Service) {
        $params.DisplayName = "FH-$($params.Service)"
      }
      if ($params.Package) {
        Write-Error -Message "Package rules must have DisplayName property. Skip." -ErrorAction Continue
        continue
      }
    }

windows-firewall's People

Contributors

ivan-georgiev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.