标题: fport.vbs for XP/2003 [打印本页] 作者: 韩冰 时间: 2004-11-5 22:57 标题: fport.vbs for XP/2003 <>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P> 1 y$ H3 t4 U8 \<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。 d8 t4 v* p1 x& o1 c7 ?2 e9 I" t% p' u) V* J
vbs脚本版:+ g9 c' H: g# _* a! G
Codz: . _" l( ]" Q8 u" I5 Y O3 G& t L! ]8 ]9 J( B/ U8 q7 T
with new regexp 6 N+ l" S) W9 P
.pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)" 3 o" A$ L* s5 B. n2 ^2 Q .global=true ( M) n2 ^9 T" w
set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall) 3 ]5 E! E7 Y, Y( ]
end with ) K4 T2 P3 }! i$ P+ h( G" v' t1 h
for each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ 9 O% z1 l" k2 b' f f=0 9 q; k0 a( y, \) v for each m in ms , q0 [& o+ Z9 Q* M0 f8 h; l. R if m.submatches(1)=ps.handle then & `& Y3 |1 e" T* P if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath 6 d9 T" ~" T' L
wscript.echo " "&m.submatches(0) 5 D5 ~' g: {8 D0 u& Y3 ?
end if & O" j* M: O0 l5 k9 u: @" a# e
next 6 k0 B3 U7 H7 G. K4 gnext8 U1 k! T: \1 s0 q+ i
$ A0 T. x% p/ L9 L7 K / j8 z* ~+ ?/ Y* V' T照例给出echo版,方便在远程shell中使用。 1 R! f& D( n ?@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs ' b7 f. N( a. c2 E) ^6 F g, {@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs$ f _4 p7 v! A* P: e
@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs 5 G5 t2 |: D5 X1 z@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs / m* ]; v& ]" o" O0 x@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs 0 I$ n# q' b ]@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs 4 R+ p9 W, n9 U@cscript //nologo fp.vbs&del fp.vbs</P>作者: kensington 时间: 2010-2-3 23:20
排版好乱作者: sxjm567 时间: 2012-7-15 22:19
众里寻他千百度,蓦然回首在这里!