数学建模社区-数学中国
标题:
fport.vbs for XP/2003
[打印本页]
作者:
韩冰
时间:
2004-11-5 22:57
标题:
fport.vbs for XP/2003
<
>作者:zzzevazzz 来自:http://www.ph4nt0m.org</P>
! W! g ? V1 D: x& t8 c* R8 F2 R
<
>XP和2003下的netstat有-o选项,所以可以容易地实现fport。
! t3 H2 ~* s8 @# M3 j- o
/ @% q% i+ x3 i/ j. X
vbs脚本版:
$ v6 h. |! W- K: O; g
Codz:
- v, j3 |5 p+ Z! e5 m/ R8 m0 a& ]
# G" B; u' k: P. f2 ]; y! B
with new regexp
# I' |0 M& I( V' E" M6 B2 l$ @
.pattern="(..Ps+S+s+S+s+[A-Z]*)s*([0-9]+)"
0 L; L- l! E2 p& |2 o
.global=true
& G* T# k6 ]0 w/ u9 h2 J
set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)
9 n2 I# `+ {# t( \- w/ a% L
end with
, j7 P6 S6 M( e- I$ X
for each ps in getobject("winmgmts:\.\rootcimv2:win32_process").instances_
* Z- h W9 P' P
f=0
" I6 r5 }! ?8 a9 U; }5 X% H
for each m in ms
; e- s" o* g# i+ r
if m.submatches(1)=ps.handle then
- \3 Z* E( A( P; s5 X1 G3 A( B
if f=0 then f=1:wscript.echo ">"&ps.handle&vbtab&ps.name&vbtab&ps.executablepath
4 G |& V) U7 x2 Q' U8 h
wscript.echo " "&m.submatches(0)
9 l$ P+ ^0 [- l( q+ @
end if
" `0 f$ ^8 e5 {$ k6 l- ]2 p2 g* M
next
A( B1 W3 X: ]
next
4 Y. v. W) E" e- e- g0 S
/ N0 u- a* b9 z0 a( `# q/ ~
+ }9 O+ Q4 I! a( {
照例给出echo版,方便在远程shell中使用。
0 ? M( K' ?9 {
@echo with new regexp:.pattern="(..P\s+\S+\s+\S+\s+[A-Z]*)\s*([0-9]+)":.global=true>fp.vbs
- l6 m4 R/ w, i9 C
@echo set ms=.execute(createobject("wscript.shell").exec("netstat -ano").stdout.readall)>>fp.vbs
) L' _$ l3 s& O! P
@echo end with:for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_>>fp.vbs
2 j3 ?6 w7 g8 x% n
@echo f=0:for each m in ms:if m.submatches(1)=ps.handle then _>>fp.vbs
1 l# d7 k# ~! H$ b0 ^
@echo if f=0 then f=1:wscript.echo ">"^&ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:end if:_>>fp.vbs
0 C4 k4 \. N# l# O# A* }
@echo wscript.echo " "^&m.submatches(0):end if:next:next>>fp.vbs
4 y/ Y+ `0 H2 S; B3 n
@cscript //nologo fp.vbs&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