Patching getSegmentsInfo bug when parsing kext

This commit is contained in:
Karmaz95
2024-12-06 19:55:44 +01:00
parent 23280fb8c9
commit 42cf84599a
+11 -8
View File
@@ -477,17 +477,20 @@ class SnakeI(SnakeAppBundleExtension):
def getSegmentsInfo(self): def getSegmentsInfo(self):
''' Helper function for gathering various initialization information about the binary if extracted from FAT. ''' ''' Helper function for gathering various initialization information about the binary if extracted from FAT. '''
segments_count = 0 segments_count = 0
file_start = 0 # Default value if no segments
file_end = 0 # Default value if no segments
# Count segments
for s in self.binary.segments: for s in self.binary.segments:
segments_count+=1 segments_count += 1
for s in self.binary.segments: # Only try to get file offsets if we have segments
if s.index == 0: if segments_count > 0:
file_start = s.file_offset + self.binary.fat_offset for s in self.binary.segments:
if s.index == 0:
elif s.index == segments_count-1: file_start = s.file_offset + self.binary.fat_offset
file_end = s.file_offset + s.file_size + self.binary.fat_offset elif s.index == segments_count-1:
pass # self.binary.fat_offset file_end = s.file_offset + s.file_size + self.binary.fat_offset
file_size = file_end - file_start file_size = file_end - file_start
return segments_count, file_start, file_size, file_end return segments_count, file_start, file_size, file_end