jackadmi 2009-08-02
代码如下:
'代码开始 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 '代码结束