zoukankan      html  css  js  c++  java
  • 列出所有到本机80端口ESTABLISHED连接的小脚本

    朋友需要,我搞了个脚本出来玩,直接运行netstat -an取得输出用正则匹配。

    Dim oShell
    Dim oExec
    Dim strOut
    Dim oRegExp
    Dim Matches
    Dim Match
    Dim Num

    Set oShell = WScript.CreateObject("WScript.Shell")
    Set oExec = oShell.Exec("netstat -an")
    Set oRegExp = new RegExp
    oRegExp.Pattern 
    = "TCP[\s]+[\d\.]+:80[\s]+[\d\.]+:[\d]+[\s]+ESTABLISHED"
    oRegExp.IgnoreCase 
    = True
    oRegExp.Global 
    = True

    Do While Not oExec.StdOut.AtEndOfStream
        strOut 
    = strOut & oExec.StdOut.ReadLine() & Chr(13& Chr(10)
    Loop

    Set Matches = oRegExp.Execute(strOut)

    Num 
    = 0
    For Each Match In Matches
        WScript.Echo Match.Value
        Num 
    = Num + 1
    Next

    WScript.Echo 
    "合计:共" & Num & "个连接"

    Set Matches = Nothing
    Set oRegExp = Nothing
    Set oExec = Nothing
    Set oShell = Nothing
  • 相关阅读:
    关于codeblocks插件(持续更新)
    自定义gvim配色方案qiucz.vim的源码
    mark it
    poj 1032
    poj 1028
    最小公倍数是lcm
    problems
    hdu 1067
    某些题的做法。。。
    突然明白了什么
  • 原文地址:https://www.cnblogs.com/luoluo/p/301947.html
Copyright © 2011-2022 走看看