用vbscript来添加ip策略 自动封IP!
来源:互联网 发布:国泰安股票收益率数据 编辑:程序博客网 时间:2024/05/21 07:02
看过有网友介绍的方法,不过是手工一条一条地封,而攻击IP一般都是数千个不同的IP。用手工封IP的办法太麻烦。下面我们用程序来实现自动封这些IP!
代码如下:
'代码开始
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所需要的策略文件,直接双击运行即可。
代码如下:
'代码开始
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!
- CentOS用iptables自动封IP脚本
- 使用 fail2ban 自动封IP
- 封ip
- 用VBScript修改本机IP地址
- 4.25工作日记 --密码猜测三次 自动封IP
- 使用iptables自动封IP的Shell脚本
- GoogleMap 封IP
- 使用iptables封ip
- IP地址合法性检测 VBScript
- linux上用iptables自动封ip的bash脚本,被CC攻击可以试试这个SHELL
- LINUS IPtables 封IP段
- 爬虫过程中关于IP被封与反扒的策略
- iptables的用法,用iptables封IP的方法
- 记录远程桌面IP策略
- 爬虫 IP代理策略
- VBScript获取电脑用户名-IP-MAC
- vbscript根据ip查询纯真数据库地址
- Josephu问题 单向链表
- The Tomcat server configuration at ServersTomcat v5.5 Server at localhost-config is missing. Check
- CMDB选型
- 一些SWING用法记录
- 一直迷糊的Div+css总结
- 用vbscript来添加ip策略 自动封IP!
- 用变换的思维写程序
- 构造函数
- 我的简历
- 模板用于解耦
- 一句话asp木马加密版 彻底突破杀毒软件
- 关于数组的&a[0]和&a及指针访问的问题
- centos 6.0 I like it~
- 将MYSQL读写权限转化为system权限