Skip to content

Update unbacked antianalysis for accuracy#589

Open
kevross33 wants to merge 1 commit into
CAPESandbox:masterfrom
kevross33:patch-579539
Open

Update unbacked antianalysis for accuracy#589
kevross33 wants to merge 1 commit into
CAPESandbox:masterfrom
kevross33:patch-579539

Conversation

@kevross33

Copy link
Copy Markdown
Contributor

Improve process tracking and also of memory frees

Improve process tracking and also of memory frees

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the unbacked memory anti-analysis signatures and introduces several new signature classes to detect fileless execution, persistence, privilege escalation, EDR unhooking, ETW/AMSI patching, and debugger detection from unbacked memory. It also adds tracking for virtual memory freeing APIs to keep memory ranges up to date. The review feedback highlights two main issues: first, in VirtualAllocEx, the hProcess argument is a process handle rather than a PID, meaning storing ranges under this handle will break tracking (especially for pseudo-handles like -1 which should resolve to the current PID); second, calling .lower() on memory address arguments can cause AttributeError crashes if the values are logged as integers, so they should be explicitly cast to strings first.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Comment on lines +865 to +869
target_addr = (
self.get_argument(call, "BaseAddress")
or self.get_argument(call, "lpAddress")
or ""
).lower()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

If BaseAddress or lpAddress is logged as an integer (which is common in many Cuckoo/Cape environments), calling .lower() directly on it will raise an AttributeError: 'int' object has no attribute 'lower' and crash the signature execution.

Converting the value to a string first using str() avoids this crash.

            base_addr = self.get_argument(call, "BaseAddress") or self.get_argument(call, "lpAddress") or ""
            target_addr = str(base_addr).lower()

Comment on lines +877 to +883
target_label = (
self.get_argument(call, "BaseAddress")
or self.get_argument(call, "lpBaseAddress")
or self.get_argument(call, "ModuleName")
or self.get_argument(call, "HandleName")
or ""
).lower()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

If BaseAddress or lpBaseAddress is logged as an integer, calling .lower() directly on it will raise an AttributeError and crash the signature.

Converting the value to a string first using str() avoids this crash.

Suggested change
target_label = (
self.get_argument(call, "BaseAddress")
or self.get_argument(call, "lpBaseAddress")
or self.get_argument(call, "ModuleName")
or self.get_argument(call, "HandleName")
or ""
).lower()
base_addr = (
self.get_argument(call, "BaseAddress")
or self.get_argument(call, "lpBaseAddress")
or self.get_argument(call, "ModuleName")
or self.get_argument(call, "HandleName")
or ""
)
target_label = str(base_addr).lower()

Comment on lines +1003 to +1007
target_addr = (
self.get_argument(call, "BaseAddress")
or self.get_argument(call, "lpAddress")
or ""
).lower()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

If BaseAddress or lpAddress is logged as an integer (which is common in many Cuckoo/Cape environments), calling .lower() directly on it will raise an AttributeError: 'int' object has no attribute 'lower' and crash the signature execution.

Converting the value to a string first using str() avoids this crash.

            base_addr = self.get_argument(call, "BaseAddress") or self.get_argument(call, "lpAddress") or ""
            target_addr = str(base_addr).lower()

Comment thread modules/signatures/windows/memory_unbacked_antianalysis.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant