Compare commits
No commits in common. "9fddccdc620def1f406b935f6d0638a335a24919" and "7fbd179fe2baf723cd99f05cc7ed03287b1a8b42" have entirely different histories.
9fddccdc62
...
7fbd179fe2
2 changed files with 19 additions and 26 deletions
41
cleanW10.ps1
41
cleanW10.ps1
|
@ -10,11 +10,8 @@ Set-StrictMode -Version 2
|
||||||
#$PSDefaultParameterValues=@{$dir = "./modules.d"}
|
#$PSDefaultParameterValues=@{$dir = "./modules.d"}
|
||||||
$HOST_FILE = "$env:windir\System32\drivers\etc\hosts"
|
$HOST_FILE = "$env:windir\System32\drivers\etc\hosts"
|
||||||
$HOST_IP = "0.0.0.0"
|
$HOST_IP = "0.0.0.0"
|
||||||
$FW_RULE_NAME_PREFIX = "CleanW10"
|
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
$ProgressPreference = "SilentlyContinue"
|
$ProgressPreference = "SilentlyContinue"
|
||||||
|
|
||||||
#Thanks to https://gist.github.com/markembling/173887
|
#Thanks to https://gist.github.com/markembling/173887
|
||||||
function BlockHost {
|
function BlockHost {
|
||||||
param(
|
param(
|
||||||
|
@ -69,20 +66,14 @@ function FwBlockOutputIP {
|
||||||
foreach ($line in Get-Content $params.file ){ FwBlockOutputIP @{"ip"="$line"} }
|
foreach ($line in Get-Content $params.file ){ FwBlockOutputIP @{"ip"="$line"} }
|
||||||
}
|
}
|
||||||
elseif ( $params.ContainsKey('ip') ) {
|
elseif ( $params.ContainsKey('ip') ) {
|
||||||
if (-not $params.ContainsKey('name') -or $params.name -eq "" ) {
|
Write-Host -NoNewline "`t$($params.ip) : "
|
||||||
$name = $FW_RULE_NAME_PREFIX + "_IP_" + $params.ip
|
if ( Get-NetFirewallRule -Name Blacklist_$($params.ip) -ErrorAction SilentlyContinue) {
|
||||||
}
|
Write-Host -ForegroundColor Yellow "already blacklisted"
|
||||||
else {
|
|
||||||
$name = $FW_RULE_NAME_PREFIX + "_IP_" + $params.name
|
|
||||||
}
|
|
||||||
Write-Host -NoNewline "`tAdd FW IP rule $name ($($params.ip)) : "
|
|
||||||
if ( Get-NetFirewallRule -Name $name -ErrorAction SilentlyContinue) {
|
|
||||||
Write-Host -ForegroundColor Yellow "already exist"
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Try {
|
Try {
|
||||||
New-NetFirewallRule -Name $name -DisplayName "$name (blacklist $($params.ip))" -Direction Outbound -Protocol any -Enabled True -Profile Any -RemoteAddress $params.ip -Action Block | Out-Null
|
New-NetFirewallRule -Name Blacklist_$($params.ip) -DisplayName "BlackList $($params.ip)" -Direction Outbound -Protocol any -Enabled True -Profile Any -RemoteAddress $params.ip -Action Block | Out-Null
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
Write-Host -ForegroundColor Red "error"
|
Write-Host -ForegroundColor Red "error"
|
||||||
|
@ -109,29 +100,29 @@ function FwBlockProgram {
|
||||||
[object]$params
|
[object]$params
|
||||||
)
|
)
|
||||||
if ( $params.ContainsKey('file') ) {
|
if ( $params.ContainsKey('file') ) {
|
||||||
foreach ($line in Get-Content $params.file ){ FwBlockProgram @{"path"="$line"} }
|
foreach ($line in Get-Content $params.file ){ FwBlockOutputIP @{"ip"="$line"} }
|
||||||
}
|
}
|
||||||
elseif ( $params.ContainsKey('path') ) {
|
elseif ( $params.ContainsKey('path') ) {
|
||||||
$path = Invoke-Expression """$($params.path)"""
|
$path = Invoke-Expression """$($params.path)"""
|
||||||
if ( -not $params.ContainsKey('name') -or $params.name -eq "" ) {
|
Write-Host -NoNewline "`tBlock program $($path) : "
|
||||||
$name = $FW_RULE_NAME_PREFIX + "_PROG_" + $params.path
|
|
||||||
}
|
|
||||||
$name = $FW_RULE_NAME_PREFIX + "_PROG_" + $params.name
|
|
||||||
Write-Host -NoNewline "`tAdd FW program rule $name ($($path)) : "
|
|
||||||
if ( Get-NetFirewallRule -Name $name -ErrorAction SilentlyContinue) {
|
|
||||||
Write-Host -ForegroundColor Yellow "already exist"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ( -not (Test-Path $path) ) {
|
if ( -not (Test-Path $path) ) {
|
||||||
Write-Host -Foregroundcolor Red "Error (path not found)"
|
Write-Host -Foregroundcolor Red "Error (path not found)"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if ( -not $params.ContainsKey('name') ) {
|
||||||
|
$params.name = $params.path
|
||||||
|
}
|
||||||
|
if ( Get-NetFirewallRule -Name $($params.name) -ErrorAction SilentlyContinue) {
|
||||||
|
Write-Host -ForegroundColor Yellow "already blacklisted"
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
New-NetFirewallRule -Name "$name" -DisplayName "$name (program : $($params.path))" -Program "$path" -Direction Outbound -Protocol any -Enabled True -Profile Any -RemoteAddress any -Action Block | Out-Null
|
New-NetFirewallRule -Name "$($params.name)" -DisplayName "$($params.name)" -Program "$path" -Direction Outbound -Protocol any -Enabled True -Profile Any -RemoteAddress any -Action Block | Out-Null
|
||||||
Write-Host -ForegroundColor Green "done"
|
Write-Host -ForegroundColor Green "done"
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -ForegroundColor Red "error"
|
Write-Host -ForegroundColor Red "error"
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -377,7 +368,7 @@ function UninstallModernApp {
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -NoNewLine -ForegroundColor Red "Error `n`t"
|
Write-Host -NoNewLine -ForegroundColor Red "Error `n`t"
|
||||||
write-Host -ForegroundColor DarkRed $_
|
write-Host -ForegroundColor DarkRed "Impossible to Uninstall. Is this a system one."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
40.77.226.246
|
40.77.226.246
|
||||||
40.79.79.123
|
40.79.79.123
|
||||||
40.127.139.224
|
40.127.139.224
|
||||||
|
52.169.118.173
|
||||||
64.4.23.151
|
64.4.23.151
|
||||||
65.54.225.167
|
65.54.225.167
|
||||||
|
65.55.108.23
|
||||||
92.122.180.48
|
92.122.180.48
|
||||||
93.184.221.200
|
93.184.221.200
|
||||||
95.101.148.83
|
95.101.148.83
|
||||||
|
|
Reference in a new issue