
windows 自动屏蔽扫描爆破
此内容年代久远,谨慎参考
由于现在扫描爆破的人越来越多,且成本越来越低,除了改端口加证书以外,自动屏蔽恶意 IP 也是很必要的手段
wind 是一个 windows 下的托管工具,用于托管不原生支持 windows 服务的应用程序或服务
IPBan 是一个根据规则来自动对恶意 IP 进行封禁的服务
§安装 IPBan
下载并解压到磁盘即可,推荐 C:\Program Files\ipban
找到并打开 DigitalRuby.IPBan.dll.config 配置文件,定位到 <appSettings> 节,按以下示例或自行喜好修改
xml<!--未列出项表示未修改-->
<appSettings>
<!--尝试失败多少次后屏蔽-->
<add key="FailedLoginAttemptsBeforeBan" value="3"/>
<!--屏蔽时间,"00:00:00:00" 代表永久,这里是一个 TimeSpan 类型-->
<add key="BanTime" value="00:00:00:00"/>
</appSettings>
修改完成后直接双击 DigitalRuby.IPBan.exe 尝试以控制台模式启动,没有错误的话应该会输出以下内容
plain2020-07-21 20:40:54.5441|WARN|DigitalRuby.IPBanCore.Logger|Initializing service
2020-07-21 20:40:54.8536|WARN|DigitalRuby.IPBanCore.Logger|Preparing to run service
2020-07-21 20:40:54.8647|WARN|DigitalRuby.IPBanCore.Logger|Starting service
2020-07-21 20:40:54.8647|WARN|DigitalRuby.IPBanCore.Logger|Running service
2020-07-21 20:40:56.4644|WARN|DigitalRuby.IPBanCore.Logger|Loaded firewall type DigitalRuby.IPBanCore.IPBanWindowsFirewall
2020-07-21 20:40:56.5473|WARN|DigitalRuby.IPBanCore.Logger|Syncing firewall and ipban.sqlite database...
2020-07-21 20:40:56.6284|WARN|DigitalRuby.IPBanCore.Logger|3 total ip addresses in the ipban.sqlite database
2020-07-21 20:40:56.6284|WARN|DigitalRuby.IPBanCore.Logger|IPBan Windows service started and initialized. Operating System: Name: Windows, Version: 10.0.17763, Friendly Name: Microsoft Windows Server 2019 Datacenter, Description: Microsoft Windows 10.0.17763
2020-07-21 20:40:56.6284|WARN|DigitalRuby.IPBanCore.Logger|Log levels: True,True,True,False,False,False
注意 IPBan 需要以特权账号运行才能正常屏蔽
如果你不是小白,或不希望有额外配置,可以就此止步,直接将 IPBan 配置为系统服务即可
§使用 wind 托管 IPBan
因为我想在任何时候任何地点了解 IPBan 的工作状态,所以我用 wind 来托管 IPBan

wind 托管 IPBan

wind 托管 IPBan
首先下载并配置 wind 后,进入单元目录,新建一个单元配置文件 ipban.json 并填充以下内容
json{
"Name": "IPBan",
"Description": "IPBan Monitors failed logins and bad behavior and bans ip addresses",
"Type": 0,
"AbsoluteExecutePath": "C:\Program Files\ipban\DigitalRuby.IPBan.exe",
"AbsoluteWorkDirectory": "C:\Program Files\ipban",
"Arguments": null,
"AutoStart": true,
"AutoStartDelay": 0,
"RestartWhenException": false,
"PriorityClass": null,
"ProcessorAffinity": null,
"StandardInputEncoding": null,
"StandardOutputEncoding": null,
"StandardErrorEncoding": null,
"MonitorPerformanceUsage": true,
"MonitorNetworkUsage": false
}
接着执行 windctl load ipban
来加载此配置文件,然后执行 windctl status-all
来检查是否正确加载了配置文件
如果配置文件加载失败,可以在 wind 的安装目录下检查日志排查问题
如果配置文件加载成功,那么可以执行 windctl start ipban
来启动单元,并使用 windctl status ipban
来查看单元状态

wind 托管 IPBan