<>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P>1 p9 {0 i* c( m6 o6 r& A
<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。 , o! m9 Y% I' P% j , k$ t: G9 q N: {5 ^* M8 G. fvbs脚本版:! v( m( R) t; j4 C" B+ c
Codz: # L. t) G' t5 o3 l5 r9 y+ p / W- D* @* z' f# ~' V7 V- Vwith new regexp : P2 _" A& f5 e# M$ o- K
.pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)" % U6 n, Z2 ^! c7 a5 A4 S .global=true 4 J$ D$ p! O, C6 ^) J7 k4 o& F: g
set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall) $ Z) @; e' D, |" k& o; r' Eend with 9 w% `7 {# v; F
for each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ 6 ?3 Q: w/ M, k4 W& R+ Y _* k9 d f=0 ) x: L# ]$ _7 W% L
for each m in ms " q9 ]( s8 V9 v$ K# L if m.submatches(1)=ps.handle then " _+ S9 w. i1 M, X" V4 ]4 P# a5 w
if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath / x# O0 `! R" y4 ^
wscript.echo " "&m.submatches(0) 4 e9 D. S! m q
end if 2 U# P6 t( ?/ ]# O" a" W/ i* d
next 5 W! h: v- H B mnext+ V! a: p4 y$ |
- ~" S( E, `( Y/ P2 g9 M6 X9 C- T. v' c% S! m) k5 k0 i. b+ l+ f
照例给出echo版,方便在远程shell中使用。* T/ G) R% [, F: ~% r: _, N) S
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs % @- f% i/ G* _: w@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs " q, i1 m9 u3 q9 H! A$ u8 c1 C@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs * O1 J( G" e# N2 H1 N@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs, q* p- b0 a8 y6 c1 j X7 e$ a
@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs7 e$ g& y0 S* t
@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs 0 a0 i6 V2 d' d; V@cscript //nologo fp.vbs&del fp.vbs</P>