Skip to content
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
1 change: 1 addition & 0 deletions malduck/crypto/aes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PlaintextKeyBlob(BaseBlob):

.. seealso:: :class:`malduck.crypto.BLOBHEADER`
"""

types = {
16: "AES-128",
24: "AES-192",
Expand Down
1 change: 1 addition & 0 deletions malduck/crypto/winhdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class BLOBHEADER(Structure):
BLOBHEADER structure description (Microsoft Docs):
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/ns-wincrypt-publickeystruc
"""

_pack_ = 1
_fields_ = [
("bType", UInt8),
Expand Down
10 changes: 6 additions & 4 deletions malduck/procmem/binmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from abc import ABCMeta, abstractmethod
from typing import Iterator, List, Optional, Type, TypeVar

from typing_extensions import Self

from .procmem import ProcessMemory, ProcessMemoryBuffer
from .region import Region

Expand All @@ -18,7 +20,7 @@ class ProcessMemoryBinary(ProcessMemory, metaclass=ABCMeta):
__magic__: Optional[bytes] = None

def __init__(
self: T,
self,
buf: ProcessMemoryBuffer,
base: int = 0,
regions: Optional[List[Region]] = None,
Expand All @@ -29,7 +31,7 @@ def __init__(
if detect_image:
image = self.is_image_loaded_as_memdump()
self.is_image = image
self._image: Optional[T] = None
self._image: Optional[Self] = None
if image:
self._reload_as_image()

Expand All @@ -41,15 +43,15 @@ def _reload_as_image(self) -> None:
raise NotImplementedError()

@property
def image(self: T) -> Optional[T]:
def image(self) -> Optional[Self]:
"""
Returns ProcessMemory object loaded with image=True or None if can't be loaded or is loaded as image yet
"""
if self.is_image:
return None
try:
if not self._image:
self._image = self.__class__.from_memory(self, image=True)
self._image = self.from_memory(self, image=True)
return self._image
except Exception:
import traceback
Expand Down
6 changes: 3 additions & 3 deletions malduck/procmem/procmem.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ProcessMemory:
def from_file(cls: Type[T], filename: str, **kwargs) -> T: ...
@classmethod
def from_memory(
cls: Type[T], memory: "ProcessMemory", base: int = None, **kwargs
cls: Type[T], memory: "ProcessMemory", base: Optional[int] = None, **kwargs
) -> T: ...
@property
def length(self) -> int: ...
Expand Down Expand Up @@ -228,8 +228,8 @@ class ProcessMemory:
) -> Iterator[Instruction]: ...
def extract(
self,
modules: ExtractorModules = None,
extract_manager: ExtractManager = None,
modules: Optional[ExtractorModules] = None,
extract_manager: Optional[ExtractManager] = None,
) -> Optional[List[Dict[str, Any]]]: ...
# yarap(ruleset)
# yarap(ruleset, offset)
Expand Down
3 changes: 3 additions & 0 deletions malduck/yara.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class YaraRulesetMatch(_Mapper["YaraRuleMatch"]):
offset_mapper: Optional[OffsetMapper] = None,
) -> None:
super().__init__(elements={})

def _map_matches(
self, matches: List[YaraRulesMatch], offset_mapper: Optional[OffsetMapper]
) -> Dict[str, "YaraRuleMatch"]: ...
Expand All @@ -116,6 +117,7 @@ class YaraRulesetOffsets(_Mapper["YaraRuleOffsets"]):
_matches: YaraRulesetMatch
def __init__(self, matches: YaraRulesetMatch) -> None:
super().__init__(elements={})

def remap(
self, offset_mapper: Optional[OffsetMapper] = None
) -> "YaraRulesetOffsets": ...
Expand All @@ -137,6 +139,7 @@ class YaraRuleMatch(_Mapper[List[YaraStringMatch]]):
tags: List[str],
) -> None:
super().__init__({})

def get_offsets(self, string) -> List[int]: ...

class YaraRuleOffsets(_Mapper[List[int]]):
Expand Down
3 changes: 1 addition & 2 deletions readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ formats: all

python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- docs

build:
os: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pyelftools
pycryptodomex>=3.8.2
capstone>=4.0.1
yara-python
typing-extensions>=3.7.4.2
typing-extensions>=4.0.0
cryptography>=3.1
dnfile>=0.15.0