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,8 +156,9 @@ class FTYPE(object):
156 WORD6 = 'Word6' 156 WORD6 = 'Word6'
157 EXCEL97 = 'Excel97' 157 EXCEL97 = 'Excel97'
158 EXCEL2007 = 'Excel2007' 158 EXCEL2007 = 'Excel2007'
  159 + EXCEL2007_MACRO = 'Excel2007_XLSM'
159 EXCEL5 = 'Excel5' 160 EXCEL5 = 'Excel5'
160 - # TODO: XLSM, XLSB, DOCM, PPTM, PPSX, PPSM, ... 161 + # TODO: XLSB, DOCM, PPTM, PPSX, PPSM, ...
161 RTF = 'RTF' 162 RTF = 'RTF'
162 HTML = 'HTML' 163 HTML = 'HTML'
163 PDF = 'PDF' 164 PDF = 'PDF'
@@ -309,8 +310,6 @@ class FType_Generic_OLE(FType_Base): @@ -309,8 +310,6 @@ class FType_Generic_OLE(FType_Base):
309 return False 310 return False
310 311
311 312
312 -# TODO: use a dictionary to map CLSIDs to Ftypes, instead of this class  
313 -  
314 class FType_OLE_CLSID_Base(FType_Generic_OLE): 313 class FType_OLE_CLSID_Base(FType_Generic_OLE):
315 """ 314 """
316 Base class to recognize OLE files based on CLSID or stream names 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,6 +319,7 @@ class FType_OLE_CLSID_Base(FType_Generic_OLE):
320 319
321 @classmethod 320 @classmethod
322 def recognize(cls, ftg): 321 def recognize(cls, ftg):
  322 + # TODO: refactor, this is not used anymore
323 if ftg.root_clsid is not None: 323 if ftg.root_clsid is not None:
324 # First, attempt to identify the root storage CLSID: 324 # First, attempt to identify the root storage CLSID:
325 if ftg.root_clsid in cls.CLSIDS: 325 if ftg.root_clsid in cls.CLSIDS:
@@ -518,8 +518,19 @@ class FType_Excel2007_Workbook(FType_Generic_OpenXML): @@ -518,8 +518,19 @@ class FType_Excel2007_Workbook(FType_Generic_OpenXML):
518 application = APP.MSEXCEL 518 application = APP.MSEXCEL
519 filetype = FTYPE.EXCEL2007 519 filetype = FTYPE.EXCEL2007
520 name = 'MS Excel 2007+ Workbook' 520 name = 'MS Excel 2007+ Workbook'
521 - longname = 'MS Excel 2007+ Workbook or Template' 521 + longname = 'MS Excel 2007+ Workbook (.xlsx)'
522 extensions = ['xlsx'] 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 clsid_ftypes = { 535 clsid_ftypes = {
525 # mapping from CLSID of root storage to FType classes: 536 # mapping from CLSID of root storage to FType classes:
@@ -540,6 +551,7 @@ openxml_ftypes = { @@ -540,6 +551,7 @@ openxml_ftypes = {
540 'application/vnd.ms-word.template.macroEnabledTemplate.main+xml': FType_Word2007_Template_Macro, 551 'application/vnd.ms-word.template.macroEnabledTemplate.main+xml': FType_Word2007_Template_Macro,
541 # EXCEL 552 # EXCEL
542 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml': FType_Excel2007_Workbook, 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 'application/vnd.ms-excel.sheet.binary.macroEnabled.main': None, 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,7 +641,8 @@ def process_file(container, filename, data):
629 print('Description: %s' % ftg.ftype.longname) 641 print('Description: %s' % ftg.ftype.longname)
630 print('Application: %s' % ftg.ftype.application) 642 print('Application: %s' % ftg.ftype.application)
631 print('Container : %s' % ftg.container) 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 print('Content-type(s) : %s' % ','.join(ftg.ftype.content_types)) 646 print('Content-type(s) : %s' % ','.join(ftg.ftype.content_types))
634 print('PUID : %s' % ftg.ftype.PUID) 647 print('PUID : %s' % ftg.ftype.PUID)
635 print() 648 print()