Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save asheroto/863e6bb2a1bb143a2da0d53d913176e2 to your computer and use it in GitHub Desktop.
Save asheroto/863e6bb2a1bb143a2da0d53d913176e2 to your computer and use it in GitHub Desktop.
PowerShell script to check for the presence of Invoke-Command, such as that ran by Empire and other fileless malware.
$result = Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-Sysmon/Operational"; StartTime=(get-date).AddHours(-1); EndTime=(Get-Date); ID=1}| ?{$_.Message -match "Invoke-Command" }
if($result.Count -gt 0) {
# PUT YOUR SCRIPT ACTION HERE WHEN DETECTED IN THE LAST HOUR
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment