韩冰 发表于 2004-11-5 22:57

fport.vbs for XP/2003

<P>作者:zzzevazzz   来自:http://www.ph4nt0m.org</P>
<P>XP和2003下的netstat有-o选项,所以可以容易地实现fport。

vbs脚本版:
Codz:

with new regexp
    .pattern="(..Ps+S+s+S+s+*)s*(+)"
    .global=true
    set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)
end with
for each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_
    f=0
    for each m in ms
        if m.submatches(1)=ps.handle then
            if f=0 then f=1:wscript.echo "&gt;"&amp;ps.handle&amp;vbtab&amp;ps.name&amp;vbtab&amp;ps.executablepath
            wscript.echo " "&amp;m.submatches(0)
        end if
    next
next


照例给出echo版,方便在远程shell中使用。
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+*)\s*(+)":.global=true&gt;fp.vbs
@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)&gt;&gt;fp.vbs
@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_&gt;&gt;fp.vbs
@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _&gt;&gt;fp.vbs
@echo if f=0 then f=1:wscript.echo "&gt;"^&amp;ps.handle^&amp;vbtab^&amp;ps.name^&amp;vbtab^&amp;ps.executablepath:end if:_&gt;&gt;fp.vbs
@echo wscript.echo " "^&amp;m.submatches(0):end if:next:next&gt;&gt;fp.vbs
@cscript //nologo fp.vbs&amp;del fp.vbs</P>

kensington 发表于 2010-2-3 23:20

排版好乱

sxjm567 发表于 2012-7-15 22:19

众里寻他千百度,蓦然回首在这里!
页: [1]
查看完整版本: fport.vbs for XP/2003