From 42cf84599ada45392401eddc14a1ed178c4cb6a8 Mon Sep 17 00:00:00 2001 From: Karmaz95 Date: Fri, 6 Dec 2024 19:55:44 +0100 Subject: [PATCH] Patching getSegmentsInfo bug when parsing kext --- X. NU/python/CrimsonUroboros.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/X. NU/python/CrimsonUroboros.py b/X. NU/python/CrimsonUroboros.py index d8b7a66..098ed42 100755 --- a/X. NU/python/CrimsonUroboros.py +++ b/X. NU/python/CrimsonUroboros.py @@ -477,17 +477,20 @@ class SnakeI(SnakeAppBundleExtension): def getSegmentsInfo(self): ''' Helper function for gathering various initialization information about the binary if extracted from FAT. ''' segments_count = 0 - - for s in self.binary.segments: - segments_count+=1 - - for s in self.binary.segments: - if s.index == 0: - file_start = s.file_offset + self.binary.fat_offset + file_start = 0 # Default value if no segments + file_end = 0 # Default value if no segments - elif s.index == segments_count-1: - file_end = s.file_offset + s.file_size + self.binary.fat_offset - pass # self.binary.fat_offset + # Count segments + for s in self.binary.segments: + segments_count += 1 + + # Only try to get file offsets if we have segments + if segments_count > 0: + for s in self.binary.segments: + if s.index == 0: + file_start = s.file_offset + self.binary.fat_offset + elif s.index == segments_count-1: + file_end = s.file_offset + s.file_size + self.binary.fat_offset file_size = file_end - file_start return segments_count, file_start, file_size, file_end