🌟 善无痕蛇无泪

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

神人佛
🕐 2026-05-02 15:09 👁️ 0 浏览

✅ 一键防内存被攻击爆满防护脚本(管理员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直接运行)

📰 生成文章海报
正在生成海报...
分类: 优化教程
💬 精彩评论 0条
还没有评论,快来抢沙发吧~

发表评论

你的邮箱地址不会被公开,带 * 为必填项

上一篇
✅ 一键禁用 Server 2022 多余后台服务(不影响网站)
下一篇
✅ 一键防CPU被压死防护脚本(管理员PowerShell运行)
👥 总访问: 1.6K
|
📅 今日: 970
|
🟢 在线: 1
网页: ...
|
🖥️ 服务: 0.024秒
|
💾 内存: 3.62M
|
📊 查询: 54次