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

Include image=True binaries in load_binaries_from_memory #108

Merged
merged 3 commits into from
Oct 11, 2023
Merged
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
3 changes: 0 additions & 3 deletions malduck/extractor/extract_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ def push_procmem(
family = self._extract_procmem(p, matches)
for binary in binaries:
family = self._extract_procmem(binary, matches) or family
binary_image = binary.image
if binary_image:
family = self._extract_procmem(binary_image, matches) or family
return family

@property
Expand Down
15 changes: 12 additions & 3 deletions malduck/procmem/binmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,22 @@ def load_binaries_from_memory(cls: Type[T], procmem: ProcessMemory) -> Iterator[
"""
Looks for binaries in ProcessMemory object and yields specialized ProcessMemoryBinary objects
:param procmem: ProcessMemory object to search

.. versionchanged:: 4.4.0

In addition to image=False binaries, it also returns image=True versions.
In previous versions it was done by extractor, so it was working only
if memory-aligned version was also "valid".
"""
if cls.__magic__ is None:
raise NotImplementedError()
for binary_va in procmem.findv(cls.__magic__):
binary_procmem = cls.from_memory(procmem, base=binary_va)
if binary_procmem.is_valid():
yield binary_procmem
binary_procmem_dmp = cls.from_memory(procmem, base=binary_va)
if binary_procmem_dmp.is_valid():
yield binary_procmem_dmp
binary_procmem_img = binary_procmem_dmp.image
if binary_procmem_img and binary_procmem_img.is_valid():
yield binary_procmem_img

@abstractmethod
def is_image_loaded_as_memdump(self) -> bool:
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ ignore_missing_imports = True

[mypy-ida_bytes.*]
ignore_missing_imports = True

[mypy-dnfile.*]
ignore_missing_imports = True
Loading