> For the complete documentation index, see [llms.txt](https://mysther.gitbook.io/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mysther.gitbook.io/knowledge-base/defesa/firewall/windows.md).

# Windows

Verificando as regras de firewall do perfil atual:

```powershell
netsh advfirewall show currentprofile
```

Verificando todas as regras de firewall:

```
netsh advfirewall firewall show rule name=all
```

Adicionando determinado arquivo com extensão `exe` nas regras do firewall

```bash
netsh advfirewall firewall add rule name="<nome_regra" dir=in action=allow program="C:\{arquivo.exe}"
```

Verificando configurações

```bash
netsh firewall show state
netsh firewall show config
```

Verificando status

```bash
netsh advfirewall show currentprofile
```

Caso o `State` do comando acima esteja `ON`, podemos verificar as regras de firewall

```bash
netsh advfirewall firewall show rule name=all
```

Desabilitando firewall de todos os perfis com Powershell.

```bash
# Powershell
Set-NetFirewallProfile -Name Domain,Private,Public -Enabled False

# Prompt de Comando (netsh)
netsh advfirewall set allprofiles state off
```

Windows Defender

```bash
# Habilitando
Set-MpPreference -DisableRealtimeMonitoring $false

# Desabilitando
Set-MpPreference -DisableRealtimeMonitoring $true
```
