-
Notifications
You must be signed in to change notification settings - Fork 60
Create bypass_edr_syscalls.py for direct syscalls evasion #536
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c5cf5f7
Create bypass_edr_syscalls.py for syscall evasion
kevross33 827698e
FP Fix: Refactor syscall evaluation to use Return Address
kevross33 6d5c8e1
Refactor sysenter return address evaluation and whitelist
kevross33 cc47614
Update description for syscall evasion class
kevross33 89c2e76
Rename SyscallEvasion class to DirectSyscallEvasion
kevross33 10ead39
Update data appending for evasive syscalls
kevross33 9050818
Update comment for syscall execution logic
kevross33 049909e
Apply suggestions from code review
kevross33 5e4f234
Simplify is_evasive condition in bypass_edr_syscalls.py
kevross33 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Copyright (C) 2026 Kevin Ross, detection logic refined with Gemini | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| from lib.cuckoo.common.abstracts import Signature | ||
|
|
||
| class DirectSyscallEvasion(Signature): | ||
| name = "direct_syscall_evasion" | ||
| description = "Executes direct syscalls to evade EDR and user-land API hooks" | ||
| severity = 3 | ||
| confidence = 80 | ||
| categories = ["evasion", "stealth"] | ||
| authors = ["Kevin Ross"] | ||
| minimum = "1.3" | ||
| evented = True | ||
| ttps = ["T1055"] | ||
|
|
||
| filter_apinames = {"sysenter", "syscall"} | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| Signature.__init__(self, *args, **kwargs) | ||
| self.evasive_syscalls = set() | ||
|
|
||
| def on_call(self, call, process): | ||
| ret_addr = self.get_argument(call, "Return Address") | ||
|
|
||
| if not ret_addr or ret_addr == "0x00000000": | ||
| return | ||
|
|
||
| try: | ||
| addr_val = int(ret_addr, 16) if ret_addr.startswith("0x") else int(ret_addr) | ||
|
|
||
| # System DLLs (ntdll.dll, kernel32.dll) load very high in memory. | ||
| # 32-bit: > 0x70000000 | 64-bit: > 0x7FF000000000 | ||
| # If the literal Return Address is in low memory, the malware is | ||
| # manually executing the syscall (Direct) and the return address will point back to the malware. | ||
| is_evasive = False | ||
| if 0 < addr_val < 0x70000000: | ||
| is_evasive = True | ||
| elif 0x0000000100000000 <= addr_val < 0x0000700000000000: | ||
| is_evasive = True | ||
|
|
||
| module = self.get_argument(call, "Module") | ||
| if module: | ||
| module_lower = module.lower() | ||
| safe_modules = ["kernel32", "kernelbase", "ntdll", "wow64"] | ||
| if any(safe in module_lower for safe in safe_modules) and not is_evasive: | ||
| return | ||
|
|
||
| if is_evasive: | ||
| mod_name = module if module else "Unknown_Memory" | ||
| if mod_name not in self.evasive_syscalls: | ||
| self.evasive_syscalls.add(mod_name) | ||
| if len(self.evasive_syscalls) <= 10: | ||
| self.mark_call() | ||
|
|
||
| except ValueError: | ||
| pass | ||
|
|
||
| def on_complete(self): | ||
| ret = False | ||
| if len(self.evasive_syscalls) > 0: | ||
| self.data.append({"direct_syscalls": list(self.evasive_syscalls)}) | ||
| ret = True | ||
|
|
||
| return ret | ||
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.
Uh oh!
There was an error while loading. Please reload this page.