Windows安全日志中,大量的事件ID4625;

最近偶然发现Windows安全日志(Win10_64位)中有大量的网络登录失败记录(事件ID为4625),大量的外网IP尝试后台登录我的计算机,感觉公司的网络已经不安全了,只能自己想办法尽量保护好自己电脑。

尝试操作1:禁用Server服务,在“网络和共享中心”中,关闭所有共享----->无效。

尝试操作2:编写一个powershell脚本,用来阻止外网IP----->这个不治本。

$arrayT1=New-Object 'string[,]' 1,1;
$arrayList=New-Object System.Collections.ArrayList;
$arrayList.Clear();
$stream=Get-EventLog -LogName Security -InstanceID 4625 | Select-Object -Property * | Out-String -Stream
[regex]::matches($stream, '(\d+\.){3}\d+') | %{
    $count=$arrayList.Count;
    if ($count -ge 1) {
        $b=0;
        for ($i=0;$i -lt $count;$i++) {
            if ($arrayList[$i][0] -eq [string]$_.Value) {
                $arrayList[$i][1]+=1;
                break;
            }
            else {
                  $b=$i+1;
            }
        }
        if ($b -eq $count) {
            $arrayT1=($_.Value,1); 
            $arrayList.add($arrayT1);
        }
    }
    else {
        $arrayT1=($_.Value,1);
        $arrayList.add($arrayT1);
    }
} | Out-Null;
$count1=$arrayList.Count;
$array1=New-Object 'string[]' $count1;
for ($i=0;$i -lt $count1;$i++) {
    $int1=0;
    $int2=1;
    for ($j=0;$j -lt $arrayList.Count;$j++){
        if ($arrayList[$j][1] -gt $int2) {
            $int2=$arrayList[$j][1];
            $int1=$j;
        }
    }
    $str1="";
    $c=16 - [string]$arrayList[$int1][0].length;
    for ($k=0;$k -lt $c;$k++) {
        $str1=$str1 + " ";
    }
    $array1[$i]=$arrayList[$int1][0] + $str1 + "---> " + $arrayList[$int1][1];
    $str2="ForbiddenIP:" + $arrayList[$int1][0];
    New-NetFirewallRule -DisplayName $str2 -Direction Inbound -Action Block -RemoteAddress $arrayList[$int1][0] | Out-Null;
    $arrayList.Remove($arrayList[$int1]);
}
"Total:" + $count1;
$array1;

尝试操作3:禁用3389,445,23号端口---->亲测有效!

(不过电脑仍然还有很多事件ID4624,4627,4672,4688,4720,4724,4726,4728,4729,4797,4799,5379生成;这个怀疑是域环境下的网络异常问题,又不能脱域,先不管了.......)

猜你喜欢

转载自www.cnblogs.com/Mst5u/p/11163304.html