VBS统计网络流量

标签: , , , , ,

VBS统计网络流量,如果你是包流量无线网卡,那这个脚本非常有用。

' *==============================================================================*
' * 网络流量统计.vbs         By: FastSLZ 2009-1-28    首次发布与 bbs.bathome.cn  *
' *==============================================================================*
'特别提醒:本脚本必须在Administrator账户,且必须通过杀毒软件授权下才能正常运行!
Dim WH
Set WH = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQuery("Select * from Win32_DesktopMonitor")
For Each aWH in WH
     TW = Int(aWH.ScreenWidth/8)
Next
Set WH = Nothing
If TW <= 0 Then :TW =128 :End If
If (Lcase(Right(Wscript.FullName,11)) = "wscript.exe") Then
   CreateObject("WScript.Shell").Run("%Comspec% /C " &Chr(34)&"mode con cols="& TW &"&Title 网络流量统计    By: FastSLZ                          bbs.bathome.cn     &&Cscript.exe //NoLogo  "&Chr(34)& Wscript.ScriptFullName &Chr(34)&Chr(34)),3:Wscript.Quit
End If
MsgBox "本脚本用于检测BT等下载工具后台偷偷上传、下载,及检测是否存在潜伏在系统里的后门程序"
Showy=vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
Input=InputBox(Showy &"请输入刷新间隔时间(单位秒)"& vbCrLf &"间隔时间越长统计数据越精确", "BY: fastslz","2")
Input=Int(Input)
If Len(Input) = 0 Then:Input = 1:End If
If Len(Input) >= 2 Then:WScript.Quit:End If
InputS = Input*1000
Dim WMI,Name
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set colItems = WMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled='TRUE'")
For Each objItem In colItems
    Name =  Replace(objItem.Description,"/","_")
Next
Set colItems = Nothing
WScript.Echo "活动连接:"&Name
If (IsArray(Name)) = TRUE Then:MsgBox vbTab& "貌似无任何网络" :WScript.Quit:End If
Call Network(Name)
Function Network(Names)
Do
Dim A
Set A = WMI.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface Where Name = '"& Name &"'")
For Each B In A
    R1 = B.BytesReceivedPersec
    S1 = B.BytesSentPersec
    T1 = B.BytesTotalPersec
    If T0 ="" Then :T0 = B.BytesTotalPersec :End If
Next
Set A = Nothing
WScript.Sleep(InputS)
Set A = WMI.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface Where Name = '"& Name &"'")
For Each B In A
    R2 = B.BytesReceivedPersec
    S2 = B.BytesSentPersec
    T2 = B.BytesTotalPersec
Next
Set A = Nothing
WScript.Echo "下载:" & CheckSize((R2-R1)/Input) &"/s" _
      &vbTab&"上传:" & CheckSize((S2-S1)/Input) &"/s" _
      &vbTab&"平均:" & CheckSize((T2-T1)/Input) &"/s" _
      &vbTab&"小计:" & CheckSize(T1-T0) _
      &vbTab&"累计:" & CheckSize(T1)
Loop
End Function

Function CheckSize(SZ)
On Error Resume Next
If SZ => 1073741824 Then
   SZ = FormatNumber(SZ/1073741824) & " GB"
   ElseIf SZ => 1048576 Then
   SZ = FormatNumber(SZ/1048576) & " MB"
   ElseIf SZ => 1024 Then
   SZ = FormatNumber(SZ/1024) & " KB"
Else
   SZ = SZ & " 字节"
End If
CheckSize=Right("      " & SZ,10)
End Function

原文链接:http://bbs.bathome.net/viewthread.php?tid=3198

随机文章:

  1. 为HG255D编译OpenWrt Barrier Breaker固件
  2. 用VBS设置静态IP和DNS服务器地址
  3. 伪造电子邮件发送时间
  4. 用Python脚本查询纯真IP库QQWry.dat(Demon修改版)
  5. 一个VBS恶作剧程序

留下回复