通过cmd脚本记录Windows远程桌面用户登录日志

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@ echo  off
 
if  "%1"  ==  "h"  goto begin 
  mshta vbscript:createobject( "wscript.shell" ).run( "%~nx0 h" ,0)(window.close)&& exit 
:begin 
 
set  port=3389
set  checkInterval=2
 
set  prev= ""
 
:loop
 
set  curr=
 
for  /f  "delims="  %%i  in  ( 'netstat -n -p tcp ^|find ^":%port%^"' do  ( set  curr=%%i)
 
if  not  "%curr%" == "%prev%"  (
 
    set  prev=%curr%
 
    date  /t  >>RDPlog.txt
 
    time  /t  >>RDPlog.txt
 
    echo  %curr% >>RDPlog.txt 
 
ping  -n %checkInterval% 127.1>nul 
 
goto :loop

远程桌面服务端口(port)为3389;

目前轮询频率(checkInterval)设置为2秒;

脚本运行后在后台,看不到Console窗口,当检测服务端口连接状态有变化时,会把时间和对方IP记录到RDPlog.txt中。

脚本设置为开机自启动就行了。

本文转自   zl1030   51CTO博客,原文链接:http://blog.51cto.com/zl1030/1925247

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
3天前
|
安全 数据安全/隐私保护 Windows
Windows 允许空密码远程桌面
Windows 允许空密码远程桌面
11 2
|
12天前
|
Oracle 关系型数据库 数据库
[windows]远程桌面失败提示CredSSP加密修正
[windows]远程桌面失败提示CredSSP加密修正
100 5
|
5天前
|
Java Windows Spring
Spring Boot CMD 运行日志输出中文乱码
Spring Boot CMD 运行日志输出中文乱码
6 0
|
1月前
|
安全 Windows
Microsoft Windows远程桌面服务远程执行代码漏洞(CVE-2019-0708)
Microsoft Windows远程桌面服务远程执行代码漏洞(CVE-2019-0708)
34 2
|
20天前
|
弹性计算 缓存 网络安全
云服务器 ECS产品使用问题之远程桌面无法连接到Windows实例,该如何排查
云服务器ECS(Elastic Compute Service)是各大云服务商阿里云提供的一种基础云计算服务,它允许用户租用云端计算资源来部署和运行各种应用程序。以下是一个关于如何使用ECS产品的综合指南。
|
1月前
|
网络安全 数据安全/隐私保护 Windows
Windows自带的远程桌面连接教程
Windows自带的远程桌面连接教程
25 0
|
2月前
|
关系型数据库 MySQL 数据安全/隐私保护
windows系统bat批处理 mysql 脚本启动关闭
windows系统bat批处理 mysql 脚本启动关闭
141 3
|
2月前
|
Windows
windows系统vbs脚本 恶搞关不掉的窗口 以及解决办法
windows系统vbs脚本 恶搞关不掉的窗口 以及解决办法
55 2
|
2月前
|
Windows
windows系统vbs脚本 恶搞将系统搞崩 死机 以及解决
windows系统vbs脚本 恶搞将系统搞崩 死机 以及解决
32 1
|
2月前
|
Windows
windows系统vbs脚本 提取文件夹中的所有文件名
windows系统vbs脚本 提取文件夹中的所有文件名
30 0