-
Notifications
You must be signed in to change notification settings - Fork 97
Description
Hi, I have this function to enable rules in the firewall.
function Set-FirewallRules {
chcp 1252 | Out-Null
# Enable all firewall profiles
Set-NetFirewallProfile -All -Enabled True
# Specific rules to enable (using DisplayName)
$rulesToEnable = @(
'Compartilhamento de Arquivo e Impressora (SMB-Entrada)',
'Coordenador de Transações Distribuídas (RPC)',
'Coordenador de Transações Distribuídas (RPC-EPMAP)',
'Coordenador de transações distribuídas (TCP-Entrada)',
'Gerenciamento Remoto de Tarefas Agendadas (RPC)',
'Gerenciamento Remoto de Tarefas Agendadas (RPC-EPMAP)',
'Gerenciamento de Volumes Remoto - Carregador de Serviço de Disco Virtual (RPC)',
'Gerenciamento de Volumes Remoto (RPC-EPMAP)',
'Gerenciamento de Volumes Remoto - Serviço de Disco Virtual (RPC)',
'Gerenciamento Remoto (RPC) do Windows Defender Firewall',
'Gerenciamento Remoto de Serviços (NP-Entrada)',
'Gerenciamento Remoto de Serviços (RPC)',
'Gerenciamento Remoto de Serviços (RPC-EPMAP)',
'Gerenciamento Remoto do Log de Eventos (NP-Entrada)',
'Gerenciamento Remoto do Log de Eventos (RPC)',
'Gerenciamento Remoto do Log de Eventos (RPC-EPMAP)',
'Gerenciamento Remoto do Windows Defender Firewall (RPC-EPMAP)',
'Instrumentação de Gerenciamento do Windows (ASync-In)',
'Instrumentação de Gerenciamento do Windows (DCOM-In)',
'Instrumentação de Gerenciamento do Windows (WMI-In)',
'Logs e Alertas de Desempenho (DCOM-Entrada)',
'Logs e Alertas de Desempenho (TCP-Entrada)'
)
# Enable specific rules
$rulesToEnable | ForEach-Object {
$rule = Get-NetFirewallRule -DisplayName $_ -ErrorAction SilentlyContinue
if ($rule) {
if ($rule.Enabled -ne 'True') {
Set-NetFirewallRule -DisplayName $_ -Enabled True -Profile Domain
Write-Host "Rule enabled: $_"
} else {
Write-Host "Rule already enabled: $_"
}
} else {
Write-Warning "Rule not found: $_"
}
}
}
The rules are written in Brazilian Portuguese (PT-BR) and contain accented characters. When the function is run directly in PowerShell, it works correctly and the rules are enabled without any problems. However, when using Chameleon (with the command python .\chameleon --base64 -t r file.ps -o file1.ps1), the rules stop working because the accented characters are not interpreted correctly at the PowerShell prompt, resulting in distortions in the text.
Rule already enabled: Compartilhamento de Arquivo e Impressora (SMB-Entrada)
AVISO: Rule not found: Coordenador de Transações DistribuÃÂdas (RPC)
AVISO: Rule not found: Coordenador de Transações DistribuÃÂdas (RPC-EPMAP)
AVISO: Rule not found: Coordenador de transações distribuÃÂdas (TCP-Entrada)
Rule already enabled: Gerenciamento Remoto de Tarefas Agendadas (RPC)
Rule already enabled: Gerenciamento Remoto de Tarefas Agendadas (RPC-EPMAP)
AVISO: Rule not found: Gerenciamento de Volumes Remoto - Carregador de Serviço de Disco Virtual (RPC)