返回列表 发帖

[系统相关] [已解决]批处理如何记录Windows远程桌面登录失败时的IP?

本帖最后由 522235677 于 2022-5-26 14:47 编辑

需求:有一个服务器,想记录远程桌面登录失败的IP,并保存到一个文本
详述:在事件查看器当中,在事件ID为4625的事件详情中可以查到IP地址,目前来说可以根据事件来创建计划任务,但是当计划任务中不知道如何来确定是哪个事件、不知道怎么获取事件中的IP地址

求大侠指导

powershell获取事件IP地址
$evt=Get-WinEvent -LogName Security -FilterXPath "Event[System[EventID=4625 and TimeCreated[timediff(@SystemTime)<=600000]]]" -MaxEvents 1 -ErrorAction SilentlyContinue
if($null -ne $evt){
$evt.Properties[3].Value # IP地址可能不是这个序号
}COPY
微信:flashercs
QQ:49908356

TOP

回复 2# flashercs


    感谢大佬帮忙,但是我测试后,发现脚本只显示0

TOP

回复 3# 522235677
$evt=Get-WinEvent -LogName Security -FilterXPath "Event[System[EventID=4625 and TimeCreated[timediff(@SystemTime)<=600000]]]" -MaxEvents 1 -ErrorAction SilentlyContinue
if($null -ne $evt){
$evt.Properties
}COPY
微信:flashercs
QQ:49908356

TOP

回复 4# flashercs


    非常感谢大佬的帮助,可以看到IP地址了
还要再请教一下,这个怎么只匹配出ip地址,然后执行一下curl,把这个ip提交
curl http://test.com?ip=%ip%
肯定大佬赐教

TOP

回复 5# 522235677
$evt=Get-WinEvent -LogName Security -FilterXPath "Event[System[EventID=4625 and TimeCreated[timediff(@SystemTime)<=600000]]]" -MaxEvents 1 -ErrorAction SilentlyContinue
if($null -ne $evt){
$ip=$evt.Properties[19].Value
curl.exe http://test.com?ip=$ip
}COPY
1

评分人数

微信:flashercs
QQ:49908356

TOP

回复 6# flashercs


    感谢大佬帮助,运行成功

TOP

回复 2# flashercs


    大佬
Event[System[EventID=4624 and TimeCreated[timediff(@SystemTime)<=600000]]]

这个我想再加个判断 EventData[LogonType=10],我尝试了很多次都失败了,望指导~

TOP

回复 8# 522235677
"Event[System[EventID=4624 and TimeCreated[timediff(@SystemTime)<=600000]] and EventData[Data[@Name='LogonType']=10]]"COPY
微信:flashercs
QQ:49908356

TOP

回复 9# flashercs


    大佬威武,向大佬学习

TOP

返回列表