欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用vbscript來(lái)添加ip策略 自動(dòng)封IP

 更新時(shí)間:2009年08月02日 11:30:19   作者:  
看過(guò)有網(wǎng)友介紹的方法,不過(guò)是手工一條一條地封,而攻擊IP一般都是數(shù)千個(gè)不同的IP。用手工封IP的辦法太麻煩。下面我們用程序來(lái)實(shí)現(xiàn)自動(dòng)封這些IP!
程序主要是讀取這個(gè)網(wǎng)站的iis日志,分析出其中的IP地址,用安全策略自動(dòng)封閉。VBS代碼如下:
復(fù)制代碼 代碼如下:

  '代碼開始

  Set fileobj=CreateObject("Scripting.filesystemobject")
  logfilepath="E:w3logW3SVC237ex070512old.log" '注意指定受攻擊網(wǎng)站的日志路徑。
  '如果是虛擬主機(jī),要查是哪個(gè)網(wǎng)站受攻擊,可以查看:C:WINDOWSsystem32LogFilesHTTPERR ,

  根據(jù)錯(cuò)誤日志很容易分析出來(lái)。
  writelog "netsh ipsec static add policy name=XBLUE"
  writelog "netsh ipsec static add filterlist name=denyip"

  overip=""
  f_name=logfilepath
  '指定日志文件

  '程序功能:把logfiles中的IP提取成ipsec需要的過(guò)濾格式,導(dǎo)入ipsec中過(guò)濾。適合某個(gè)網(wǎng)站受大量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)
  '指定分離的標(biāo)識(shí)字符串!
  if instr(overip,newip)=0 then '去除重復(fù)的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) '導(dǎo)出IPsec的策略文件為一個(gè)bat文件。
  ipfilename="denyerrorip.bat"
  Set logfile=fileobj.opentextfile(ipfilename,8,true)
  logfile.writeline errmes
  logfile.close
  Set logfile=nothing
  End Sub

  '代碼結(jié)束

  把上述代碼存為一個(gè).vbs文件,設(shè)置好其中日志的路徑。雙擊運(yùn)行即可,運(yùn)行完畢后生成一個(gè)denyerrorip.bat文件,這個(gè)是ipsec所需要的策略文件,直接雙擊運(yùn)行即可。

相關(guān)文章

最新評(píng)論