-
Notifications
You must be signed in to change notification settings - Fork 234
feat(rules): detect ReadDirectoryChanges shellcode via callback and APC (#1095) #1143
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| rule: | ||
| meta: | ||
| name: execute shellcode via ReadDirectoryChanges APC | ||
| namespace: load-code/shellcode | ||
| authors: | ||
| - sherkhanz | ||
| description: Detects abuse of the ReadDirectoryChanges API completion routine combined with an alertable wait state to execute shellcode. | ||
| scopes: | ||
| static: function | ||
| dynamic: span of calls | ||
| att&ck: | ||
| - Defense Evasion::Process Injection::Asynchronous Procedure Call [T1055.004] | ||
| mbc: | ||
| - Defense Evasion::Hijack Execution Flow::Abuse Windows Function Calls [F0015.006] | ||
| references: | ||
| - https://github.com/mandiant/capa-rules/issues/1095 | ||
| - https://osandamalith.com/2025/09/25/executing-shellcode-with-readdirectorychangess-hidden-callback/ | ||
| - https://github.com/OsandaMalith/CallbackShellcode/blob/main/ReadDirectoryChanges.c | ||
| features: | ||
| - and: | ||
| - or: | ||
| - api: ReadDirectoryChangesW | ||
| - api: ReadDirectoryChangesA | ||
| - api: ReadDirectoryChangesExW | ||
| - api: ReadDirectoryChangesExA | ||
|
Comment on lines
+22
to
+25
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review the rule documentation to understand how capa handles APIs with A/W variants and update accordingly. |
||
| - or: | ||
| - api: SleepEx | ||
| - api: WaitForSingleObjectEx | ||
| - api: WaitForMultipleObjectsEx | ||
| - api: MsgWaitForMultipleObjectsEx | ||
| - api: SignalObjectAndWait | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ rule: | |
| - https://osandamalith.com/2021/04/01/executing-shellcode-via-callbacks/ | ||
| - https://github.com/tlsbollei/Malware-Training/blob/main/Code%20Injection/LdrCallEnclave.cpp | ||
| - https://osandamalith.com/2025/10/18/rtlregisterwait-shellcode-execution-poc/ | ||
| - https://osandamalith.com/2025/09/25/executing-shellcode-with-readdirectorychangess-hidden-callback/ | ||
| examples: | ||
| - 10cd7afd580ee9c222b0a87ff241d306:0x10008BE0 | ||
| - 268d61837aa248c1d49a973612a129ce:0x1000CEC0 | ||
|
|
@@ -82,6 +83,10 @@ rule: | |
| - api: ImmEnumInputContext | ||
| - api: LdrCallEnclave | ||
| - api: LineDDA | ||
| - api: ReadDirectoryChangesA | ||
| - api: ReadDirectoryChangesW | ||
| - api: ReadDirectoryChangesExA | ||
| - api: ReadDirectoryChangesExW | ||
|
Comment on lines
+86
to
+89
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review the rule documentation to understand how capa handles APIs with A/W variants and update accordingly. |
||
| - and: | ||
| - api: RtlRegisterWait | ||
| - api: SetEvent | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.