Skip to content
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

Update and refactor memory allocation/permission rules #836

Merged
merged 7 commits into from
Oct 16, 2023

Conversation

mr-tz
Copy link
Collaborator

@mr-tz mr-tz commented Oct 11, 2023

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now named: allocate or change RWX memory

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now called: allocate or change RW memory

Comment on lines -19 to -26
- api: kernel32.VirtualProtect
- api: kernel32.VirtualProtectEx
- api: NtAllocateVirtualMemory
- api: ZwAllocateVirtualMemory
- api: NtMapViewOfSection
- api: ZwMapViewOfSection
- api: NtProtectVirtualMemory
- api: ZwProtectVirtualMemory
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved the removed APIs to change memory protection

Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a nice cleanup

Comment on lines -16 to -28
- basic block:
- and:
# xor ecx, ecx ; lpAddress
# mov edx, 31Fh ; dwSize
# mov r8d, 1000h ; flAllocationType
# lea r9d, [rcx+40h] ; flProtect
# call cs:VirtualAlloc
- match: allocate memory
- or:
- number: 0x40
- instruction:
- mnemonic: lea
- offset: 0x40
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved to allocate RWX memory / allocate RW memory

@mr-tz
Copy link
Collaborator Author

mr-tz commented Oct 11, 2023

@jtothej feel free to review and provide feedback here, as well

@mr-tz mr-tz requested a review from mike-hunhoff October 13, 2023 11:50
Copy link
Collaborator

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

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

this is a beautiful update that really shows how we can abstract logic with capa. thanks @mr-tz !

@mr-tz mr-tz merged commit 210b86f into master Oct 16, 2023
3 checks passed
@mr-tz mr-tz deleted the update-alloc-rules branch October 16, 2023 14:51
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.

2 participants