华域联盟 vbs 用vbscript来添加ip策略 自动封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所需要的策略文件,直接双击运行即可。

本文由 华域联盟 原创撰写:华域联盟 » 用vbscript来添加ip策略 自动封IP

转载请保留出处和原文链接:https://www.cnhackhy.com/15744.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部