rules: add nursery rule for shellcode execution via ReadDirectoryChanges#1140
Open
akshat4703 wants to merge 2 commits intomandiant:masterfrom
Open
rules: add nursery rule for shellcode execution via ReadDirectoryChanges#1140akshat4703 wants to merge 2 commits intomandiant:masterfrom
akshat4703 wants to merge 2 commits intomandiant:masterfrom
Conversation
Contributor
Author
|
@mike-hunhoff Updated per the rule docs on A/W handling: I replaced explicit A/W variants with base API names (ReadDirectoryChanges, ReadDirectoryChangesEx, and CreateFile) so the rule matches both variants correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new nursery rule detecting potential shellcode execution triggered through the Windows
ReadDirectoryChangesAPI callback flow.The idea comes from the
rule-ideaissues and currently has no related PRs (GitHub search for"ReadDirectoryChanges" shellcode executionreturned none).Detection logic
The rule looks for patterns where malware may use directory change notifications as a trigger for executing shellcode.
Typical flow includes:
ReadDirectoryChangesWorReadDirectoryChangesExWSleepExWaitForSingleObjectExWaitForMultipleObjectsExThese APIs together can indicate a callback-driven execution path where shellcode is triggered by filesystem events.
Rule location
rules/nursery/execute-shellcode-via-readdirectorychanges.yml
Validation
Formatting and lint checks pass:
HOME=/tmp .venv/bin/python scripts/capafmt.py -c rules/nursery/execute-shellcode-via-readdirectorychanges.yml
HOME=/tmp .venv/bin/python scripts/lint.py -t “execute shellcode via ReadDirectoryChanges” rules
Both commands completed successfully.
Notes
This rule is added to nursery because it may benefit from additional testing and refinement before promotion to the main ruleset.