Commit 608f55c0ed455d216d4fb55942d0a27d1943ac95

Authored by decalage2
1 parent a962dd20

olemap: improved MiniFAT display with tablestream

Showing 1 changed file with 9 additions and 1 deletions
oletools/olemap.py
@@ -45,6 +45,7 @@ http://www.decalage.info/python/oletools @@ -45,6 +45,7 @@ http://www.decalage.info/python/oletools
45 # 2016-09-05 PL: - added main entry point for setup.py 45 # 2016-09-05 PL: - added main entry point for setup.py
46 # 2017-03-20 v0.51 PL: - fixed absolute imports, added optparse 46 # 2017-03-20 v0.51 PL: - fixed absolute imports, added optparse
47 # - added support for zip files and wildcards 47 # - added support for zip files and wildcards
  48 +# - improved MiniFAT display with tablestream
48 49
49 50
50 __version__ = '0.51dev3' 51 __version__ = '0.51dev3'
@@ -166,15 +167,22 @@ def main(): @@ -166,15 +167,22 @@ def main():
166 # print '%8X: %-12s offset=%08X next=%8X' % (i, fat_type, 0, fat_value) 167 # print '%8X: %-12s offset=%08X next=%8X' % (i, fat_type, 0, fat_value)
167 t.write_row(['%8X' % i, fat_type, '%08X' % offset, '%8X' % fat_value], 168 t.write_row(['%8X' % i, fat_type, '%08X' % offset, '%8X' % fat_value],
168 colors=[None, color_type, None, None]) 169 colors=[None, color_type, None, None])
  170 + t.close()
169 print('') 171 print('')
170 172
171 print('MiniFAT:') 173 print('MiniFAT:')
172 # load MiniFAT if it wasn't already done: 174 # load MiniFAT if it wasn't already done:
173 ole.loadminifat() 175 ole.loadminifat()
  176 + t = tablestream.TableStream([8, 12, 8, 8], header_row=['Sector #', 'Type', 'Offset', 'Next #'])
174 for i in range(len(ole.minifat)): 177 for i in range(len(ole.minifat)):
175 fat_value = ole.minifat[i] 178 fat_value = ole.minifat[i]
176 fat_type = FAT_TYPES.get(fat_value, 'Data') 179 fat_type = FAT_TYPES.get(fat_value, 'Data')
177 - print('%8X: %-12s offset=%08X next=%8X' % (i, fat_type, 0, fat_value)) 180 + color_type = FAT_COLORS.get(fat_value, FAT_COLORS['default'])
  181 + # TODO: compute offset
  182 + # print('%8X: %-12s offset=%08X next=%8X' % (i, fat_type, 0, fat_value))
  183 + t.write_row(['%8X' % i, fat_type, 'N/A', '%8X' % fat_value],
  184 + colors=[None, color_type, None, None])
  185 + t.close()
178 186
179 ole.close() 187 ole.close()
180 188