网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 用vbscript来添加ip策略 自动封IP
内容
    看过有网友介绍的方法,不过是手工一条一条地封,而攻击IP一般都是数千个不同的IP。用手工封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所需要的策略文件,直接双击运行即可。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/13 8:08:54