用vbscript来添加ip策略 自动封IP
导读:收集整理的这篇文章主要介绍了用vbscript来添加ip策略 自动封IP,觉得挺不错的,现在分享给大家,也给大家做个参考。 程序主要是读取这个网站的iis日志,分析出其中的IP地址,用安...
收集整理的这篇文章主要介绍了用vbscript来添加ip策略 自动封IP,觉得挺不错的,现在分享给大家,也给大家做个参考。 程序主要是读取这个网站的iis日志,分析出其中的IP地址,用安全策略自动封闭。vbS代码如下: 复制代码 代码如下:
'代码开始
Set fileobj=CreateObject("Scripting.fileSystemobject")
LOGfilepath="E:w3logW3SVC237ex070512old.log" '注意指定受攻击网站的日志路径。
'如果是虚拟主机,要查是哪个网站受攻击,可以查看:C:WINDOWSsystem32LogFilesHTTPERR ,
根据错误日志很容易分析出来。
wrITelog "netsh ipsec static add policy name=XBLUE"
writelog "netsh ipsec static add filterlist name=denyip"
overip=""
f_name=logfilepath
'指定日志文件
'程序功能:把logfiles中的IP提取成ipsec需要的过滤格式,导入ipsec中过滤。适合某个网站受大量CC攻击的情况。
set fileobj88=CreateObject("Scripting.FileSystemObject")
Set MYFILE=fileobj88.OpenTextFile(f_name,1,false)
contentover=MYFILE.ReadAll()
contentip=lcase(contentover)
MYFILE.close
set fileobj88=nothing
on error resume next
myline=split(contentip,chr(13))
for i=0 to ubound(myline)-1
myline2=split(myline(i)," ")
newip=myline2(6)
'指定分离的标识字符串!
if instr(overip,newip)=0 then '去除重复的IP。
overip=overip& newip
dsafasf=split(newip,".")
if ubound(dsafasf)=3 then
writelog "netsh ipsec static add filter filterlist=denyip srCADdr="& newip& " dstaddr=Me
dstport=80 PRotocol=TCP"
end if
else
wscript.echo newip & " is exits!"
end if
next
writelog "netsh ipsec static add filteraction name=denyact action=block"
writelog "netsh ipsec static add rule name=kill3389 policy=XBLUE filterlist=denyip
filteraction=denyact"
writelog "netsh ipsec static set policy name=XBLUE assign=y"
Sub writelog(errmes) '导出IPsec的策略文件为一个bat文件。
ipfilename="denyerrorip.bat"
Set logfile=fileobj.opentextfile(ipfilename,8,true)
logfile.writeline errmes
logfile.close
Set logfile=nothing
End Sub
'代码结束
把上述代码存为一个.vbs文件,设置好其中日志的路径。双击运行即可,运行完毕后生成一个denyerrorip.bat文件,这个是ipsec所需要的策略文件,直接双击运行即可。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 用vbscript来添加ip策略 自动封IP
本文地址: https://pptw.com/jishu/609790.html
