标题: fport.vbs for XP/2003 [打印本页] 作者: 韩冰 时间: 2004-11-5 22:57 标题: fport.vbs for XP/2003 <>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P>- R, u% S, _) V" T! W% F% v
<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。/ ]; D7 B1 x' o! u/ G3 j0 ~) f+ o
7 W9 b) w& b: h7 }3 Y. ^* zvbs脚本版: w! Z$ r6 r, m) ~Codz: " C3 U% E* [* i5 }. O # U8 x* v9 r& q4 Jwith new regexp 4 L0 r; }% q: ~: f# Z9 ^ .pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)" + C! |) V- P6 E$ l/ ~
.global=true 0 a6 j" f, A* P6 k o! ? [
set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall) ; o0 w' Q2 B; {3 W+ i& j, C
end with 9 o7 B' A) e J1 r: h0 a& K9 mfor each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ H& A& u& S$ q [) R4 X f=0 ' l x( N- W# }- T( E
for each m in ms # C! B, G8 F! v8 ^2 ~" p B
if m.submatches(1)=ps.handle then / {9 U5 S1 e6 d( {# U$ n6 s d5 m
if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath * G! x* O! x: p7 A
wscript.echo " "&m.submatches(0) ) E8 h6 v& g) ?, j/ Z end if g0 o: E h+ H+ u
next ' {; [3 V- p; U. S" s4 t
next9 D5 M: b2 z. C- F& _; S
$ ?" c' ?0 S) { $ ?1 ~& Z; E2 \/ K& Z- m照例给出echo版,方便在远程shell中使用。8 s: `1 \. P0 s4 }. p8 y% }
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs+ y/ e0 Z$ m9 U+ w# L( N1 l8 p, Z6 W
@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs 6 d& C7 r5 [' z3 y; M@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs " G. U' ?5 V" ?5 H- ~- ]@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs0 r) O9 ^. z, A/ K. w5 F, U
@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs % Q( i! Y$ \2 d3 ?& ^: Z@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs , z3 A" s! d# g* u) v! F@cscript //nologo fp.vbs&del fp.vbs</P>作者: kensington 时间: 2010-2-3 23:20
排版好乱作者: sxjm567 时间: 2012-7-15 22:19
众里寻他千百度,蓦然回首在这里!