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
  • 相关阅读:
    Python多版本共存
    Windows下安装glumy过程
    安卓手机刷机
    动态规划学习
    Linux下载源
    背包问题扩展
    mongol学习
    云爬虫测试
    arc的安装
    Centos
  • 原文地址:https://www.cnblogs.com/luoluo/p/301947.html
Copyright © 2011-2022 走看看