-
Notifications
You must be signed in to change notification settings - Fork 164
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
Add patch-antimalware-scan-interface-function.yml and updated patch-e… #798
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
anti-analysis/anti-av/patch-antimalware-scan-interface-function.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
rule: | ||
meta: | ||
name: patch Antimalware Scan Interface function | ||
namespace: anti-analysis/anti-av | ||
authors: | ||
- [email protected] | ||
scope: function | ||
att&ck: | ||
- Defense Evasion::Impair Defenses::Disable or Modify Tools [T1562.001] | ||
mbc: | ||
- Defense Evasion::Disable or Evade Security Tools [F0004] | ||
references: | ||
- https://fluidattacks.com/blog/amsi-bypass/ | ||
examples: | ||
- edb92795c06a2bde47e652639327253a1148ee675ba2f0d1d9ac8690ef1820b1:0x14001126C | ||
features: | ||
- and: | ||
- match: link function at runtime on Windows | ||
- or: | ||
- api: kernel32.VirtualProtect | ||
- api: kernel32.VirtualProtectEx | ||
- api: ntdll.NtProtectVirtualMemory | ||
- api: ZwProtectVirtualMemory | ||
- string: "VirtualProtect" | ||
- string: "VirtualProtectEx" | ||
- string: "NtProtectVirtualMemory" | ||
- string: "ZwProtectVirtualMemory" | ||
jtothej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- or: | ||
- string: "AmsiScanBuffer" | ||
- string: "AmsiScanString" | ||
- optional: | ||
- match: write process memory | ||
- string: "amsi.dll" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ rule: | |
- [email protected] | ||
scope: function | ||
att&ck: | ||
- Defense Evasion::Impair Defenses::Indicator Blocking [T1562.006] | ||
- Defense Evasion::Impair Defenses::Disable or Modify Tools [T1562.001] | ||
mbc: | ||
- Defense Evasion::Disable or Evade Security Tools [F0004] | ||
references: | ||
|
@@ -19,9 +19,11 @@ rule: | |
- match: link function at runtime on Windows | ||
- or: | ||
- api: kernel32.VirtualProtect | ||
- api: kernel32.VirtualProtectEx | ||
- api: ntdll.NtProtectVirtualMemory # exported by only ntdll, not ntoskrnl | ||
- api: ZwProtectVirtualMemory # exported by both ntdll and ntoskrnl | ||
- string: "VirtualProtect" | ||
- string: "VirtualProtectEx" | ||
- string: "NtProtectVirtualMemory" | ||
- string: "ZwProtectVirtualMemory" | ||
jtothej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- or: | ||
|
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.
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.
i think we should factor this logic out into a library rule, like
patch read-only memory at runtime
or somethingThere 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.
then we can have a rule like
hook function at runtime
and then the rules in this PR boil down to:and
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.
I was initially thinking about using
allocate RWX memory
(which in turn depends onallocate memory
) butallocate memory
matches on both memory allocation functions and functions that change of protection of already allocated memory.So maybe we could split
allocate memory
to actualallocate memory
and something likechange memory protection
(includingVirtualProtect
,VirtualProtectEx
,NtProtectVirtualMemory
,ZwProtectVirtualMemory
). The we could havechange memory protection to RWX
and use it in rules in this PR. The problem with this approach would be figuring out which rules currently usingallocate memory
rule depend on memory allocation functions, which depend on change of memory functions and which on both.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.
yup, that sounds like a great refactor!
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.
refactoring this in #836