Commit e05aded2a45fc6ebd5735b4f57be67e59c97fbeb

Authored by decalage2
1 parent bcdd6708

ftguess: added xlsm

Showing 1 changed file with 18 additions and 5 deletions
oletools/ftguess.py
... ... @@ -156,8 +156,9 @@ class FTYPE(object):
156 156 WORD6 = 'Word6'
157 157 EXCEL97 = 'Excel97'
158 158 EXCEL2007 = 'Excel2007'
  159 + EXCEL2007_MACRO = 'Excel2007_XLSM'
159 160 EXCEL5 = 'Excel5'
160   - # TODO: XLSM, XLSB, DOCM, PPTM, PPSX, PPSM, ...
  161 + # TODO: XLSB, DOCM, PPTM, PPSX, PPSM, ...
161 162 RTF = 'RTF'
162 163 HTML = 'HTML'
163 164 PDF = 'PDF'
... ... @@ -309,8 +310,6 @@ class FType_Generic_OLE(FType_Base):
309 310 return False
310 311  
311 312  
312   -# TODO: use a dictionary to map CLSIDs to Ftypes, instead of this class
313   -
314 313 class FType_OLE_CLSID_Base(FType_Generic_OLE):
315 314 """
316 315 Base class to recognize OLE files based on CLSID or stream names
... ... @@ -320,6 +319,7 @@ class FType_OLE_CLSID_Base(FType_Generic_OLE):
320 319  
321 320 @classmethod
322 321 def recognize(cls, ftg):
  322 + # TODO: refactor, this is not used anymore
323 323 if ftg.root_clsid is not None:
324 324 # First, attempt to identify the root storage CLSID:
325 325 if ftg.root_clsid in cls.CLSIDS:
... ... @@ -518,8 +518,19 @@ class FType_Excel2007_Workbook(FType_Generic_OpenXML):
518 518 application = APP.MSEXCEL
519 519 filetype = FTYPE.EXCEL2007
520 520 name = 'MS Excel 2007+ Workbook'
521   - longname = 'MS Excel 2007+ Workbook or Template'
  521 + longname = 'MS Excel 2007+ Workbook (.xlsx)'
522 522 extensions = ['xlsx']
  523 + content_types = ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',)
  524 + PUID = 'fmt/214'
  525 +
  526 +class FType_Excel2007_Workbook_MacroEnabled(FType_Generic_OpenXML):
  527 + application = APP.MSEXCEL
  528 + filetype = FTYPE.EXCEL2007_MACRO
  529 + name = 'MS Excel 2007+ Macro-Enabled Workbook'
  530 + longname = 'MS Excel 2007+ Macro-Enabled Workbook (.xlsm)'
  531 + extensions = ['xlsm']
  532 + content_types = ('application/vnd.ms-excel.sheet.macroEnabled.12',)
  533 + PUID = 'fmt/445'
523 534  
524 535 clsid_ftypes = {
525 536 # mapping from CLSID of root storage to FType classes:
... ... @@ -540,6 +551,7 @@ openxml_ftypes = {
540 551 'application/vnd.ms-word.template.macroEnabledTemplate.main+xml': FType_Word2007_Template_Macro,
541 552 # EXCEL
542 553 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml': FType_Excel2007_Workbook,
  554 + 'application/vnd.ms-excel.sheet.macroEnabled.main+xml': FType_Excel2007_Workbook_MacroEnabled,
543 555 'application/vnd.ms-excel.sheet.binary.macroEnabled.main': None,
544 556 }
545 557  
... ... @@ -629,7 +641,8 @@ def process_file(container, filename, data):
629 641 print('Description: %s' % ftg.ftype.longname)
630 642 print('Application: %s' % ftg.ftype.application)
631 643 print('Container : %s' % ftg.container)
632   - print('Root CLSID : %s - %s' % (ftg.root_clsid, ftg.root_clsid_name))
  644 + if ftg.root_clsid is not None:
  645 + print('Root CLSID : %s - %s' % (ftg.root_clsid, ftg.root_clsid_name))
633 646 print('Content-type(s) : %s' % ','.join(ftg.ftype.content_types))
634 647 print('PUID : %s' % ftg.ftype.PUID)
635 648 print()
... ...