Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions load-code/shellcode/execute-shellcode-via-readdirectorychanges.yml
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- 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
Copy link
Copy Markdown
Collaborator

@mike-hunhoff mike-hunhoff Mar 19, 2026

Choose a reason for hiding this comment

The 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
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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
Expand Down
Loading