数学建模社区-数学中国

标题: fport.vbs for XP/2003 [打印本页]

作者: 韩冰    时间: 2004-11-5 22:57
标题: fport.vbs for XP/2003
<>作者:zzzevazzz   来自:http://www.ph4nt0m.org</P>- F  K! I9 ~3 E9 t: Q, v. @
<>XP和2003下的netstat有-o选项,所以可以容易地实现fport。
( A* z% L0 G0 u; c8 u+ A* H1 u; I' H- x6 i9 e$ g
vbs脚本版:
* n5 D/ q1 k( n9 q: w& w9 ZCodz:   J' K: ?: p" l  [5 [$ D5 z
. }8 o2 q8 X9 t9 D4 W7 p5 g
with new regexp $ ?8 \. Q( t0 R
    .pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)"   w& S# }' |; R3 Y% d; i, X
    .global=true + o6 d' p7 T& J- }+ g8 g
    set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)
, S$ Q% k' i5 s' N! F0 Wend with
- n) M5 ~/ c9 U1 Kfor each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_ * L/ V3 u6 C* {  @. a& K9 l
    f=0
0 E8 h. ~! q2 ^! K: f    for each m in ms
  N" n; l- ~. ?! Q; T0 n        if m.submatches(1)=ps.handle then
% {( D5 H. T: Y2 D            if f=0 then f=1:wscript.echo "&gt;"&amp;ps.handle&amp;vbtab&amp;ps.name&amp;vbtab&amp;ps.executablepath
) n7 q! e( X3 r- O' ~            wscript.echo " "&amp;m.submatches(0)
3 v) D+ I1 t* H/ H- g5 w        end if
* y3 K) D/ m' A7 P6 c  ^    next
* f3 z2 Z4 R% W: ~6 A' u: q5 o( X0 Tnext( U0 ^% ^& @. T* D) d& w

% \* j( f. j+ Y3 e! ^: H& P2 M3 g! p. o$ K+ H
照例给出echo版,方便在远程shell中使用。  ~1 t- }& r  W; n; m
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true&gt;fp.vbs
! ]6 A! O- e6 Y, L@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)&gt;&gt;fp.vbs, X; v' }' H2 \0 a. K
@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_&gt;&gt;fp.vbs
" N7 l* z- C/ Z@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _&gt;&gt;fp.vbs
4 q8 |" ^: X4 Y6 E( U, `2 O. [, ^@echo if f=0 then f=1:wscript.echo "&gt;"^&amp;ps.handle^&amp;vbtab^&amp;ps.name^&amp;vbtab^&amp;ps.executablepath:end if:_&gt;&gt;fp.vbs% \/ A3 |) M* B  X3 |) W1 O
@echo wscript.echo " "^&amp;m.submatches(0):end if:next:next&gt;&gt;fp.vbs
* b# z. U6 t$ w, T/ }  `4 x@cscript //nologo fp.vbs&amp;del fp.vbs</P>
作者: kensington    时间: 2010-2-3 23:20
排版好乱
作者: sxjm567    时间: 2012-7-15 22:19
众里寻他千百度,蓦然回首在这里!




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5