From 2c0b5b95a6698802ab4939952f91f4a6be98c4e2 Mon Sep 17 00:00:00 2001 From: MathematicianGoat <101201591+MathematicianGoat@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:52:10 +0300 Subject: [PATCH] Update wh1tem0cha.py Added dump_section method. --- src/wh1tem0cha/wh1tem0cha.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wh1tem0cha/wh1tem0cha.py b/src/wh1tem0cha/wh1tem0cha.py index 87d614f..e7f8aef 100755 --- a/src/wh1tem0cha/wh1tem0cha.py +++ b/src/wh1tem0cha/wh1tem0cha.py @@ -427,6 +427,18 @@ def dump_segment(self, segment_name): self._fhandler.seek(int(target_segment_info["offset"], 16)-0x8) # locate segment start return self._fhandler.read(int(target_segment_info["filesize"], 16)) + def dump_section(self, section_name): + """ + Description: This method is for dumping section data + Usage: wm.dump_section(section_name="__TEXT") + """ + # We need section info first + target_section_info = self.section_info(section_name=section_name) + + # Seek target offset and read sizeof(section) + self._fhandler.seek(int(target_section_info["offset"], 16)) + return self._fhandler.read(int(target_section_info["size"], 16)) + def get_strings(self): """ Description: This method is for dumping string values @@ -655,4 +667,4 @@ def get_binary_info(self): self._binary_info["sha256"] = hash_val return self._binary_info else: - raise Exception("There is no pattern about MACH-O!!") \ No newline at end of file + raise Exception("There is no pattern about MACH-O!!")