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生成;这个怀疑是域环境下的网络异常问题,又不能脱域,先不管了.......)

 

posted @   Mst.W  阅读(9526)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示