标题: fport.vbs for XP/2003 [打印本页] 作者: 韩冰 时间: 2004-11-5 22:57 标题: fport.vbs for XP/2003 <>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P>& D# m) S! l7 C" S( Z* U
<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。) d) a: a) H9 P$ u# ?- e+ ^
" f+ s$ \: L# ^0 ovbs脚本版:& R9 p" c7 A" S
Codz: ! L, w U: \, b2 L7 u# b/ ^ ) I) C+ ^ C: iwith new regexp : j0 P; V+ ?( S .pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)" , e9 S) f; v6 y# y" i
.global=true ! L+ l6 ]7 ]( S6 f. Y set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall) 1 T. a: G. ^* k; b+ c
end with # L) T- R% Y W5 r
for each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ % }) M" _4 w4 d5 ^! i4 o f=0 , d: E! |+ \* O for each m in ms " i' G5 B1 [* t8 u, y
if m.submatches(1)=ps.handle then 5 l. L( Z. I! ~4 p; u$ K
if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath - B) x9 z4 k/ H9 Y wscript.echo " "&m.submatches(0) 0 q, O5 X* H8 A1 H* p end if & k0 r$ H+ D- ?: G8 j
next % c1 v2 r3 {* k. Enext8 N7 h- G! y1 { F9 e! Y. h
' j* e$ S$ N0 E% [& G9 _3 H% ~6 @" O# C
照例给出echo版,方便在远程shell中使用。' i! B4 f G3 e8 N4 J' C- Z, D
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs + O4 C9 F9 G9 {& W3 ^0 W ~ k* k@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs + k' o; L: T" {% S% Q7 F. s@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs 9 a5 s# L. O* m+ J5 e) z@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs0 I* J7 @4 W+ m! d# p
@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs 2 d. K2 O6 n. I' |8 V@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs2 C! A) ], H( _1 b. Y
@cscript //nologo fp.vbs&del fp.vbs</P>作者: kensington 时间: 2010-2-3 23:20
排版好乱作者: sxjm567 时间: 2012-7-15 22:19
众里寻他千百度,蓦然回首在这里!