Skip to main content

Ver reglas de firewall desde PowerShell

Para visualizar el conjunto de reglas del Firewall de Windows Defender mediante PowerShell, podemos ejecutar lo siguiente

Show-NetFirewallRule 

Esto nos dará una salida como la siguiente

PS C:\Users\Administrador.TECNOCRATICA> Show-NetFirewallRule

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Name                       : SNMP-Out-UDP-NoScope
DisplayName                : Servicio SNMP (UPD de salida)
Description                : Regla de salida del servicio Protocolo simple de administración de red (SNMP) para permitir el tráfico SNMP. [UDP 161]
DisplayGroup               : Servicio SNMP
Group                      : @snmp.exe,-3
Enabled                    : True
Profile                    : Domain
Platform                   :
Direction                  : Outbound
Action                     : Allow
EdgeTraversalPolicy        : Block
LooseSourceMapping         : False
LocalOnlyMapping           : False
Owner                      :
PrimaryStatus              : OK
Status                     : Se analizó la regla correctamente desde el almacén. (65536)
EnforcementStatus          : NotApplicable
PolicyStoreSource          : PersistentStore
PolicyStoreSourceType      : Local

$_ | Get-NetFirewallAddressFilter
     LocalAddress          : Any
     RemoteAddress         : Any

$_ | Get-NetFirewallServiceFilter
     Service               : SNMP

$_ | Get-NetFirewallApplicationFilter
     Program               : %SystemRoot%\system32\snmp.exe
     Package               :

$_ | Get-NetFirewallInterfaceFilter
     InterfaceAlias        : Any

$_ | Get-NetFirewallInterfaceTypeFilter
     InterfaceType         : Any

$_ | Get-NetFirewallPortFilter
     Protocol              : UDP
     LocalPort             : Any
     RemotePort            : 161
     IcmpType              : Any
     DynamicTarget         : Any

$_ | Get-NetFirewallSecurityFilter
     Authentication        : NotRequired
     Encryption            : NotRequired
     OverrideBlockRules    : False
     LocalUser             : Any
     RemoteUser            : Any
     RemoteMachine         : Any
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Name                       : SNMP-In-UDP-NoScope
DisplayName                : Servicio SNMP (UPD de entrada)
Description                : Regla de entrada del servicio Protocolo simple de administración de red (SNMP) para permitir el tráfico SNMP. [UDP 161]
DisplayGroup               : Servicio SNMP
Group                      : @snmp.exe,-3
Enabled                    : True
Profile                    : Domain
Platform                   :
Direction                  : Inbound
Action                     : Allow
EdgeTraversalPolicy        : Block
LooseSourceMapping         : False
LocalOnlyMapping           : False
Owner                      :
PrimaryStatus              : OK
Status                     : Se analizó la regla correctamente desde el almacén. (65536)
EnforcementStatus          : NotApplicable
PolicyStoreSource          : PersistentStore
PolicyStoreSourceType      : Local

$_ | Get-NetFirewallAddressFilter
     LocalAddress          : Any
     RemoteAddress         : Any

$_ | Get-NetFirewallServiceFilter
     Service               : SNMP

$_ | Get-NetFirewallApplicationFilter
     Program               : %SystemRoot%\system32\snmp.exe
     Package               :

$_ | Get-NetFirewallInterfaceFilter
     InterfaceAlias        : Any

$_ | Get-NetFirewallInterfaceTypeFilter
     InterfaceType         : Any

$_ | Get-NetFirewallPortFilter
     Protocol              : UDP
     LocalPort             : 161
     RemotePort            : Any
     IcmpType              : Any
     DynamicTarget         : Any

$_ | Get-NetFirewallSecurityFilter
     Authentication        : NotRequired
     Encryption            : NotRequired
     OverrideBlockRules    : False
     LocalUser             : Any
     RemoteUser            : Any
     RemoteMachine         : Any

Obtener la información de las reglas de Firewall de Windows Defender por puerto destino

Por ejemplo, saber los procesos que tienen habilitado el puerto 80. En Windows ejecutaremos powershell ISE, creamos un archivo nuevo y escribimos el siguiente script

Get-NetFirewallPortFilter |
    Where-Object { $_.LocalPort -eq 80 } |
    Get-NetFirewallRule

 

image.png