<>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P>( G( z: }* u5 G& D
<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。 / K" b& }. i' x; J3 h: F N# V+ R+ z; A9 L. T( Q$ G* ~vbs脚本版: 1 f* K# b! l, `: |; T6 BCodz: y4 x8 \9 j$ Y7 v$ j$ B+ w# p9 O
[, C' h# \ |; ^
with new regexp ! Q$ c. w. a# m+ Z9 S
.pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)" 3 r# e7 r, N$ C9 h6 A5 {. S .global=true 5 a# w% m' y# {" v- o; @
set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall) / ^3 x8 @3 b0 g4 u8 m) N
end with t1 j( I6 {, Q$ C4 N3 q
for each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ 5 V9 h. T# _) x4 }5 E/ d f=0 & J( [, S, M. {% q8 ^; i1 y+ o e* d
for each m in ms " S. r! R) x9 o5 G$ F9 T if m.submatches(1)=ps.handle then ( k$ Y& |/ X- w/ ]9 e if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath * J* s/ a: k# Z! J) r6 O7 e8 F wscript.echo " "&m.submatches(0) 8 [9 ^. ^4 t- B. r5 h end if & d7 g4 n& Z( ~5 q% S9 v: e M next 5 Z) P' c" R- ?% s% S; Nnext' w$ G+ J& O& Z1 x. L
; u1 n# _# I5 M+ n1 F5 q3 {
, D* N- @: u+ X% Z! d0 F照例给出echo版,方便在远程shell中使用。7 r, p0 h- |, F& l5 U; {) T
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs5 P! Q/ _3 T* E2 |" V9 ~
@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs8 A% t" H3 B) O, U4 Q
@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs7 A8 @0 G5 s3 q/ l8 G* F# ~8 P+ p
@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs7 y# y; B- `2 j# c& ^3 z3 C! d
@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs( k& D- ?+ k8 {
@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs ; u: Y5 e* C! B7 J$ A) U@cscript //nologo fp.vbs&del fp.vbs</P>