文章分类 | 软件分类 | 最新软件 | 杀毒软件 | 实用软件  | MTV下载  | 设为首页 |
  | 下载分类 | 最近更新
您的位置: 首页 >> 文章首页 >> 网络冲浪 >> 服务器 >>  
服务器点击TOP10
·Microsoft IIS6.0实现WAP应用2006-2-5 15:34:58
·如何利用qmail防止垃圾邮件2006-2-5 12:49:44
·四十九、从DOS工作站登录NTS4.0服务器2006-2-6 8:44:55
·做个自己的MSN聊天机器人2006-2-5 17:12:47
·BitTorrent服务器架设指南2006-2-5 13:42:34
·维护服务器安全的基本方法2006-2-5 12:51:06
·UNIX系统操作入门2006-2-5 15:20:06
·ISA SERVER使用指南2006-2-5 12:32:46
·图解打造多种流媒体服务器2006-2-9 18:52:41
·创建自己的私服新人必学2006-2-5 12:39:39
网络冲浪点击TOP10
·去除IE地址栏中的网址2006-2-5 12:45:08
·入侵检测系统之LIDS篇2006-2-5 10:58:21
·IP网络路由技术2006-2-9 19:14:24
·让“TE”变“IE”的移花接木大法2006-2-5 19:26:30
·巧改设置强化3389入侵2006-2-6 9:00:42
·我的常州装饰网如何建立的2006-2-5 13:35:30
·用Ipconfig获取最新的网络配置2006-2-6 10:14:20
·海阳asp木马的漏洞2006-2-5 13:51:57
·[常用]另类可执行文件压缩软件PECompact2006-2-6 7:50:02
·很酷的一篇入侵分析2006-2-5 12:35:56

 

巧用批处理实现windows xp/windows2003进程和端口关联
作者:我去下载           时间:2006-2-9 20:05:33


闲来无事的时候随手写了个,把它放在%SYSTEM%目录下,可省不少心-_-

@REM =====================
@REM = Write phanrider =
@REM = 2005.1.12 =
@REM =====================
@ECHO OFF
set zhl_file=task_1$.txt
set zhl_temp_file=Temp1$.zhl
set zhl_file2=task_2$.txt
set zhl_temp_file2=Temp2$.zhl
set temp_1=lmj_zhl$.txt
set temp_2=lmj_zhl2$.txt
set zhl_1=%1
set zhl_2=2

:BEGIN
if "%zhl_1%"=="" goto :HELP
if %zhl_1%==0 @echo 端口号不能为零!&& goto :END

if exist %zhl_file% erase %zhl_file%
if exist %zhl_temp_file% erase %zhl_temp_file%
echo 正在处理网络端口...
netstat -ano find ":" >%zhl_file% 2>nul
for /f "eol=U tokens=1,2,3,4,5*" %%a in (%zhl_file%) do @echo %%a %%b$ %%c %%d #""%%e""# >> %zhl_temp_file% 2>nul
for /f "eol=T tokens=1,2,3,4*" %%a in (%zhl_file%) do @echo %%a %%b %%c * #""%%d""# >> %zhl_temp_file% 2>nul
if exist %zhl_file2% erase %zhl_file2%
if exist %zhl_temp_file2% erase %zhl_temp_file2%
echo 正在读取进程映像......
tasklist /FO CSV >%zhl_file2% 2>nul
echo 正在初始化映像和端口......
for /f "skip=2 tokens=1,2,3,4,5* delims=," %%a in (%zhl_file2%) do @echo %%a,#%%b#,%%c,%%d,%%e >> %zhl_temp_file2% 2>nul
echo 正在查找进程和端口对应关系......
if exist %temp_1% erase %temp_1%
type %zhl_temp_file% find ":%zhl_1%$" >> %temp_1% 2>nul
for /f "tokens=4,5*" %%x in (%temp_1%) do @set zhl_2=%%y
if "%zhl_2%"=="2" echo 没有任何进程使用%zhl_1%端口 && goto :END
type %zhl_temp_file2% find "%zhl_2%" >> %temp_2% 2>nul
for /f "tokens=1,2* delims=," %%f in (%temp_2%) do @set zhl_3=%%f
echo 发现进程%zhl_3%使用%zhl_1%端口

rem if exist Temp1.zhl erase Temp1.zhl
rem for /f "tokens=2,3*" %%i in (1.txt) do @echo %%j* >> Temp1.zhl
rem if exist Temp2.zhl erase Temp2.zhl
rem for /f "tokens=1,2* delims=:" %%j in (Temp1.zhl) do @echo %%k >> Temp2.zhl
REM echo %zhl_1%
REM type Temp1.zhl find "%zhl_1%*" /N
goto :end
:HELP
echo WINXP/WIN2003查看指定端口是哪个进程使用
echo.
echo USE: %0 port
:END
REM ====================================
REM 最后的清扫工作
REM ====================================
erase %zhl_file% 1>nul 2>&1
erase %zhl_file2% 1>nul 2>&1
erase %zhl_temp_file% 1>nul 2>&1
erase %zhl_temp_file2% 1>nul 2>&1
erase %temp_1% 1>nul 2>&1
erase %temp_2% 1>nul 2>&1
set zhl_file=
set zhl_temp_file=
set zhl_file2=
set zhl_temp_file2=
set temp_1=
set zhl_1=
set zhl_2=
分页:
相关文章:
Copyright© 2005-2006 wqxz.com, All Rights Reserved. 购买虚拟主机请与本站联系