✅ 一键防内存被攻击爆满防护脚本(管理员PowerShell直接运行)

✅ 一键防内存被攻击爆满防护脚本(管理员PowerShell直接运行)

1777706071092

 

Write-Host "正在配置服务器防内存爆满防护..." -ForegroundColor Cyan;
# 1. 开启系统低内存保护,强制优先释放闲置内存
New-Item -Path "HKLM:SYSTEMCurrentControlSetControlSession ManagerMemory Management" -Force | New-ItemProperty -Name LowMemoryThreshold -Value 512 -PropertyType DWord -Force;
New-Item -Path "HKLM:SYSTEMCurrentControlSetControlSession ManagerMemory Management" -Force | New-ItemProperty -Name DisablePagingExecutive -Value 1 -PropertyType DWord -Force;
# 2. 限制单进程最大内存占用(防止恶意进程吃爆内存)
New-Item -Path "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionsphp-cgi.exePerfOptions" -Force | New-ItemProperty -Name CpuPriorityClass -Value 4 -PropertyType DWord -Force;
New-Item -Path "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionsnginx.exePerfOptions" -Force | New-ItemProperty -Name CpuPriorityClass -Value 4 -PropertyType DWord -Force;
# 3. 开启自动内存保护,内存低于20%时强制释放
schtasks /Create /TN "AutoMemoryGuard" /TR "powershell.exe -Command "Get-Process | Where-Object {$_.WorkingSet64 -gt 0} | ForEach-Object {try{$_.MinWorkingSet=$_.WorkingSet64;$_.MaxWorkingSet=$_.WorkingSet64}catch{}}; wmic memorycache delete 2>&1 | Out-Null"" /SC MINUTE /MO 5 /RL HIGHEST /F >nul 2>&1;
# 4. 关闭系统内存自动膨胀功能
New-Item -Path "HKLM:SYSTEMCurrentControlSetServicesSysMainParameters" -Force | New-ItemProperty -Name NoSuperfetch -Value 1 -PropertyType DWord -Force;
Write-Host "✅ 防内存爆满防护配置完成!网站访问不受影响" -ForegroundColor Green

✅ 一键防内存被攻击爆满防护脚本(管理员PowerShell直接运行)

© 版权声明
THE END
喜欢就支持一下吧
点赞91.9W+ 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容