MCPcopy Create free account
hub / github.com/HexHive/NASS / Section

Class Section

tools/gef.py:657–691  ·  view source on GitHub ↗

GEF representation of process memory sections.

Source from the content-addressed store, hash-verified

655
656
657class Section:
658 """GEF representation of process memory sections."""
659
660 def __init__(self, **kwargs: Any) -> None:
661 self.page_start: int = kwargs.get("page_start", 0)
662 self.page_end: int = kwargs.get("page_end", 0)
663 self.offset: int = kwargs.get("offset", 0)
664 self.permission: Permission = kwargs.get("permission", Permission(0))
665 self.inode: int = kwargs.get("inode", 0)
666 self.path: str = kwargs.get("path", "")
667 return
668
669 def is_readable(self) -> bool:
670 return (self.permission & Permission.READ) != 0
671
672 def is_writable(self) -> bool:
673 return (self.permission & Permission.WRITE) != 0
674
675 def is_executable(self) -> bool:
676 return (self.permission & Permission.EXECUTE) != 0
677
678 @property
679 def size(self) -> int:
680 if self.page_end is None or self.page_start is None:
681 return -1
682 return self.page_end - self.page_start
683
684 @property
685 def realpath(self) -> str:
686 # when in a `gef-remote` session, realpath returns the path to the binary on the local disk, not remote
687 return self.path if gef.session.remote is None else f"/tmp/gef/{gef.session.remote:d}/{self.path}"
688
689 def __str__(self) -> str:
690 return (f"Section(page_start={self.page_start:#x}, page_end={self.page_end:#x}, "
691 f"permissions={self.permission!s})")
692
693
694Zone = collections.namedtuple("Zone", ["name", "zone_start", "zone_end", "filename"])

Callers 3

__parse_procfs_mapsMethod · 0.85
__parse_info_memMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected