我很少来这里发帖子,今天就来发个小东西,有兴趣的就玩玩!~
@echo off
setlocal EnableDelayedExpansion
date/t >> c:\windows\3389log.txt
set lflag=nolog
set rip=0.0.0.0
:TS3389
ping -n 10 -w 500 0.0.0.1>nul
for /f "tokens=4 delims=: " %%a in ('netstat -an ^| find "3389" ^|find "ESTABLISHED"') do set lrip=%%a
if "%lrip%" == "!rip!" goto :TS3389
netstat -an | find "3389" |find "ESTABLISHED"&&set lflag=log
if "%lflag%" == "log" (
for /f "tokens=4 delims=: " %%a in ('netstat -an ^| find "3389" ^|find "ESTABLISHED"') do set rip=%%a
set lflag=nolog
time/t >> c:\windows\3389log.txt
netstat -an | find "3389" |find "ESTABLISHED">> c:\windows\3389log.txt
)
goto :TS3389
默认保存日志到c:\windows\3389log.txt,监控端口是3389,有兴趣大家根据实际情况自己改下!
|
|