CmdID

CmdID / Rules / Windows

Potentially Suspicious EventLog Recon Activity Using Log Query Utilities

A Sigma rule for process creation on Windows, by Nasreddine Bencherchali (Nextron Systems), X__Junior (Nextron Systems).

medium 2 ATT&CK techniques 3 programs it names 12 everyday examples trip it

What it looks for

its detection, as SigmaHQ writes it
detection:
  selection_cmdlet:
    CommandLine|contains:
      - 'Get-WinEvent '
      - 'get-eventlog '
  selection_logs_eid:
    CommandLine|contains:
      - '-InstanceId 462?'
      - '.eventid -eq 462?'
      - '.ID -eq 462?'
      - 'EventCode=?462?'
      - 'EventIdentifier=?462?'
      - 'System[EventID=462?]'
      - '-InstanceId 4778'
      - '.eventid -eq 4778'
      - '.ID -eq 4778'
      - 'EventCode=?4778?'
      - 'EventIdentifier=?4778?'
      - 'System[EventID=4778]'
      - '-InstanceId 25'
      - '.eventid -eq 25'
      - '.ID -eq 25'
      - 'EventCode=?25?'
      - 'EventIdentifier=?25?'
      - 'System[EventID=25]'
      - '-InstanceId 1149'
      - '.eventid -eq 1149'
      - '.ID -eq 1149'
      - 'EventCode=?1149?'
      - 'EventIdentifier=?1149?'
      - 'System[EventID=1149]'
      - '-InstanceId 21'
      - '.eventid -eq 21'
      - '.ID -eq 21'
      - 'EventCode=?21?'
      - 'EventIdentifier=?21?'
      - 'System[EventID=21]'
      - '-InstanceId 22'
      - '.eventid -eq 22'
      - '.ID -eq 22'
      - 'EventCode=?22?'
      - 'EventIdentifier=?22?'
      - 'System[EventID=22]'
  selection_logs_name:
    CommandLine|contains:
      - 'Microsoft-Windows-PowerShell'
      - 'Microsoft-Windows-Security-Auditing'
      - 'Microsoft-Windows-TerminalServices-LocalSessionManager'
      - 'Microsoft-Windows-TerminalServices-RemoteConnectionManager'
      - 'Microsoft-Windows-Windows Defender'
      - 'PowerShellCore'
      - 'Security'
      - 'Windows PowerShell'
  selection_wevtutil_cli:
    CommandLine|contains:
      - ' qe '
      - ' query-events '
  selection_wevtutil_img:
    - Image|endswith: '\wevtutil.exe'
    - OriginalFileName: 'wevtutil.exe'
  selection_wmi:
    CommandLine|contains|all:
      - 'Select'
      - 'Win32_NTLogEvent'
  selection_wmic_cli:
    CommandLine|contains: ' ntevent'
  selection_wmic_img:
    - Image|endswith: '\wmic.exe'
    - OriginalFileName: 'wmic.exe'
  condition: 1 of selection_logs_* and (selection_wmi or all of selection_wevtutil_* or all of selection_wmic_* or selection_cmdlet)

The rule’s detection, its selections and fields in order of name. The whole rule, with its references and false positives, is on SigmaHQ, by Nasreddine Bencherchali (Nextron Systems), X__Junior (Nextron Systems), under the Detection Rule License 1.1. CmdID evaluates it on a command line alone: a test on what a command line cannot show, such as the parent process or the user, is not met.

Command lines that trip it

everyday examples from tldr-pages, CC BY 4.0, each read by CmdID

Convert the PowerShell event log to CSV on the page for ConvertTo-Csv

(Get-Culture).TextInfo.ListSeparator Get-WinEvent -LogName 'Windows PowerShell' | ConvertTo-Csv -UseCulture -NoTypeInformationIdentify

Create a web page to display PowerShell events on the page for ConvertTo-Html

Get-EventLog -LogName "Windows PowerShell" | ConvertTo-Html | Out-File pslog.htmIdentify

Create a web page to display PowerShell events on the page for ConvertTo-Html

Get-EventLog -Log "Windows PowerShell" | ConvertTo-Html -Property Id, Level, TaskIdentify

Configure the classic Security log on the page for Get-WinEvent

$log = Get-WinEvent -ListLog Security $log.MaximumSizeInBytes = 1gb try{ $log.SaveChanges() Get-WinEvent -ListLog Security | Format-List -Property * }catch [System.UnauthorizedAccessException]{ $ErrMsg = 'You don't have permission to configure this log!' $ErrMsg += ' Try running this script with administrator privileges. ' $ErrMsg += $_.Exception.Message Write-Error $ErrMsg }Identify

Get log information from event object properties on the page for Get-WinEvent

$Event = Get-WinEvent -LogName 'Windows PowerShell' $Event.Count $Event | Group-Object -Property Id -NoElement | Sort-Object -Property Count -Descending $Event | Group-Object -Property LevelDisplayName -NoElementIdentify

Invoke a command with a scriptblock stored in a variable on the page for Invoke-Command

$command = { Get-EventLog -LogName 'Windows PowerShell' | Where-Object { $_.Message -like 'certificate' } } Invoke-Command -ComputerName S1, S2 -ScriptBlock $commandIdentify

Run a single command on several computers on the page for Invoke-Command

$parameters = @{ ComputerName = 'Server01', 'Server02', 'TST-0143', 'localhost' ConfigurationName = 'MySession.PowerShell' ScriptBlock = { Get-EventLog 'Windows PowerShell' } } Invoke-Command @parametersIdentify

Include local variables in a command run on a remote computer on the page for Invoke-Command

$Log = 'Windows PowerShell' Invoke-Command -ComputerName Server01 -ScriptBlock { Get-EventLog -LogName $Using:Log -Newest 10 }Identify

Measure a command on the page for Measure-Command

Measure-Command { Get-EventLog "Windows PowerShell" }Identify

Select newest and oldest events in the event log on the page for Select-Object

$a = Get-EventLog -LogName "Windows PowerShell" $a | Select-Object -Index 0, ($A.Count - 1)Identify

Decrypt an encrypted event log message on the page for Unprotect-CmsMessage

$event = Get-WinEvent Microsoft-Windows-PowerShell/Operational -MaxEvents 1 | Where-Object Id -EQ 4104 Unprotect-CmsMessage -EventLogRecord $eventIdentify

Decrypt encrypted event log messages using the pipeline on the page for Unprotect-CmsMessage

Get-WinEvent Microsoft-Windows-PowerShell/Operational | Where-Object Id -EQ 4104 | Unprotect-CmsMessageIdentify

Programs and files it names

their pages here

ATT&CK

the techniques it is tagged with
T1087Account Discovery
T1552Unsecured Credentials