Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex improvement on Powershell rules #5145

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

djlukic
Copy link
Contributor

@djlukic djlukic commented Dec 27, 2024

Summary of the Pull Request

Hi,

Proposing a regex fix for following rules:

  1. 30a8cb77-8eb3-4cfb-8e79-ad457c5a4592
  2. df9a0e0e-fedb-4d6c-8668-d765dfc92aa7

Changelog

Regex condition update for following rules:

  • Suspicious Non PowerShell WSMAN COM Provider
  • Renamed Powershell Under Powershell Channel

Example Log Event

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="PowerShell" /> 
  <EventID Qualifiers="0">400</EventID> 
  <Level>4</Level> 
  <Task>4</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2024-12-01T14:26:10.0000000Z" /> 
  <EventRecordID>3079110</EventRecordID> 
  <Channel>Windows PowerShell</Channel> 
  <Computer>McServer.mcdermott.local</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Available</Data> 
  <Data>None</Data> 
  <Data>NewEngineState=Available PreviousEngineState=None SequenceNumber=37 HostName=RunspaceHost HostVersion=15.0.0.0 HostId=9d15ca57-8227-4b5f-a365-fed71ccb085b EngineVersion=3.0 RunspaceId=5e473451-e6ff-4eba-b8d8-c96c5fe84509 PipelineId= CommandName= CommandType= ScriptName= CommandPath= CommandLine=</Data> 
  </EventData>
  </Event>

Fixed Issues

Above Example of Log Event is beautified view from Event Viewer.

Screenshot 2024-12-27 122655

However after HostId=9d15ca57-8227-4b5f-a365-fed71ccb085b there is no whitespace but \r\n\t. I checked this in many EVTX parsers to be sure and all of them have \r\n\t.

Windows Powershell.evtx in HxD shows the same.
Screenshot 2024-12-27 122853

SigmaHQ Rule Creation Conventions

  • If your PR adds new rules, please consider following and applying these conventions

@github-actions github-actions bot added Rules Windows Pull request add/update windows related rules labels Dec 27, 2024
Copy link
Member

@nasbench nasbench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original logs matched accurately on this using a custom parser. Hence changing this to \s+ should cover all cases.

Also @djlukic please update the modified date.

@nasbench nasbench added the 2nd Review Needed PR need a second approval label Dec 27, 2024
@nasbench nasbench requested a review from frack113 December 27, 2024 15:35
@frack113
Copy link
Member

Regex is good to me, only miss to update the modified date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2nd Review Needed PR need a second approval Rules Windows Pull request add/update windows related rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants