[go: up one dir, main page]

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

Changed to not use Lookahead regex #4964

Merged
merged 5 commits into from
Aug 11, 2024

Conversation

fukusuket
Copy link
Contributor
@fukusuket fukusuket commented Aug 10, 2024

Summary of the Pull Request

Since lookahead(and lookbehind) regex are not supported in Golang or Rust,
I replaced the lookahead regex with simple contains logic as follows.

  • before(lookahead regex): (?=.*`)
  • after(contains logic): |contains: '`'

FYI: #4526

I think it's difficult to support regex for all languages...,
but I think it might be better to use more supported regex as much as possible.

Changelog

fix: Powershell Token Obfuscation - Powershell - Changed to not use Lookahead regex
fix: Powershell Token Obfuscation - Process Creation - Changed to not use Lookahead regex

Example Log Event

N/A

Fixed Issues

Golang

https://go.dev/play/p/YjkmggquHlV
スクリーンショット 2024-08-11 9 28 44

Rust

スクリーンショット 2024-08-11 8 45 32

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 Aug 10, 2024
@fukusuket fukusuket changed the title changed to not use lookahead regex changed to not use Lookahead regex Aug 10, 2024
@fukusuket fukusuket marked this pull request as draft August 10, 2024 23:57
@fukusuket
Copy link
Contributor Author
fukusuket commented Aug 11, 2024

Regex compile test

I tested on regex101.

Rust

スクリーンショット 2024-08-11 8 35 26

Java

スクリーンショット 2024-08-11 8 34 54

.NET(C#)

スクリーンショット 2024-08-11 8 35 17

Python

スクリーンショット 2024-08-11 8 34 39

PCRE2

スクリーンショット 2024-08-11 8 33 57

@fukusuket
Copy link
Contributor Author
fukusuket commented Aug 11, 2024

Regex compile test

Golang

Since regex101 does not correctly check Golang regex containing backquotes, I wrote a simple script to check (Backslash escaping is required, so after manually adding)

https://go.dev/play/p/UW4ADHQHpmm

スクリーンショット 2024-08-11 9 33 11

@fukusuket fukusuket changed the title changed to not use Lookahead regex Changed to not use Lookahead regex Aug 11, 2024
@fukusuket fukusuket marked this pull request as ready for review August 11, 2024 00:40
@fukusuket
Copy link
Contributor Author

Sorry, I noticed that this pull request needs a little more improvement, so I'll fix it.

@fukusuket fukusuket marked this pull request as draft August 11, 2024 01:05
@nasbench nasbench added the Work In Progress Some changes are needed label Aug 11, 2024
@fukusuket fukusuket marked this pull request as ready for review August 11, 2024 03:45
@fukusuket
Copy link
Contributor Author

Converting this case to a rule without lookahead is difficult... I tried to deal with it by filtering out $env:path
(It would be nice if we could avoid using lookahead as much as possible, but if this pull request is not appropriate, I will close this pull request)

FYI:
As far as I am currently aware, the following projects are using Sigma:

Golang

Rust:

We are very grateful for the Sigma project :)

@nasbench nasbench removed the Work In Progress Some changes are needed label Aug 11, 2024
@nasbench
Copy link
Member

This is indeed a difficult case (especially for scriptblock). We'll accept the blindspot for now, until we can find a better solution.

I will add a test for lookahead usage in regex, to avoid this in the future.

Thanks for the quick fix.

@nasbench nasbench merged commit c8a3761 into SigmaHQ:master Aug 11, 2024
12 checks passed
@fukusuket fukusuket deleted the changed-not-use-lookahead-regex branch August 11, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rules Windows Pull request add/update windows related rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants