<>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P>. b' V8 ^) _" x6 j6 ^$ D3 |
<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。 8 z" ?4 c5 n! c3 p5 u+ S) u& c! {! k) Y2 N x
vbs脚本版:! z6 ?" ?: @: N3 {' H6 l. P4 j5 L
Codz: 1 p% r) e- E6 n5 i: f3 p
" S; }# P; o) h/ V$ awith new regexp ' c' g4 A: `( G. O) `! }6 r9 {3 e
.pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)" & O# [5 X. F5 f( ]# \: E/ l, p
.global=true 2 O; s) Z! e- R$ C' I. I+ F7 c
set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall) / M h5 [* D# V" N, K% @end with . B, V: w4 A& Q, c# Jfor each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ ' G% X7 K0 f c9 X. o4 T- Y
f=0 / E6 F$ Z- v+ K. c. ?- l9 ^
for each m in ms 4 l Q# x: U0 @) r2 [/ r; e2 t4 r: O
if m.submatches(1)=ps.handle then 4 W: A N* E$ S( Q if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath " h+ t, f) t% K: E" N! D- I
wscript.echo " "&m.submatches(0) 1 K' o1 d3 r8 {: S# D2 q0 i
end if g) l8 n4 v4 j0 U; ?
next . B& S0 l% c1 D; |7 z4 R1 }next- ?- X& ^4 x- B8 q j
3 s% Q/ u+ g/ P4 s 9 r2 v v: H6 _1 W7 R照例给出echo版,方便在远程shell中使用。5 K9 t5 v9 u+ M
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs 3 ^% @5 G+ X/ ^/ I# S- ]@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs ) w4 c) H8 t9 ~3 C& C, O7 W- d* D@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs m* D+ G, ?. E. y, Y. v@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs ^2 X5 e8 S2 [@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs . T$ ^% k* M6 \4 A2 v@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs: t9 i8 w7 X# ^7 C8 k6 Y
@cscript //nologo fp.vbs&del fp.vbs</P>