+
    ¿ÌjÇ™ ã                   óÌ  € R t ^ RIHt Rt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
 ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt ^ RIHt ^ RIt]P<                  R8X  d   ]P>                  PA                  RR7       ^ RI!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1H2t2H3t3H4t4  ^ R	I5H6t7 Rt8]Pr                  Pu                  ]Pr                  Pw                  ]Pr                  Py                  ]=4      4      4      t>]Pr                  Pu                  ]Pr                  P                  ]>R4      4      t@]@]Pr                  9  d   ]Pr                  Pƒ                  ^ ]@4       ^ RIBtB^ RICHDtD ^ RIEHFtFHGtG ^ RIHHItI ^ RIJHKtK ^ RIJHLtL ^ RIJHMtM ^ RIJHNtN ^ RIOHPtP ^ RIQHRtR ^ RIJHStS ^ RITHUtU ]P¬                  ^ ,          ^8:  d   RtW]XtYRtZMQR
tWR tY][t\]]t^]_t`^ RIaHbtb RtZ]P¬                  ER8  d-   ^ RIctc]cPÈ                  ! R4      teR tf]cPÎ                  ! R]f4       R thERR lti]UPÔ                  ! R4      tkR tl ! R  R!]m4      tn ! R" R#]n4      to ! R$ R%]n4      tp ! R& R']q]n4      tr ! R( R)]o4      ts ! R* R+]n4      tt^ tu^tv^tw^tx^ty^tz^t{^t|^t}^	t~R,R-R.R/R0R1R2R3R4R5R6R7R8R9R:R;R<R=R>R?R@RARBR1/tRCt€RD]€,          t�REt‚RFtƒRGt„RHt…RIt†RJt‡RKtˆRLt‰]‚RM]ƒRN]„RO]…RP]†RQ]‡RR]ˆRS]‰RT/tŠRUt‹RVtŒRWt�RXtŽRYt�]�RZ,           t�]�R[,           t‘R\t’]’R],           t“]’R^,           t”]’R[,           t•]’R_,           t–R`t—]’Ra,           t˜RbERRcERRdERReERRfERRgERRhERRiERRjER/	t™RkERRlER/tš/ RmERbRoERbRpERbRqERbRrERbRsER bRtER!bRuER"bRvER#bRwER$bRxER%bRyER&bRzER'bR{ER(bR|ER)bR}ER*bR~ER+b/ RER,bR€ER-bR�ER.bR‚ER/bRƒER0bR„ER1bR…ER2bR†ER3bR‡ER4bRˆER5bR‰ER6bRŠER7bR‹ER8bRŒER9bR�ER:bRŽER;bR�ER<bCR’ER=R“ER>R”ER?R•ER@R–ERAR—ERBR˜ERCR™ERDRšERER›ERFRœERGR�ERH/Ct›RžERIRŠERJRŸERKR ERLR¡ERMR|ERNR¢ERO/tœR£ERP/t�R¥tžR¦tŸR§]Ÿ,           R¨,           t R©t¡Rª]¡,           R«,           ]¡,           t¢Rª]¢,           R¬,           ] ,           R¨,           t£R­t¤]£]¤,           t¥R®t¦]žR¯,           ]¥,           ]¦,           t§]EPP                  ! ]§4      t©R°R±.tªR²]EPP                  ! ]§4      3R³]EPP                  ! ]¢4      3R´]EPP                  ! Rµ]£,           R¤,           4      3R¶]EPP                  ! R·4      33t«]EPP                  ! R¸4      t¬R¹t­]EPP                  ! Rº]­,           Rº,           4      t®]¯! . ERQO4      t°]EPP                  ! R»4      t±]EPP                  ! R¼4      t²]EPP                  ! R½4      t³]4EPh                  ! 4        ]-R¾,           tµ ! R¿ RÀ]_4      t¶]$! ]'! RÁ4      ],! ]µ4      ,           ]+! ]04      ,           ]*! ]'! ]+! RÂ^RÃ7      4      4      ,           4      t·]·EPq                  RÄ 4       ]$! ]*! ]&! RÅ4      ]'! ]#! RÆ4      4      ,           4      ]+! ]2! RÇ4      4      ,           ]*! ]'! ]+! RÂ^RÃ7      4      4      ,           4      t¹]¹EPq                  RÈ 4       ]$! ]*! ]#! RÉ4      4      ]+! ]2! RÊ4      4      ,           ]*! ]'! ]+! RÂ^RÃ7      4      4      ,           4      tº]ºEPq                  RË 4       ]·]¹,          ]º,          t»](! RºRÌRÍ7      t¼]¼EPq                  RÎ 4       ]%! 4       t½]%! 4       t¾]*! ]$! ],! ]µ4      ]#! R�4      ,           ]'! ]#! RÏ4      ]#! RÐ4      ,          4      ,           ]'! RÑ4      ,           4      RÒ,           4      ]¾,           ]*! R¨4      ,           t¿RÓ tÀ]¿EPq                  ]À4       ]*! ]"! RÔ4      RÒ,           4      ]½,           ]*! R¨4      ,           tÁ]ÁEPq                  RÕ 4       ]*! ]"! RÖ4      RÒ,           4      ]½,           ]*! R¨4      ,           tÂ]ÂEPq                  R× 4       ]*! ]"! R‘4      RÒ,           4      ]½,           ]*! R¨4      ,           tÃ]ÃEPq                  RØ 4       ]*! ]"! Rn4      RÒ,           4      ]½,           ]*! R¨4      ,           tÄ]ÄEPq                  RÙ 4       ]+! ].]-R¾,           RÚ7      tÅ]*! Rº4      ]$! ]+! ]/^RÃ7      ERR,          4      ,           ]*! Rº4      ,           tÆ]ÆEPq                  RÛ 4       ]*! ]Å4      ]*! RÒ4      ,           ]Æ! RÜ4      ,           ]*! R¨4      ,           tÇ]ÇEPq                  RÝ 4       ]*! Rº4      ])! ]­4      ,           ]*! Rº4      ,           tÈ]ÈEPq                  RÞ 4       ]*! ]Å4      ]*! RÒ4      ,           ]È! Rß4      ,           ]*! R¨4      ,           tÉ]ÉEPq                  Rà 4       Rá tÊ]¿]Ã,          ]Ä,          ]¼,          ]Ç,          ]É,          tË]½]3! ]ËRâ^]1EP˜                  ]Ê3RÅ^]1EP˜                  ]Ê3.4      ,          t½Rã tÍRä tÎRå tÏRæ tÐ]Á]Â,          ]»,          tÑ]¾]3! ]ÑRç^]1EP˜                  ]Ï3Rè^]1EP˜                  ]Ð3RÁ^]1EP˜                  ]Î3Râ^]1EP˜                  ]Í3.4      ,          t¾Ré tÒ]EPP                  ! Rê4      tÓRë tÔ]¯! ]EPª                  4      tÖRì t×Rí tØRî tÙ ! Rï Rð]Ú4      tÛ ! Rñ Rò]Ú4      tÜERSRó ltÝRô tÞRõ tßERTRö ltàERTR÷ ltáERTRø ltâRù tãRú täRû tåRü tæRý tçRþ tèRÿ téERUER  ltêERVER ltë ! ER ER]Ú4      tìERWER ltí ! ER ER]Ú4      tî ! ER ER]î4      tïERTER	 ltðERXER
 ltñERTER ltò]óER8X  d
   ]ò! 4        R# R#   ] d9     ^ RIHu Ht  E
LÒ  ] d!     ^ RIHt   E
Lä  ] d    ]! ER4      hi ; ii ; ii ; i  ] d    R
t8 E
L¨i ; i(Y  ao  
olevba.py

olevba is a script to parse OLE and OpenXML files such as MS Office documents
(e.g. Word, Excel), to extract VBA Macro code in clear text, deobfuscate
and analyze malicious macros.
XLM/Excel 4 Macros are also supported in Excel and SLK files.

Supported formats:
    - Word 97-2003 (.doc, .dot), Word 2007+ (.docm, .dotm)
    - Excel 97-2003 (.xls), Excel 2007+ (.xlsm, .xlsb)
    - PowerPoint 97-2003 (.ppt), PowerPoint 2007+ (.pptm, .ppsm)
    - Word/PowerPoint 2007+ XML (aka Flat OPC)
    - Word 2003 XML (.xml)
    - Word/Excel Single File Web Page / MHTML (.mht)
    - Publisher (.pub)
    - SYLK/SLK files (.slk)
    - Text file containing VBA or VBScript source code
    - Password-protected Zip archive containing any of the above
    - raises an error if run with files encrypted using MS Crypto API RC4

Author: Philippe Lagadec - http://www.decalage.info
License: BSD, see source code or documentation

olevba is part of the python-oletools package:
http://www.decalage.info/python/oletools

olevba is based on source code from officeparser by John William Davison
https://github.com/unixfreak0037/officeparser
)Úprint_functionz0.60.2N)ÚBytesIOÚStringIOÚntT)Úauto_colors)ÚCaselessKeywordÚCaselessLiteralÚCombineÚForwardÚLiteralÚOptionalÚQuotedStringÚRegexÚSuppressÚWordÚ	WordStartÚ	alphanumsÚalphasÚhexnumsÚnumsÚopAssocÚsrangeÚinfixNotationÚParserElement)ÚdeobfuscatorFz..)Útablestream)ÚxglobÚPathNotFoundException)ÚcBIFF)Ú
ppt_parser)Úoleform)Úrtfobj)Úcrypto)Úensure_stdout_handles_unicode)Ú	codepages)Úftguess)Ú
log_helperÚutf8c                 ó   € V # ©N© )Úxs   &Úi/home/l0st/web/w4ttz.lol/public_html/toolz/MsgDoxxer/venv/lib/python3.14/site-packages/oletools/olevba.pyÚbyte_ordr-   n  s   € Øˆó    ©ÚreduceÚbackslashreplacec                 óÐ   € \        V \        4      '       dG   R P                  R V P                  V P                  V P
                    4       4      pWP
                  3# \        V 4      # )Ú c              3   óD   "  € T F  pR P                  V4      x € K  	  R# 5i)z	\x{0:02x}N©Úformat)Ú.0Úcs   & r,   Ú	<genexpr>Ú*backslashreplace_errors.<locals>.<genexpr>�  s    é € ÐZÑ<Y°q˜L×/Ñ/°×2Ð2Ó<Yùó   ‚ )Ú
isinstanceÚUnicodeDecodeErrorÚjoinÚobjectÚstartÚendÚ_backslashreplace_errors)ÚexcÚus   & r,   Úbackslashreplace_errorsrE     sQ   € Ü˜#Ô1×2Ò2Ø—G‘GÑZ¸C¿J¹JÀsÇyÁyÐQT×QXÑQXÑ<YÓZÓZ�ØŸ'™'�zÐ!Ü+¨CÓ0Ð0r.   c                óD   € \         '       d   V P                  RRR7      # V # )a  
convert a unicode string to a native str:
    - on Python 3, it returns the same string
    - on Python 2, the string is encoded with UTF-8 to a bytes str
:param unicode_string: unicode string to be converted
:return: the string converted to str
:rtype: str
r'   Úreplace©Úerrors)ÚPYTHON2Úencode)Úunicode_strings   &r,   Úunicode2strrM   ˆ  s%   € ÷ ƒwØ×$Ñ$ V°IÐ$Ó>Ð>àÐr.   c                óD   € \         '       d   V # V P                  VRR7      # )ad  
convert a bytes string to a native str:
    - on Python 2, it returns the same string (bytes=str)
    - on Python 3, the string is decoded using the provided encoding
      (UTF-8 by default) to a unicode str
:param bytes_string: bytes string to be converted
:param encoding: codec to be used for decoding
:return: the string converted to str
:rtype: str
rG   rH   )rJ   Údecode)Úbytes_stringÚencodings   &&r,   Ú	bytes2strrR   —  s%   € ÷ ƒwØÐà×"Ñ" 8°IÐ"Ó>Ð>r.   Úolevbac                 ó    € \         P                  \        P                  4       \        P
                  ! 4        \        P
                  ! 4        R# )aÞ  
Enable logging for this module (disabled by default).

For use by third-party libraries that import `olevba` as module.

This will set the module-specific logger level to `NOTSET`, which
means the main application controls the actual logging level.

This also enables logging for the modules used by us, but not the global
common logging mechanism (:py:mod:`oletools.common.log_helper.log_helper`).
Use :py:func:`oletools.common.log_helper.log_helper.enable_logging` for
that.
N)ÚlogÚsetLevelr&   ÚNOTSETr   Úenable_loggingr"   r*   r.   r,   rX   rX   ¯  s.   € ô ‡L�L”×"Ñ"Ô#Ü×ÒÔÜ
×ÒÖr.   c                   ó:   a a€ ] tR tRt oRtRV 3R lltRtVtV ;t# )ÚOlevbaBaseExceptioniÅ  zCBase class for exceptions produced here for simpler except clauses c                ó¾   <€ V'       d-   \         \        V `
  ! VR P                  V4      ,           3/ VB  M\         \        V `
  ! V3/ VB  Wn        W n        W0n        R# )z ({0})N)ÚsuperrZ   Ú__init__r6   ÚmsgÚfilenameÚorig_exc)Úselfr^   r_   r`   ÚkwargsÚ	__class__s   &&&&,€r,   r]   ÚOlevbaBaseException.__init__Ç  sZ   ø€ ßÜÔ% tÒ5°cØ6>·o±oÀhÓ6Oõ7Pñ @à8>ó@ô Ô% tÒ5°cÑD¸VÒDØŒØ ŒØ Žr.   )r_   r^   r`   )NN©	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r]   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©rc   Ú__classdict__s   @@r,   rZ   rZ   Å  s   ù‡ € ÙN÷	!÷ 	!r.   rZ   c                   ó:   a a€ ] tR tRt oRtRV 3R lltRtVtV ;t# )ÚFileOpenErroriÓ  zpraised by VBA_Parser constructor if all open_... attempts failed

probably means the file type is not supported
c                ó>   <€ \         \        V `  R V,          W4       R# )zFailed to open file %sN)r\   rq   r]   ©ra   r_   r`   rc   s   &&&€r,   r]   ÚFileOpenError.__init__Ù  s   ø€ ÜŒm˜TÑ+Ø$ xÕ/°ö	Er.   r*   r)   re   rn   s   @@r,   rq   rq   Ó  s   ù‡ € ñ÷
E÷ Er.   rq   c                   ó6   a a€ ] tR tRt oRtV 3R ltRtVtV ;t# )ÚProcessingErroriÞ  z-raised by VBA_Parser.process_file* functions c                ó>   <€ \         \        V `  R V,          W4       R# )zError processing file %sN)r\   rv   r]   rs   s   &&&€r,   r]   ÚProcessingError.__init__á  s   ø€ ÜŒo˜tÑ-Ø&¨Õ1°8ö	Gr.   r*   re   rn   s   @@r,   rv   rv   Þ  s   ù‡ € Ù8÷Gõ Gr.   rv   c                   ó*   a € ] tR tRt o RtR tRtV tR# )ÚMsoExtractionErroriæ  zAraised by mso_file_extract if parsing MSO/ActiveMIME data failed c                óZ   € \         P                  W4       \        P                  W4       R # r)   )rz   r]   rZ   )ra   r^   s   &&r,   r]   ÚMsoExtractionError.__init__é  s   € Ü×#Ñ# DÔ.Ü×$Ñ$ TÖ/r.   r*   N©rf   rg   rh   ri   rj   r]   rk   rl   ©ro   s   @r,   rz   rz   æ  s   ø‡ € ÙL÷0ð 0r.   rz   c                   ó:   a a€ ] tR tRt oRtRV 3R lltRtVtV ;t# )ÚSubstreamOpenErroriî  zDspecial kind of FileOpenError: file is a substream of original file c                óˆ   <€ \         \        V `  \        V4      R ,           \        V4      ,           V4       Wn        W n        R# ©Ú/N)r\   r€   r]   Ústrr_   Úsubfilename)ra   r_   r…   r`   rc   s   &&&&€r,   r]   ÚSubstreamOpenError.__init__ñ  s6   ø€ ÜÔ  $Ñ0Ü�‹M˜CÕ¤# kÓ"2Õ2°Hô	>à ŒØ&Ör.   )r_   r…   r)   re   rn   s   @@r,   r€   r€   î  s   ù‡ € ÙO÷'÷ 'r.   r€   c                   ó6   a a€ ] tR tRt oRtV 3R ltRtVtV ;t# )ÚUnexpectedDataErroriø  zDraised when parsing is strict (=not relaxed) and data is unexpected c                ó”  <€ \        V\        4      '       d   R P                  V4      pMc\        V\        4      '       d+   RP	                  R V 4       4      pRP                  V4      pM#\        RP                  \        V4      4      4      h\        \        V `'  RP                  WWT4      4       Wn
        W n        W0n        W@n        R# )ú{0:04X}Ú,c              3   óD   "  € T F  pR P                  V4      x € K  	  R# 5i)rŠ   Nr5   )r7   Úes   & r,   r9   Ú/UnexpectedDataError.__init__.<locals>.<genexpr>ÿ  s   é € Ð@±x°!˜)×*Ñ*¨1×-Ð-³xùr;   z({0})zUnknown type encountered: {0}zIUnexpected value in {0} for variable {1}: expected {2} but found {3:04X}!N)r<   Úintr6   Útupler>   Ú
ValueErrorÚtyper\   rˆ   r]   Ústream_pathÚvariableÚexpectedÚvalue)ra   r“   r”   r•   r–   Úesrc   s   &&&&& €r,   r]   ÚUnexpectedDataError.__init__û  s¢   ø€ Ü�h¤×$Ò$Ø×!Ñ! (Ó+‰BÜ˜¤%×(Ò(Ø—‘Ñ@±xÓ@Ó@ˆBØ—.‘. Ó$‰BäÐ<×CÑCÄDÈÃNÓSÓTÐTÜÔ! 4Ñ1ð.ç‰V�K¨2Ó5ô	7ð 'ÔØ ŒØ ŒØŽ
r.   )r•   r“   r–   r”   re   rn   s   @@r,   rˆ   rˆ   ø  s   ù‡ € ÙO÷õ r.   rˆ   i'  z	mac-romani'  Úshiftjisi'  Úasciii'  Úgb2321i'  Úbig5i'  Úhebrewi'  z
mac-arabici'  z	mac-greekia'  zmac-turkishi%'  Úthaii-'  Úmaccentraleuropei'  z,https://github.com/decalage2/oletools/issueszPlease report this issue on %sÚOLEÚOpenXMLÚFlatOPC_XMLÚWord2003_XMLÚMHTMLÚTextÚPPTÚSLKzOLE:zOpX:zFlX:zXML:zMHT:zTXT:zPPT:zSLK:s
   ActiveMimeÚbasÚclsÚfrmz6{http://schemas.microsoft.com/office/word/2003/wordml}ÚbinDataÚnamez5{http://schemas.microsoft.com/office/2006/xmlPackage}ÚpackageÚpartÚcontentTypez$application/vnd.ms-office.vbaProjectÚ
binaryDataz%Runs when the Word document is openedz%Runs when the Word document is closedz'Runs when the Word document is modifiedz(Runs when a new Word document is createdz2Runs when the Word or Publisher document is openedz*Runs when the Publisher document is closedz&Runs when the Excel Workbook is openedz&Runs when the Excel Workbook is closedz)May run when an Excel WorkSheet is openedz>Runs when the file is opened (using InkPicture ActiveX object)z?Runs when the file is opened and ActiveX objects trigger eventsz%May read system environment variablesÚEnvironzMay open a filez+May write to a file (if combined with Open)z7May read or write a binary file (if combined with Open)zMay copy a filezMay move a filezMay delete a filezMay create a text filez.May run an executable file or a system commandzMay run a dllz0May execute file or a system command through WMIz7May run an executable file or a system command on a MaczMay run PowerShell commandsz?May run an executable file or a system command using PowerShellz-May call a DLL using Excel 4 Macros (XLM/XLF)zMay hide the applicationzMay create a directoryzMay save the current workbookz<May change which directory contains files to open at startupzMay create an OLE objectz-May get an OLE object with a running instancez)May create an OLE object using PowerShellz6May run an application (if combined with CreateObject)z/May run an Excel 4 Macro (aka XLM/XLF) from VBAzMMay enumerate application windows (if combined with Shell.Application object)zMay run code from a DLLz$May run code from a library on a Macz$May inject code into another processzMay run a shellcode in memoryz$May download files from the Internetz5May download files from the Internet using PowerShellz=May control another application by simulating user keystrokesz1May attempt to obfuscate malicious function callszMMay attempt to obfuscate specific strings (use option --deobf to deobfuscate)ÚChrÚ
StrReversezMay read or write registry keyszMay read registry keyszMay detect virtualizationzMay detect Anubis SandboxzMay detect SandboxiezMay detect Sunbelt SandboxzMay detect Norman SandboxzMay detect CW SandboxzMay detect WinJail Sandboxz<May attempt to disable VBA macro security and Protected Viewz6May attempt to modify the VBA code (self-modification)z6May modify Excel 4 Macro formulas at runtime (XLM/XLF)z6May use Word Document Variables to store and hide datazUMay run an executable file or a system command on a Mac (if combined with libc.dylib)zMMay run an executable file or a system command using Excel 4 Macros (XLM/XLF)zqCould contain a function that allows to run an executable file or a system command using Excel 4 Macros (XLM/XLF)zQCould contain a function that allows to call a DLL using Excel 4 Macros (XLM/XLF)zZMay use special characters such as backspace to obfuscate code when printed on the consoleÚz\b(?:http|ftp)s?z((?:xn--[a-zA-Z0-9]{4,20}|[a-zA-Z]{2,20})z(?:[a-zA-Z0-9\-\.]+\.Ú)z2(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])z(?:z\.){3}Ú|z(?:\:[0-9]{1,5})?z*(?:/[a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~]*)?z\://z"http://schemas.openxmlformats.org/zhttp://schemas.microsoft.com/ÚURLzIPv4 addresszE-mail addressz(?i)\b[A-Z0-9._%+-]+@zExecutable file namezœ(?i)\b\w+\.(EXE|PIF|GADGET|MSI|MSP|MSC|VBS|VBE|VB|JSE|JS|WSF|WSC|WSH|WS|BAT|CMD|DLL|SCR|HTA|CPL|CLASS|JAR|PS1XML|PS1|PS2XML|PS2|PSC1|PSC2|SCF|LNK|INF|REG)\bz(?:[0-9A-Fa-f]{2}){4,}zV(?:[A-Za-z0-9+/]{4}){1,}(?:[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=|[A-Za-z0-9+/][AQgw]==)?Ú"z"[0-9A-Za-z]{20,}"z[G-Zg-z]s   [\t\r\n\x20-\xFF]{5,}Ú_c                   ó   € ] tR tRtRtRtR# )ÚVbaExpressionStringi�  a;  
Class identical to str, used to distinguish plain strings from strings
obfuscated using VBA expressions (Chr, StrReverse, etc)
Usage: each VBA expression parse action should convert strings to
VbaExpressionString.
Then isinstance(s, VbaExpressionString) is True only for VBA expressions.
 (see detect_vba_strings)
r*   N)rf   rg   rh   ri   rj   rk   r*   r.   r,   r»   r»   �  s   † ñó 	r.   r»   Ú-z%&^)Úexactc                 ó&   € \        V ^ ,          4      # ©é    ©r�   ©Úts   &r,   Ú<lambda>rÄ   ½  s   € ¬¨Q¨q­T¬r.   Ú&Úoz[0-7]c                 ó*   € \        V ^ ,          ^R7      # ©rÀ   )ÚbaserÁ   rÂ   s   &r,   rÄ   rÄ   Á  s   € ¤s¨1¨Q­4°aÕ'8r.   z&hz[0-9a-fA-F]c                 ó*   € \        V ^ ,          ^R7      # rÈ   rÁ   rÂ   s   &r,   rÄ   rÄ   Å  s   € ¤S¨¨1­°BÕ%7r.   ú"")ÚescQuotec                 ó&   € \        V ^ ,          4      # r¿   ©r„   rÂ   s   &r,   rÄ   rÄ   Ò  s   € ¤s¨1¨Q­4¤yr.   ÚBÚWÚ$Ú(c                 ó   €  V ^ ,          pV^ 8¼  d   V^ÿ8:  d   \        \        V4      4      # \        \        V4      P                  RR4      4      #   \         d2    \
        P                  RX,          4       \        RT,          4      u # i ; i)rÀ   zutf-8r1   z.ERROR: incorrect parameter value for chr(): %rzChr(%r))r»   ÚchrÚunichrrK   r‘   rU   Ú	exception)rÃ   Úis   & r,   Úvba_chr_tostrrØ     s}   € ð2Øˆa�DˆØˆaŒ4�A�s”Fô '¤s¨1£vÓ.Ð.ô
 '¤v¨a£y×'7Ñ'7¸ÐASÓ'TÓUÐUøÜô 2Ü�‰ÐFÈÕJÔKÜ" 9¨q¥=Ó1Ò1ð2ús   ‚*A ­#A Á9BÂBÚAscc                 ó&   € \        V ^ ,          4      # r¿   )ÚordrÂ   s   &r,   rÄ   rÄ   +  s   € ¤ Q q¥T¤r.   ÚValc                 óB   € \        V ^ ,          P                  4       4      # r¿   )r�   ÚstriprÂ   s   &r,   rÄ   rÄ   3  s   € ¤ Q q¥T§Z¡Z£\Ô!2r.   c                 óL   € \        \        V ^ ,          4      RRR1,          4      # )rÀ   Néÿÿÿÿ)r»   r„   rÂ   s   &r,   rÄ   rÄ   :  s   € Ô$7¼¸A¸a½D»	Á$ÀBÀ$½Ô$Hr.   c                 ó4   € \        R V ^ ,          ,          4      # )z%%%s%%)r»   rÂ   s   &r,   rÄ   rÄ   A  s   € Ô!4°XÀÀ!Åµ_Ô!Er.   )Ú	initCharsÚ	bodyCharsc                 ó&   € \        V ^ ,          4      # r¿   rÎ   rÂ   s   &r,   rÄ   rÄ   T  s   € ¬3¨q°­t¬9r.   Ú
hex_stringc                 óT   € \        \        P                  ! V P                  4      4      # r)   )r»   ÚbinasciiÚa2b_hexrå   rÂ   s   &r,   rÄ   rÄ   X  s   € Ô+>¼x×?OÒ?OÐPQ×P\ÑP\Ó?]Ô+^r.   c                 ó&   € \        V ^ ,          4      # r¿   rÎ   rÂ   s   &r,   rÄ   rÄ   b  s   € ¬c°!°Aµ$¬ir.   Úbase64_stringc                 óT   € \        \        P                  ! V P                  4      4      # r)   )r»   rç   Ú
a2b_base64rê   rÂ   s   &r,   rÄ   rÄ   f  s   € Ô.AÄ(×BUÒBUÐVW×VeÑVeÓBfÔ.gr.   c                óV   € V ^ ,          R,          p\        RP                  V4      4      # )zS
parse action to concatenate strings in a VBA expression with operators '+' or '&'
ºNNé   r3   )r»   r>   )ÚtokensÚstringss   & r,   Úconcat_strings_listrò   k  s%   € ð �Q�i˜�n€GÜ˜rŸw™w wÓ/Ó0Ð0r.   Ú+c                ó8   € V ^ ,          R,          p\        V4      # )zD
parse action to sum integers in a VBA expression with operator '+'
rî   )Úsum©rð   Úintegerss   & r,   Úsum_ints_listrø   €  s   € ð �a�y˜�~€HÜˆx‹=Ðr.   c                ó<   € V ^ ,          R,          p\        R V4      # )zI
parse action to subtract integers in a VBA expression with operator '-'
rî   c                 ó   € W,
          # r)   r*   ©r+   Úys   &&r,   rÄ   Ú$subtract_ints_list.<locals>.<lambda>’  ó   € ˜QžSr.   r/   rö   s   & r,   Úsubtract_ints_listrÿ   Š  s   € ð �a�y˜�~€Hä‘. (Ó+Ð+r.   c                ó<   € V ^ ,          R,          p\        R V4      # )zI
parse action to multiply integers in a VBA expression with operator '*'
rî   c                 ó   € W,          # r)   r*   rû   s   &&r,   rÄ   Ú$multiply_ints_list.<locals>.<lambda>œ  rþ   r.   r/   rö   s   & r,   Úmultiply_ints_listr  •  ó   € ð �a�y˜�~€HÜ‘. (Ó+Ð+r.   c                ó<   € V ^ ,          R,          p\        R V4      # )zG
parse action to divide integers in a VBA expression with operator '/'
rî   c                 ó   € W,          # r)   r*   rû   s   &&r,   rÄ   Ú"divide_ints_list.<locals>.<lambda>¦  rþ   r.   r/   rö   s   & r,   Údivide_ints_listr  Ÿ  r  r.   Ú*rƒ   c                ó,   € V P                  \        4      # )a„  
Check if the provided data is the content of a MSO/ActiveMime file, such as
the ones created by Outlook in some cases, or Word/Excel when saving a
file with the MHTML format or the Word 2003 XML format.
This function only checks the ActiveMime magic at the beginning of data.
:param data: bytes string, MSO/ActiveMime file content
:return: bool, True if the file is MSO, False otherwise
)Ú
startswithÚMSO_ACTIVEMIME_HEADER©Údatas   &r,   Úis_mso_filer  »  s   € ð �?‰?Ô0Ó1Ð1r.   r+   c           	     óx  € \        V 4      '       g   Q h^2R.p \        P                  ! RV ^R7      ^ ,          ^.,           p\        P	                  RV,          4       VP                  ^ V4       T F:  p \        P	                  RT,          4       \        P                  ! YR
 4      pTu # 	  \        P	                  R4       \        P                  T 4       FJ  pTP                  4       p \        P	                  RT,          4       \        P                  ! YR
 4      pTu # 	  \        R4      h  \        P                   dD   p\        P                  RT,          4       \        P	                  RRR7       \        R	4      hR
p?ii ; i  \        P                   dB   p\        P                  RT: RT: R24       \        P	                  RRR7        R
p?EKm  R
p?ii ; i  \        P                   d@   p\        P                  RT,          4       \        P	                  RRR7        R
p?EK\  R
p?ii ; i)ae  
Extract the data stored into a MSO/ActiveMime file, such as
the ones created by Outlook in some cases, or Word/Excel when saving a
file with the MHTML format or the Word 2003 XML format.

:param data: bytes string, MSO/ActiveMime file content
:return: bytes string, extracted data (uncompressed)

raise a MsoExtractionError if the data cannot be extracted
i*  ú<H)Úoffsetz$Parsing MSO file: data offset = 0x%Xz/Unable to parse MSO/ActiveMime file header (%s)úTrace:T©Úexc_infoz*Unable to parse MSO/ActiveMime file headerNz7Attempting zlib decompression from MSO file offset 0x%Xz%zlib decompression failed for offset ú (rµ   z8Looking for potential zlib-compressed blocks in MSO filezzlib decompression failed (%s)z4Unable to decompress data from a MSO/ActiveMime file)r  ÚstructÚunpack_fromrU   ÚdebugÚinsertÚerrorÚinforz   ÚzlibÚ
decompressÚre_zlib_headerÚfinditerr@   )r  Úoffsetsr  rC   r@   Úextracted_dataÚmatchs   &      r,   Úmso_file_extractr$  Ë  sË  € ô �t×ÒÐÐð
 �Uˆm€Gð
OÜ×#Ò# D¨$°tÔ<¸QÕ?À"ÕDˆÜ�	‰	Ð8¸6ÕAÔBØ�‰�q˜&Ô!ó ˆð	/Ü�I‰IÐOÐRWÕWÔXÜ!Ÿ_š_¨T°&¨\Ó:ˆNØ!Ò!ñ	 ô ‡I�IÐHÔIÜ×(Ñ(¨Ö.ˆØ—‘“ˆð	/Ü�I‰IÐOÐRWÕWÔXÜ!Ÿ_š_¨T°&¨\Ó:ˆNØ!Ò!ñ /ô ÐSÓ
TÐTøô5 �<‰<ô OÜ�‰ÐBÀSÕHÔIÜ�	‰	�( Tˆ	Ô*Ü Ð!MÓNÐNûðOûô �z‰zô 	/Ü�HŠHÛ›sð$ô %ä�I‰I�h¨ˆI×.Ó.ûð	/ûô �z‰zô 	/Ü�H‰HÐ5¸Õ;Ô<Ü�I‰I�h¨ˆI×.Ó.ûð	/úsH   ™AD1 Á45FÃ,5G%Ä1F	Å>FÆF	ÆG"Æ!5GÇG"Ç%H9Ç:3H4È4H9c                ó>   € \        V 4      P                  \        4      # )zÃ
returns True if string s only contains printable ASCII characters
(i.e. contained in string.printable)
This is similar to Python 3's str.isprintable, for Python 2.x.
:param s: str
:return: bool
)ÚsetÚissubsetÚ_PRINTABLE_SET)Úss   &r,   Úis_printabler*    s   € ô ˆq‹6�?‰?œ>Ó*Ð*r.   c                óÔ   € W,
          p\        \        P                  ! \        P                  ! V^4      4      4      p\	        V^.4      pRV,	          pV( pRV,	          ^,           pWEW63# )aF  
compute bit masks to decode a CopyToken according to MS-OVBA 2.4.1.3.19.1 CopyToken Help

decompressed_current: number of decompressed bytes so far, i.e. len(decompressed_container)
decompressed_chunk_start: offset of the current chunk in the decompressed container
return length_mask, offset_mask, bit_count, maximum_length
iÿÿ  )r�   ÚmathÚceilrU   Úmax)Údecompressed_currentÚdecompressed_chunk_startÚ
differenceÚ	bit_countÚlength_maskÚoffset_maskÚmaximum_lengths   &&     r,   Úcopytoken_helpr6    sc   € ð &Õ@€JÜ”D—I’IœdŸhšh z°1Ó5Ó6Ó7€IÜ�Y �NÓ#€IØ˜IÕ%€KØ�,€KØ 	Õ)¨QÕ.€NØ YÐ>Ð>r.   c                ój  € \        V \        4      '       g   \        V 4      p \        P                  RP	                  \        V 4      4      4       \        4       p^ pW,          pV^8w  d   \        RP	                  V4      4      hV^,          pV\        V 4      8  Ed�   Tp\        P                  ! RWV^,            4      ^ ,          pVR,          ^,           pV^,	          ^,          pV^8w  d   \        R4      hV^,	          ^,          p\        P                  RP	                  WdV4      4       V^8X  d   VR8”  d   \        RV,          4      hV^ 8X  d   VR8w  d   \        R	V,          4      hWF,           \        V 4      8”  d   \        P                  R
4       \        \        V 4      WF,           .4      p	V^,           pV^ 8X  d'   VP                  WVR,            4       VR,          pEK^  \        V4      p
W)8  g   EKr  W,          pV^,          p\        ^ ^4       EF  pW)8¼  d    K3  W¼,	          ^,          pV^ 8X  d$   VP                  W,          .4       V^,          pKF  \        P                  ! RWV^,            4      ^ ,          p\        \        V4      V
4      w  ppppWï,          ^,           pVV,          p^V,
          pVV,	          ^,           p\        V4      V,
          p\        VVV,           4       F  pVP                  VV,          .4       K  	  V^,          pEK	  	  EK4  \        V4      # )zû
Decompress a stream according to MS-OVBA section 2.4.1

:param compressed_container bytearray: bytearray or bytes compressed according to the MS-OVBA 2.4.1.3.6 Compression algorithm
:return: the decompressed container as a bytes string
:rtype: bytes
z-decompress_stream: compressed size = {} byteszinvalid signature byte {0:02X}r  iÿ  z9Invalid CompressedChunkSignature in VBA compressed streamz2chunk size = {}, offset = {}, compressed flag = {}i  z:CompressedChunkSize=%d > 4098 but CompressedChunkFlag == 1z;CompressedChunkSize=%d != 4098 but CompressedChunkFlag == 0z3Chunk size is larger than remaining compressed datai   )r<   Ú	bytearrayrU   r  r6   Úlenr‘   r  ÚunpackÚwarningÚminÚextendÚxranger6  Úbytes)Úcompressed_containerÚdecompressed_containerÚcompressed_currentÚsig_byteÚcompressed_chunk_startÚcompressed_chunk_headerÚ
chunk_sizeÚchunk_signatureÚ
chunk_flagÚcompressed_endr0  Ú	flag_byteÚ	bit_indexÚflag_bitÚ
copy_tokenr3  r4  r2  r¹   ÚlengthÚtemp1Útemp2r  Úcopy_sourceÚindexs   &                        r,   Údecompress_streamrS  %  s  € ô: Ð*¬I×6Ò6Ü(Ð)=Ó>Ðä‡I�IÐ=×DÑDÄSÐI]ÓE^Ó_Ô`Ü&›[ÐØÐà#Õ7€HØ�4ÔÜÐ9×@Ñ@ÀÓJÓKÐKà˜!ÕÐð œsÐ#7Ó8Õ
8à!3Ðô �MŠM˜$Ð 4ÐLbÐefÕLfÐ gÓhÐijÕkð 	 ð .°Õ6¸!Õ;ˆ
à2°bÕ8¸DÕ@ˆØ˜eÔ#ÜÐXÓYÐYà-°Õ3°tÕ;ˆ
Ü�	‰	ÐF×MÑMÈjÐr|Ó}Ô~ð ˜Œ?˜z¨DÔ0ÜÐYÐ\fÕfÓgÐgØ˜Œ?˜z¨TÔ1ÜÐZÐ]gÕgÓhÐhð "Õ.´Ð5IÓ1JÔJÜ�K‰KÐMÔNÜœcÐ"6Ó7Ð9OÕ9\Ð]Ó^ˆà3°aÕ7Ðà˜Œ?ð #×)Ñ)Ð*>ÐRdÐgkÕRkÐ*lÔmØ $Õ&Óô (+Ð+AÓ'BÐ$Ø$×5ð
 1ÕD�	Ø" aÕ'Ð"ä!'¨¨1§�Ià)Ô;Úð !*Õ 6¸!Õ;�Hà 1”}à.×5Ñ5Ð7KÕ7_Ð6`ÔaØ*¨aÕ/Ò*ô #ŸMšM¨$Ð0DÐXjÐmnÕXnÐ0oÓpÐqrÕsð #ô BPÜÐ 6Ó7Ð9QóBSÑ>˜ [°)¸Qà",Õ":¸aÕ!?˜Ø *¨[Õ 8˜Ø " Y¥˜Ø"'¨5¥.°AÕ!5˜ä&)Ð*@Ó&AÀFÕ&J˜Ü%+¨K¸ÀvÕ9MÖ%N˜EØ2×9Ñ9Ð;QÐRWÕ;XÐ:YÖZñ &Oà*¨aÕ/Ó*ô7 ".ô8 Ð'Ó(Ð(r.   c                   ó*   a € ] tR tRt o RtR tRtV tR# )Ú
VBA_Modulei¤  zp
Class to parse a VBA module from an OLE file, and to store all the corresponding
metadata and VBA source code.
c           	     ó�  € Wn         RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n	        RV n
        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n         \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP-                  R^V4       \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP+                  V4      pVP/                  V4      V n        \1        V P                  4      V n        \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^G8X  d�   \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP+                  V4      P3                  RR4      V n        \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^8X  Ed/   \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP+                  V4      pVP/                  V4      V n        \1        V P                  4      V n        \&        P(                  ! RVP+                  ^4      4      ^ ,          p	VP-                  R^2V	4       \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP+                  V4      P3                  RR4      V n        \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^8X  Ed   \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP+                  V4      p
VP/                  V
4      V n        \&        P(                  ! RVP+                  ^4      4      ^ ,          p	VP-                  R	^HV	4       \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP+                  V4      V n        \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^18X  d    \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP-                  R
^V4       \&        P(                  ! RVP+                  ^4      4      ^ ,          V n	        \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^8X  d›   \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP-                  R^V4       \&        P(                  ! RVP+                  ^4      4      ^ ,          p\&        P(                  ! RVP+                  ^4      4      ^ ,          pV^,8X  d›   \&        P(                  ! RVP+                  ^4      4      ^ ,          pVP-                  R^V4       \&        P(                  ! RVP+                  ^4      4      ^ ,          p\&        P(                  ! RVP+                  ^4      4      ^ ,          pV^!8X  g   V^"8X  da   Wpn
        \&        P(                  ! RVP+                  ^4      4      ^ ,          p	\&        P(                  ! RVP+                  ^4      4      ^ ,          pV^%8X  du   RV n        \&        P(                  ! RVP+                  ^4      4      ^ ,          p	VP-                  R^ V	4       \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^(8X  du   RV n        \&        P(                  ! RVP+                  ^4      4      ^ ,          p	VP-                  R^ V	4       \&        P(                  ! RVP+                  ^4      4      ^ ,          pV^+8X  dC   \&        P(                  ! RVP+                  ^4      4      ^ ,          p	VP-                  R^ V	4       RpVR8w  d%   \4        P7                  RP9                  V4      4       \4        P;                  RP9                  V P                  4      4       \4        P;                  RP9                  V P
                  4      4       \4        P;                  RP9                  V P                  4      4       RpV P                  V P                  V P                  V P                  3pV F‚  pVf   K	   VP<                  R,           V,           V n        \4        P;                  RV P$                  ,          4       VP>                  PA                  V P$                  4      P+                  4       p M	  Vfp   \4        PE                  RW1PF                  RPI                  R V 4       4      3,          4       VPJ                  '       d   R# \M        RRV P                  ,           4      h\4        P;                  RP9                  \O        V4      4      4       \4        P;                  RP9                  V P                  4      4       WàP                  R p\O        V4      ^ 8”  dô   \Q        \S        V4      4      pWàn        VP/                  V4      V n        \1        V P                  4      V n        V P                   PT                  PW                  V P                  PY                  4       R 4      pR!P9                  V P                  V4      V n        \1        V P                   4      V n        \4        P;                  R"P9                  V P"                  4      4       R# \4        P7                  R#P9                  V P
                  4      4       R#   \B         d+   p\4        P;                  RT: RT: R24        Rp?EKÅ  Rp?ii ; i  \Z        \L        3 d    h \\         d7   p\4        PE                  R$P9                  Y1PF                  4      RR%7       h Rp?ii ; i)&a]  
Parse a VBA Module record from the dir stream of a VBA project.
Reference: MS-OVBA 2.3.4.2.3.2 MODULE Record

:param VBA_Project project: VBA_Project, corresponding VBA project
:param olefile.OleStream dir_stream: olefile.OleStream, file object containing the module record
:param int module_index: int, index of the module in the VBA project list
NFr  ÚMODULENAME_Idú<LzUTF-16LErG   ÚMODULESTREAMNAME_ReservedÚMODULEDOCSTRING_ReservedÚMODULEOFFSET_SizeÚMODULEHELPCONTEXT_SizeÚMODULECOOKIE_SizeTÚMODULEREADONLY_ReservedÚMODULEPRIVATE_ReservedÚMODULE_Reservedz,unknown or invalid module section id {0:04X}zModule Name = {0}zStream Name = {0}zTextOffset = {0}zVBA/zopening VBA code stream %szfailed to open stream VBA/r  z), try other namez4Could not open stream %d of %d ('VBA/' + one of %r)!rƒ   c              3   óB   "  € T F  pR V,           R ,           x € K  	  R# 5i)Ú'Nr*   )r7   Ústream_names   & r,   r9   Ú&VBA_Module.__init__.<locals>.<genexpr>R  s%   é € ð %CÙ8A¨ð &)¨;Õ%6¸×%<Ò%<Û8Aùs   ‚z[BASE]zlength of code_data = {0}zoffset of code_data = {0}Úvbaz{0}.{1}zextracted file {0}z(module stream {0} has code data length 0z Error parsing module {0} of {1}:r  )/Úprojectr¬   Úname_strÚ_name_unicodeÚ
streamnameÚstreamname_strÚ_streamname_unicodeÚ	docstringÚ_docstring_unicodeÚ
textoffsetr’   ÚreadonlyÚprivateÚcode_rawÚcodeÚcode_strr_   Úfilename_strÚ	code_pathr  r:  ÚreadÚcheck_valueÚdecode_bytesrM   rO   rU   r;  r6   r  Úvba_rootÚoleÚ
openstreamÚIOErrorr  Úmodules_countr>   Úrelaxedr€   r9  rS  r8  Ú
module_extÚgetÚlowerrˆ   Ú	Exception)ra   rf  Ú
dir_streamÚmodule_indexÚ_idÚsizeÚmodulename_bytesÚ
section_idÚstreamname_bytesÚreservedÚdocstring_bytesÚmodulehelpcontext_sizeÚhelpcontextÚcookieÚ	code_dataÚ	try_namesrc  ÚioeÚfilextrC   s   &&&&                r,   r]   ÚVBA_Module.__init__ª  s	  € ð ŒàˆŒ	àˆŒà!ˆÔàˆŒà"ˆÔØ#'ˆÔ ØˆŒØ"&ˆÔØˆŒØˆŒ	ØˆŒØˆŒàˆŒàˆŒ	àˆŒàˆŒà ˆÔØˆŒðb	ô —-’-  j§o¡o°aÓ&8Ó9¸!Õ<ˆCØ×Ñ °¸Ô=Ü—=’=  z§¡°qÓ'9Ó:¸1Õ=ˆDØ)Ÿ™¨tÓ4Ðà×,Ñ,Ð-=Ó>ˆDŒIÜ'¨¯	©	Ó2ˆDŒMô  Ÿš t¨Z¯_©_¸QÓ-?Ó@ÀÕCˆJØ˜VÔ#ô —}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø%/§_¡_°TÓ%:×%AÑ%AÀ*ÈiÓ%X�Ô"Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÕ#ô —}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø#-§?¡?°4Ó#8Ð à")×"6Ñ"6Ð7GÓ"H�”Ü&1°$·/±/Ó&B�Ô#Ü!Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕE�Ø×#Ñ#Ð$?ÀÈÔRÜ—}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø+5¯?©?¸4Ó+@×+GÑ+GÈ
ÐT]Ó+^�Ô(Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÕ#ô —}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø",§/¡/°$Ó"7�Ø!(×!5Ñ!5°oÓ!F�”Ü!Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕE�Ø×#Ñ#Ð$>ÀÈÔQÜ—}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø*4¯/©/¸$Ó*?�Ô'Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ#ô —}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø×#Ñ#Ð$7¸ÀÔFÜ"(§-¢-°°j·o±oÀaÓ6HÓ"IÈ!Õ"L�”Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ#ô *0¯ª°t¸Z¿_¹_ÈQÓ=OÓ)PÐQRÕ)SÐ&Ø×#Ñ#Ð$<¸fÐF\Ô]ô %Ÿmšm¨D°*·/±/À!Ó2DÓEÀaÕH�Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ#ô —}’} T¨:¯?©?¸1Ó+=Ó>¸qÕA�Ø×#Ñ#Ð$7¸ÀÔFÜŸš t¨Z¯_©_¸QÓ-?Ó@ÀÕC�Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ# z°VÔ';ð '”	Ü!Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕE�Ü#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ#ð !%�”Ü!Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕE�Ø×#Ñ#Ð$=¸vÀxÔPÜ#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ#ð  $�”Ü!Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕE�Ø×#Ñ#Ð$<¸fÀhÔOÜ#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕG�
Ø˜VÔ#ô "Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕE�Ø×#Ñ#Ð$5°v¸xÔHØ!�
Ø˜TÔ!Ü—‘ÐJ×QÑQÐR\Ó]Ô^ä�I‰IÐ)×0Ñ0°·±Ó?Ô@ä�I‰IÐ)×0Ñ0°×1DÑ1DÓEÔFä�I‰IÐ(×/Ñ/°·±Ó@ÔAàˆIàŸ™¨$×*BÑ*BÀDÇIÁIÈt×OaÑOaÐbˆIÛ(�ð Ô*ð8Ø)0×)9Ñ)9¸GÕ)CÀkÕ)Q˜œÜŸ	™	Ð">ÀÇÁÕ"OÔPØ$+§K¡K×$:Ñ$:¸4¿>¹>Ó$J×$OÑ$OÓ$Q˜	Ùñ  )ð Ò Ü—‘ÐOØ(×*?Ñ*?ØŸH™Hñ %CÙ8Aó%Có CðDõDô Eð —?—?�?Ùä,¨X°vÀÇ	Á	Õ7IÓJÐJä�I‰IÐ1×8Ñ8¼¸Y»ÓHÔIÜ�I‰IÐ1×8Ñ8¸¿¹ÓIÔJØ!§/¡/Ð"2Ð3ˆIÜ�9‹~ Ô!Ü-¬i¸	Ó.BÓC�	à )”à#×0Ñ0°Ó;�”	ä +¨D¯I©IÓ 6�”àŸ™×0Ñ0×4Ñ4°T·Y±Y·_±_Ó5FÈÓN�Ø *× 1Ñ 1°$·)±)¸VÓ D�”Ü$/°·±Ó$>�Ô!Ü—	‘	Ð.×5Ñ5°d×6GÑ6GÓHÖIä—‘ÐF×MÑMÈd×NaÑNaÓbÖcøô? #ô 8ÜŸ	š	Û%0³#ð#7÷ 8ó 8ûð8ûô@ $Ô%7Ð8ô 	ØÜô 	Ü�H‰HÐ7ß‘f˜\×+@Ñ+@ÓAØ"ð ô $ð
 ûð	úsX   Â`$m3 â0A8l;ä(Am3 æFm3 ì.m3 ì;m0ím+í$m3 í+m0í0m3 í3oîoî1o ï o)rm  rh  rk  rr  ru  rq  rs  rl  r_   rt  r¬   rg  rp  rf  ro  ri  rj  rn  r’   Nr}   r~   s   @r,   rU  rU  ¤  s   ø‡ € ñ÷
Ið Ir.   rU  c                   óJ   a € ] tR tRt o RtR
R ltR tR tR tRR lt	Rt
V tR	# )ÚVBA_Projectix  zm
Class to parse a VBA project from an OLE file, and to store all the corresponding
metadata and VBA modules.
c                ó&+  € Wn         W n        W0n        W@n        WPn        . V n        / V n        \        P                  RV,          4       VP                  V4      P                  4       p\        \        \        V4      4      4      pWpn        \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          p	V P#                  R^V	4       \        P                   ! RVP                  ^4      4      ^ ,          V n        ^ R^R^R^R	/p
V
P'                  V P$                  R
4      V n        \        P                  RV P$                  V P(                  3,          4       V P$                  V
9  d/   \        P+                  RP-                  V P$                  4      4       \        P                   ! RVP                  ^4      4      ^ ,          pV^J8X  dÕ   TpV P#                  R^JV4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          p\        P                  RP-                  VR7      4       \        P                   ! RVP                  ^4      4      ^ ,          pTpV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          V n        V P#                  RRV P.                  4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          V n        V P#                  RRV P0                  4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          V n        \4        P6                  ! V P2                  4      V n        \        P                  RV P2                  : RV P8                  : 24       \4        P:                  ! V P2                  4      V n        \        P                  RV P2                  V P<                  3,          4       \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R^V4       \        P                   ! RVP                  ^4      4      ^ ,          p\        P                  RV,          4       V^8  g   V^€8”  d%   \        P+                  RP-                  V4      4       VP                  V4      pV P?                  V4      V n         \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R ^V4       \        P                   ! RVP                  ^4      4      ^ ,          pVR!8”  d%   \        P+                  R"P-                  V4      4       VP                  V4      pV P?                  V4      V n!        \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R#^@V4       \        P                   ! RVP                  ^4      4      ^ ,          pV^,          ^ 8w  d   \        P+                  R$4       VP                  V4      pVPE                  R%R&R'7      V n#        \        P                   ! RVP                  ^4      4      ^ ,          pV P#                  R(^V4       \        P                   ! RVP                  ^4      4      ^ ,          pVR)8”  d%   \        P+                  R*P-                  V4      4       VP                  V4      p \        P                   ! RVP                  ^4      4      ^ ,          p!V P#                  R+^=V!4       \        P                   ! RVP                  ^4      4      ^ ,          p"V"V8w  d   \        P+                  R,4       VP                  V"4      p#V#V 8w  d   \        P+                  R-4       \        P                   ! RVP                  ^4      4      ^ ,          p$V P#                  R.^V$4       \        P                   ! RVP                  ^4      4      ^ ,          p%V P#                  R/^V%4       \        P                   ! RVP                  ^4      4      ^ ,          p&T&p'\        P                   ! RVP                  ^4      4      ^ ,          p(V P#                  R0^V(4       \        P                   ! RVP                  ^4      4      ^ ,          p)V P#                  R1^V)4       \        P                   ! RVP                  ^4      4      ^ ,          p*V P#                  R2^ V*4       \        P                   ! RVP                  ^4      4      ^ ,          p+V P#                  R3^	V+4       \        P                   ! RVP                  ^4      4      ^ ,          p,V P#                  R4^V,4       \        P                   ! RVP                  ^4      4      ^ ,          p-\        P                   ! RVP                  ^4      4      ^ ,          p.T-p'T.p'\        P                   ! RVP                  ^4      4      ^ ,          p/V P#                  R5^V/4       \        P                   ! RVP                  ^4      4      ^ ,          p0V0R68”  d%   \        P+                  R7P-                  V04      4       VP                  V04      p1\        P                   ! RVP                  ^4      4      ^ ,          p2V P#                  R8^<V24       \        P                   ! RVP                  ^4      4      ^ ,          p3V3^,          ^ 8w  d   \        P+                  R94       VP                  V34      p4T1p'T4p'R:p5 \        P                   ! RVP                  ^4      4      ^ ,          p5\        P                  R;P-                  V54      4       V5^8X  d   R:# V5^8X  Ed   T5p6\        P                   ! RVP                  ^4      4      ^ ,          p7VP                  V74      p8\        P                  R<\I        V P?                  V84      4      ,          4       \        P                   ! RVP                  ^4      4      ^ ,          p9V9^>8X  dH   \        P                   ! RVP                  ^4      4      ^ ,          p:VP                  V:4      p;T6p'T8p'T;p'EKR  T9p5\        P                  R;P-                  V54      4       V5^38X  d|   T5p<\        P                   ! RVP                  ^4      4      ^ ,          p=VP                  V=4      p>\        P                  R=\I        V P?                  V>4      4      ,          4       T<p'T>p'EKú  V5^/8X  Ed¡   T5p?\        P                   ! RVP                  ^4      4      ^ ,          p@\        P                   ! RVP                  ^4      4      ^ ,          pAVP                  VA4      pB\        P                  R>\I        V P?                  VB4      4      ,          4       \        P                   ! RVP                  ^4      4      ^ ,          pCV P#                  R?^ VC4       \        P                   ! RVP                  ^4      4      ^ ,          pDV P#                  R@^ VD4       T?p'T@p'TBp'\        P                   ! RVP                  ^4      4      ^ ,          pEVE^8X  Ed   T5pF\        P                   ! RVP                  ^4      4      ^ ,          pGVP                  VG4      pH\        P                  RA\I        V P?                  VH4      4      ,          4       \        P                   ! RVP                  ^4      4      ^ ,          pIVI^>8X  ds   \        P                   ! RVP                  ^4      4      ^ ,          pJVP                  VJ4      pK\        P                   ! RVP                  ^4      4      ^ ,          pLXFp'XHp'TKp'MXIpLMXEpLV P#                  RB^0XL4       \        P                   ! RVP                  ^4      4      ^ ,          pM\        P                   ! RVP                  ^4      4      ^ ,          pNVP                  VN4      pO\        P                   ! RVP                  ^4      4      ^ ,          pP\        P                   ! RVP                  ^4      4      ^ ,          pQVP                  ^4      pR\        P                   ! RVP                  ^4      4      ^ ,          pSTMp'TOp'TPp'TQp'TRp'TSp'EK¢  V5^8X  Ed+   T5pT\        P                   ! RVP                  ^4      4      ^ ,          pU\        P                   ! RVP                  ^4      4      ^ ,          pVVP                  VV4      pW\        P                  RC\I        V P?                  VW4      4      ,          4       \        P                   ! RVP                  ^4      4      ^ ,          pXV P#                  RD^ VX4       \        P                   ! RVP                  ^4      4      ^ ,          pYV P#                  RE^ VY4       TTp'TUp'TWp'EKÔ  V5^8X  Ed}   T5pZ\        P                   ! RVP                  ^4      4      ^ ,          p[\        P                   ! RVP                  ^4      4      ^ ,          p\VP                  V\4      p]\        P                  RF\I        V P?                  V]4      4      ,          4       \        P                   ! RVP                  ^4      4      ^ ,          p^VP                  V^4      p_\        P                  RG\I        V P?                  V_4      4      ,          4       \        P                   ! RVP                  ^4      4      ^ ,          p`\        P                   ! RVP                  ^4      4      ^ ,          paTZp'T[p'T]p'T_p'T`p'Tap'EKX  \        P+                  RHP-                  V54      4       \K        VRIRJV54      h)Kak  
Extract VBA macros from an OleFileIO object.

:param vba_root: path to the VBA root storage, containing the VBA storage and the PROJECT stream
:param project_path: path to the PROJECT stream
:param relaxed: If True, only create info/debug log entry if data is not as expected
                (e.g. opening substream fails); if False, raise an error in this case
zParsing the dir stream from %rr  ÚPROJECTSYSKIND_IdrX  ÚPROJECTSYSKIND_Sizez16-bit Windowsz32-bit WindowsÚ	Macintoshz64-bit WindowsÚUnknownzPROJECTSYSKIND_SysKind: %d - %sz&invalid PROJECTSYSKIND_SysKind {0:04X}ÚPROJETCOMPATVERSION_IdÚPROJECTCOMPATVERSION_Sizez compat version: {compat_version})Úcompat_versionÚPROJECTLCID_IdÚPROJECTLCID_SizeÚPROJECTLCID_Lcidi	  ÚPROJECTLCIDINVOKE_IdÚPROJECTLCIDINVOKE_SizeÚPROJECTLCIDINVOKE_LcidInvokeÚPROJECTCODEPAGE_IdÚPROJECTCODEPAGE_SizezProject Code Page: ú - z.Python codec corresponding to code page %d: %sÚPROJECTNAME_IdzProject name size: %d bytesz=PROJECTNAME_SizeOfProjectName value not in range [1-128]: {0}ÚPROJECTDOCSTRING_IdiÐ  z8PROJECTDOCSTRING_SizeOfDocString value not in range: {0}ÚPROJECTDOCSTRING_Reservedz3PROJECTDOCSTRING_SizeOfDocStringUnicode is not evenÚutf16rG   rH   ÚPROJECTHELPFILEPATH_Idi  z;PROJECTHELPFILEPATH_SizeOfHelpFile1 value not in range: {0}ÚPROJECTHELPFILEPATH_ReservedzVPROJECTHELPFILEPATH_SizeOfHelpFile1 does not equal PROJECTHELPFILEPATH_SizeOfHelpFile2zJPROJECTHELPFILEPATH_HelpFile1 does not equal PROJECTHELPFILEPATH_HelpFile2ÚPROJECTHELPCONTEXT_IdÚPROJECTHELPCONTEXT_SizeÚPROJECTLIBFLAGS_IdÚPROJECTLIBFLAGS_SizeÚPROJECTLIBFLAGS_ProjectLibFlagsÚPROJECTVERSION_IdÚPROJECTVERSION_ReservedÚPROJECTCONSTANTS_Idi÷  z8PROJECTCONSTANTS_SizeOfConstants value not in range: {0}ÚPROJECTCONSTANTS_Reservedz3PROJECTCONSTANTS_SizeOfConstantsUnicode is not evenNzreference type = {0:04X}zREFERENCE name: %szREFERENCE original lib id: %sz%REFERENCE control twiddled lib id: %sÚREFERENCECONTROL_Reserved1ÚREFERENCECONTROL_Reserved2z*REFERENCE control name record extended: %sÚREFERENCECONTROL_Reserved3zREFERENCE registered lib id: %sÚREFERENCEREGISTERED_Reserved1ÚREFERENCEREGISTERED_Reserved2z%REFERENCE project lib id absolute: %sz%REFERENCE project lib id relative: %sz#invalid or unknown check Id {0:04X}zreference type)é   é   é3   é/   é   é   )&rz  ry  Úproject_pathÚdir_pathr~  Úmodulesr  rU   r  r{  rv  r   rS  r8  rƒ  r  r:  rw  Úsyskindr€  Úsyskind_namer  r6   ÚlcidÚ
lcidinvokeÚcodepager$   Úget_codepage_nameÚcodepage_nameÚcodepage2codecÚcodecrx  Úprojectnamerl  rO   Údocstring_unicoderM   rˆ   )bra   rz  ry  rÁ  rÂ  r~  Údir_compressedrƒ  Úprojectsyskind_idÚprojectsyskind_sizeÚSYSKIND_NAMEÚ
project_idÚprojectcompatversion_idÚprojectcompatversion_sizeÚ"projectcompatversion_compatversionÚprojectlcid_idÚprojectlcid_sizeÚprojectlcidinvoke_idÚprojectlcidinvoke_sizeÚprojectcodepage_idÚprojectcodepage_sizeÚprojectname_idÚsizeof_projectnameÚprojectname_bytesÚprojectdocstring_idÚ!projectdocstring_sizeof_docstringr‹  Úprojectdocstring_reservedÚ)projectdocstring_sizeof_docstring_unicodeÚdocstring_unicode_bytesÚprojecthelpfilepath_idÚ$projecthelpfilepath_sizeof_helpfile1Úprojecthelpfilepath_helpfile1Úprojecthelpfilepath_reservedÚ$projecthelpfilepath_sizeof_helpfile2Úprojecthelpfilepath_helpfile2Úprojecthelpcontext_idÚprojecthelpcontext_sizeÚprojecthelpcontext_helpcontextÚunusedÚprojectlibflags_idÚprojectlibflags_sizeÚprojectlibflags_projectlibflagsÚprojectversion_idÚprojectversion_reservedÚprojectversion_versionmajorÚprojectversion_versionminorÚprojectconstants_idÚ!projectconstants_sizeof_constantsÚprojectconstants_constantsÚprojectconstants_reservedÚ)projectconstants_sizeof_constants_unicodeÚ"projectconstants_constants_unicodeÚcheckÚreference_idÚreference_sizeof_nameÚreference_nameÚreference_reservedÚreference_sizeof_name_unicodeÚreference_name_unicodeÚreferenceoriginal_idÚ&referenceoriginal_sizeof_libidoriginalÚreferenceoriginal_libidoriginalÚreferencecontrol_idÚreferencecontrol_sizetwiddledÚ%referencecontrol_sizeof_libidtwiddledÚreferencecontrol_libidtwiddledÚreferencecontrol_reserved1Úreferencecontrol_reserved2Úcheck2Ú&referencecontrol_namerecordextended_idÚ/referencecontrol_namerecordextended_sizeof_nameÚ(referencecontrol_namerecordextended_nameÚ,referencecontrol_namerecordextended_reservedÚ7referencecontrol_namerecordextended_sizeof_name_unicodeÚ0referencecontrol_namerecordextended_name_unicodeÚreferencecontrol_reserved3Úreferencecontrol_sizeextendedÚ%referencecontrol_sizeof_libidextendedÚreferencecontrol_libidextendedÚreferencecontrol_reserved4Úreferencecontrol_reserved5Ú referencecontrol_originaltypelibÚreferencecontrol_cookieÚreferenceregistered_idÚreferenceregistered_sizeÚ referenceregistered_sizeof_libidÚreferenceregistered_libidÚreferenceregistered_reserved1Úreferenceregistered_reserved2Úreferenceproject_idÚreferenceproject_sizeÚ%referenceproject_sizeof_libidabsoluteÚreferenceproject_libidabsoluteÚ%referenceproject_sizeof_libidrelativeÚreferenceproject_libidrelativeÚreferenceproject_majorversionÚreferenceproject_minorversionsb   &&&&&&                                                                                            r,   r]   ÚVBA_Project.__init__~  s¾  € ð ŒØ ŒØ)ÔØ ŒØŒàˆŒàˆŒÜ�	‰	Ð2°XÕ=Ô>àŸ™¨Ó1×6Ñ6Ó8ˆäÔ.¬y¸Ó/HÓIÓJˆ
à$Œô #ŸMšM¨$°
·±ÀÓ0BÓCÀAÕFÐØ×ÑÐ,¨fÐ6GÔHÜ$Ÿmšm¨D°*·/±/À!Ó2DÓEÀaÕHÐØ×ÑÐ.°Ð8KÔLÜ—}’} T¨:¯?©?¸1Ó+=Ó>¸qÕAˆŒàÐ"ØÐ"Ø�+ØÐ"ð	
ˆð )×,Ñ,¨T¯\©\¸9ÓEˆÔÜ�	‰	Ð3°t·|±|ÀT×EVÑEVÐ6WÕWÔXØ�<‰<˜|Ô+Ü�I‰IÐ>×EÑEÀdÇlÁlÓSÔTô —]’] 4¨¯©¸Ó);Ó<¸QÕ?ˆ
Ø˜Ôð '1Ð#Ø×ÑÐ5°vÐ?VÔWÜ(.¯ª°d¸J¿O¹OÈAÓ<NÓ(OÐPQÕ(RÐ%Ø×ÑÐ8¸&ÐB[Ô\Ü17·²¸tÀZÇ_Á_ÐUVÓEWÓ1XÐYZÕ1[Ð.ä�I‰IÐ8×?Ñ?ÐOqÐ?ÓrÔsô  Ÿš t¨Z¯_©_¸QÓ-?Ó@ÀÕCˆJà#ˆð 	×ÑÐ)¨6°>ÔBÜ!Ÿ=š=¨¨z¯©¸qÓ/AÓBÀ1ÕEÐØ×ÑÐ+¨VÐ5EÔFä—M’M $¨
¯©¸Ó(:Ó;¸AÕ>ˆŒ	Ø×ÑÐ+¨U°D·I±IÔ>ô  &Ÿ}š}¨T°:·?±?À1Ó3EÓFÀqÕIÐØ×ÑÐ/°Ð9MÔNÜ!'§¢¨t°Z·_±_ÀQÓ5GÓ!HÈÕ!KÐØ×ÑÐ1°6Ð;QÔRä Ÿ-š-¨¨j¯o©o¸aÓ.@ÓAÀ!ÕDˆŒØ×ÑÐ7¸ÀÇÁÔPô $Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕGÐØ×ÑÐ-¨vÐ7IÔJÜ%Ÿ}š}¨T°:·?±?À1Ó3EÓFÀqÕIÐØ×ÑÐ/°Ð9MÔNÜŸš d¨J¯O©O¸AÓ,>Ó?ÀÕBˆŒÜ&×8Ò8¸¿¹ÓGˆÔÜ�	Š	°$·-´-À×ASÓASÐTÔUÜ×-Ò-¨d¯m©mÓ<ˆŒ
Ü�	‰	ÐBÀdÇmÁmÐUY×U_ÑU_ÐE`Õ`Ôaô
  Ÿš t¨Z¯_©_¸QÓ-?Ó@ÀÕCˆØ×ÑÐ)¨6°>ÔBÜ#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕGÐÜ�	‰	Ð/Ð2DÕDÔEØ Ô!Ð%7¸#Ô%=ä�I‰IÐU×\Ñ\Ð]oÓpÔqØ&ŸO™OÐ,>Ó?ÐØ×,Ñ,Ð->Ó?ˆÔô
 %Ÿmšm¨D°*·/±/À!Ó2DÓEÀaÕHÐØ×ÑÐ.°Ð8KÔLÜ,2¯MªM¸$À
ÇÁÐPQÓ@RÓ,SÐTUÕ,VÐ)Ø,¨tÔ3Ü�I‰IØJ×QÑQÐRsÓtôvð
 %Ÿ/™/Ð*KÓLˆØ×*Ñ*¨?Ó;ˆŒÜ$*§M¢M°$¸
¿¹ÈÓ8JÓ$KÈAÕ$NÐ!Ø×ÑÐ4°fÐ>WÔXÜ4:·M²MÀ$È
ÏÉÐXYÓHZÓ4[Ð\]Õ4^Ð1Ø4°qÕ8¸AÔ=Ü�I‰IÐKÔLð #-§/¡/Ð2[Ó"\ÐØ!8×!?Ñ!?ÀÐPYÐ!?Ó!ZˆÔô "(§¢¨t°Z·_±_ÀQÓ5GÓ!HÈÕ!KÐØ×ÑÐ1°6Ð;QÔRÜ/5¯}ª}¸TÀ:Ç?Á?ÐSTÓCUÓ/VÐWXÕ/YÐ,Ø/°#Ô5Ü�I‰IØM×TÑTÐUyÓzô|à(2¯©Ð8\Ó(]Ð%Ü'-§}¢}°T¸:¿?¹?È1Ó;MÓ'NÈqÕ'QÐ$Ø×ÑÐ7¸ÐA]Ô^Ü/5¯}ª}¸TÀ:Ç?Á?ÐSTÓCUÓ/VÐWXÕ/YÐ,Ø/Ð3WÔWÜ�I‰IÐnÔoØ(2¯©Ð8\Ó(]Ð%Ø(Ð,IÔIÜ�I‰IÐbÔcô !'§¢¨d°J·O±OÀAÓ4FÓ GÈÕ JÐØ×ÑÐ0°&Ð:OÔPÜ"(§-¢-°°j·o±oÀaÓ6HÓ"IÈ!Õ"LÐØ×ÑÐ2°FÐ<SÔTÜ)/¯ª°t¸Z¿_¹_ÈQÓ=OÓ)PÐQRÕ)SÐ&Ø/ˆô $Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕGÐØ×ÑÐ-¨vÐ7IÔJÜ%Ÿ}š}¨T°:·?±?À1Ó3EÓFÀqÕIÐØ×ÑÐ/°Ð9MÔNÜ*0¯-ª-¸¸j¿o¹oÈaÓ>PÓ*QÐRSÕ*TÐ'Ø×ÑÐ:¸FÐDcÔdô #ŸMšM¨$°
·±ÀÓ0BÓCÀAÕFÐØ×ÑÐ,¨fÐ6GÔHÜ"(§-¢-°°j·o±oÀaÓ6HÓ"IÈ!Õ"LÐØ×ÑÐ2°FÐ<SÔTÜ&,§m¢m°D¸*¿/¹/È!Ó:LÓ&MÈaÕ&PÐ#Ü&,§m¢m°D¸*¿/¹/È!Ó:LÓ&MÈaÕ&PÐ#Ø,ˆØ,ˆô %Ÿmšm¨D°*·/±/À!Ó2DÓEÀaÕHÐØ×ÑÐ.°Ð8KÔLÜ,2¯MªM¸$À
ÇÁÐPQÓ@RÓ,SÐTUÕ,VÐ)Ø,¨tÔ3Ü�I‰IØJ×QÑQÐRsÓtôvà%/§_¡_Ð5VÓ%WÐ"Ü$*§M¢M°$¸
¿¹ÈÓ8JÓ$KÈAÕ$NÐ!Ø×ÑÐ4°fÐ>WÔXÜ4:·M²MÀ$È
ÏÉÐXYÓHZÓ4[Ð\]Õ4^Ð1Ø4°qÕ8¸AÔ=Ü�I‰IÐKÔLØ-7¯_©_Ð=fÓ-gÐ*Ø+ˆØ3ˆð ˆØÜ—M’M $¨
¯©¸Ó(:Ó;¸AÕ>ˆEÜ�I‰IÐ0×7Ñ7¸Ó>Ô?Ø˜ŒÙà˜�ð  %�Ü(.¯ª°d¸J¿O¹OÈAÓ<NÓ(OÐPQÕ(RÐ%Ø!+§¡Ð1FÓ!G�Ü—	‘	Ð.´¸T×=NÑ=NÈ~Ó=^Ó1_Õ_Ô`Ü%+§]¢]°4¸¿¹ÈÓ9KÓ%LÈQÕ%OÐ"ð &¨Ô/ô 5;·M²MÀ$È
ÏÉÐXYÓHZÓ4[Ð\]Õ4^Ð1Ø-7¯_©_Ð=ZÓ-[Ð*Ø)�FØ+�FØ3�FÚà.�EÜ—I‘IÐ8×?Ñ?ÀÓFÔGà˜Œð (-Ð$Ü9?¿ºÀtÈZÏ_É_Ð]^ÓM_Ó9`ÐabÕ9cÐ6Ø2<·/±/ÐBhÓ2iÐ/Ü—	‘	Ð9¼KÈ×HYÑHYÐZyÓHzÓ<{Õ{Ô|Ø-�Ø8�Úà˜�ð ',Ð#Ü06·²¸dÀJÇOÁOÐTUÓDVÓ0WÐXYÕ0ZÐ-Ü8>¿ºÀdÈJÏOÉOÐ\]ÓL^Ó8_Ð`aÕ8bÐ5Ø1;·±ÐAfÓ1gÐ.Ü—	‘	ÐAÄKÐPT×PaÑPað  cAó  QBó  ECõ  Cô  DÜ-3¯]ª]¸4ÀÇÁÐQRÓASÓ-TÐUVÕ-WÐ*Ø× Ñ Ð!=¸vÐGaÔbÜ-3¯]ª]¸4ÀÇÁÐQRÓASÓ-TÐUVÕ-WÐ*Ø× Ñ Ð!=¸vÐGaÔbØ,�Ø6�Ø7�äŸš t¨Z¯_©_¸QÓ-?Ó@ÀÕC�Ø˜VÕ#Ø=BÐ:ÜFLÇmÂmÐTXÐZd×ZiÑZiÐjkÓZlÓFmÐnoÕFpÐCØ?I¿¹ØGó@IÐ<ä—I‘IÐJÌ[Ø×)Ñ)Ð*RÓSóNUõ Uô VäCIÇ=Â=ÐQUÐWa×WfÑWfÐghÓWiÓCjÐklÕCmÐ@ØCÀvÔMÜRX×R_ÒR_Ð`dÐfp×fuÑfuÐvwÓfxÓRyÐz{ÕR|ÐOØKUÏ?É?ØSóLUÐHä5;·]²]À4ÈÏÉÐYZÓI[Ó5\Ð]^Õ5_Ð2Ø!G˜Ø!I˜Ø!Q™à5aÑ2à17Ð.à× Ñ Ð!=¸vÐGaÔbÜ06·²¸dÀJÇOÁOÐTUÓDVÓ0WÐXYÕ0ZÐ-Ü8>¿ºÀdÈJÏOÉOÐ\]ÓL^Ó8_Ð`aÕ8bÐ5Ø1;·±ÐAfÓ1gÐ.Ü-3¯]ª]¸4ÀÇÁÐQRÓASÓ-TÐUVÕ-WÐ*Ü-3¯]ª]¸4ÀÇÁÐQRÓASÓ-TÐUVÕ-WÐ*Ø3=·?±?À2Ó3FÐ0Ü*0¯-ª-¸¸j¿o¹oÈaÓ>PÓ*QÐRSÕ*TÐ'Ø6�Ø7�Ø3�Ø3�Ø9�Ø0�Úà˜�ð */Ð&Ü+1¯=ª=¸¸z¿¹ÈqÓ?QÓ+RÐSTÕ+UÐ(Ü39·=²=ÀÀzÇÁÐWXÓGYÓ3ZÐ[\Õ3]Ð0Ø,6¯O©OÐ<\Ó,]Ð)Ü—	‘	Ð;¼kÈ$×J[ÑJ[Ð\uÓJvÓ>wÕwÔxÜ06·²¸dÀJÇOÁOÐTUÓDVÓ0WÐXYÕ0ZÐ-Ø× Ñ Ð!@À&ÐJgÔhÜ06·²¸dÀJÇOÁOÐTUÓDVÓ0WÐXYÕ0ZÐ-Ø× Ñ Ð!@À&ÐJgÔhØ/�Ø1�Ø2�Úà˜�ð ',Ð#Ü(.¯ª°d¸J¿O¹OÈAÓ<NÓ(OÐPQÕ(RÐ%Ü8>¿ºÀdÈJÏOÉOÐ\]ÓL^Ó8_Ð`aÕ8bÐ5Ø1;·±ÐAfÓ1gÐ.Ü—	‘	ÐAÄKÐPT×PaÑPað  cAó  QBó  ECõ  Cô  DÜ8>¿ºÀdÈJÏOÉOÐ\]ÓL^Ó8_Ð`aÕ8bÐ5Ø1;·±ÐAfÓ1gÐ.Ü—	‘	ÐAÄKÐPT×PaÑPað  cAó  QBó  ECõ  Cô  DÜ06·²¸dÀJÇOÁOÐTUÓDVÓ0WÐXYÕ0ZÐ-Ü06·²¸dÀJÇOÁOÐTUÓDVÓ0WÐXYÕ0ZÐ-Ø,�Ø.�Ø7�Ø7�Ø6�Ø6�Úä�I‰IÐ;×BÑBÀ5ÓIÔJä% hÐ0@ÐBfÐhmÓnÐnr.   c                ó²   € W#8w  dQ   V P                   '       d(   \        P                  R P                  WV4      4       R# \	        V P
                  WV4      hR# )z2invalid value for {0} expected {1:04X} got {2:04X}N)r~  rU   r;  r6   rˆ   rÂ  )ra   r¬   r•   r–   s   &&&&r,   rw  ÚVBA_Project.check_valueÒ  sH   € ØÔØ�|�|ˆ|ô —‘ÐPß!™6 $°%Ó8ö:ô *¨$¯-©-¸ÈÓOÐOñ r.   c                óV  € V P                   P                  V P                  4      p/ V n        V Fö  pV P	                  V4      p\
        P                  RV,          4       VP                  4       pRV9   g   KI  VP                  R^4      w  r4VP                  4       pVR8X  d/   VP                  R^4      ^ ,          p\        V P                  V&   K¢  VR8X  d   \        V P                  V&   K¾  VR8X  d   \        V P                  V&   KÚ  VR8X  g   Kã  \        V P                  V&   Kø  	  R# )	z8
Parse the PROJECT stream from the VBA project
:return:
zPROJECT: %rÚ=ÚDocumentrƒ   ÚModuleÚClassÚ	BaseClassN)rz  r{  rÁ  r  rx  rU   r  rÞ   Úsplitr�  ÚCLASS_EXTENSIONÚMODULE_EXTENSIONÚFORM_EXTENSION)ra   Úproject_streamÚliner¬   r–   s   &    r,   Úparse_project_streamÚ VBA_Project.parse_project_streamÝ  sï   € ð Ÿ™×,Ñ,¨T×->Ñ->Ó?ˆð, ˆŒã"ˆDØ×$Ñ$ TÓ*ˆDÜ�I‰I�m dÕ*Ô+Ø—:‘:“<ˆDØ�dŽ{à"Ÿj™j¨¨aÓ0‘�ð
 Ÿ™›�Ø˜:Ô%à!ŸK™K¨¨QÓ/°Õ2�EÜ-<�D—O‘O EÓ*Ø˜XÔ%Ü-=�D—O‘O EÓ*Ø˜W”_Ü-<�D—O‘O EÓ*Ø˜[Ö(Ü-;�D—O‘O EÓ*ó+ #r.   c              #  ó°  "  € V P                   p\        P                  ! R VP                  ^4      4      ^ ,          pV P	                  R^V4       \        P                  ! RVP                  ^4      4      ^ ,          V n        \        P                  ! RVP                  ^4      4      ^ ,          pV P	                  R^V4       \        P                  ! R VP                  ^4      4      ^ ,          pV P	                  R^V4       \        P                  ! RVP                  ^4      4      ^ ,          pTp\        P                  RP                  V P
                  4      4       \        ^ V P
                  4       FZ  p\        W P                   VR7      pV P                  P                  V4       VP                  VP                  VP                  3x € K\  	  Tp	R# 5i)rX  ÚPROJECTMODULES_Sizer  Ú%PROJECTMODULES_ProjectCookieRecord_IdÚ'PROJECTMODULES_ProjectCookieRecord_Sizezparsing {0} modules)r„  N)rƒ  r  r:  rv  rw  r}  rU   r  r6   r>  rU  rÃ  Úappendru  rt  rs  )
ra   rƒ  Úprojectmodules_sizer…  r†  Úprojectcookierecord_cookierî  r„  Úmoduler¹   s
   &         r,   Úparse_modulesÚVBA_Project.parse_modules  sh  é € Ø—_‘_ˆ
ô %Ÿmšm¨D°*·/±/À!Ó2DÓEÀaÕHÐØ×ÑÐ.°Ð8KÔLÜ#Ÿ]š]¨4°·±ÀÓ1CÓDÀQÕGˆÔÜ�mŠm˜D *§/¡/°!Ó"4Ó5°aÕ8ˆØ×ÑÐ@À&È#ÔNÜ�}Š}˜T :§?¡?°1Ó#5Ó6°qÕ9ˆØ×ÑÐBÀFÈDÔQÜ%+§]¢]°4¸¿¹ÈÓ9KÓ%LÈQÕ%OÐ"Ø+ˆä�	‰	Ð'×.Ñ.¨t×/AÑ/AÓBÔCÜ" 1 d×&8Ñ&8Ö9ˆLÜ §o¡oÀLÔQˆFØ�L‰L×Ñ Ô'Ø×#Ñ# V×%8Ñ%8¸&¿/¹/ÐJÔJñ :ð ˆÙùs   ‚GGc                ó<   € VP                  V P                  VR7      # )zá
Decode a bytes string to a unicode string, using the project code page
:param bytes_string: bytes, bytes string to be decoded
:param errors: str, mode to handle unicode conversion errors
:return: str/unicode, decoded string
rH   )rO   rÌ  )ra   rP   rI   s   &&&r,   rx  ÚVBA_Project.decode_bytes*  s   € ð ×"Ñ" 4§:¡:°fÐ"Ó=Ð=r.   )rÌ  rÈ  rÊ  rÂ  rƒ  rl  rÎ  rÆ  rÇ  r  rÃ  r}  rz  rÁ  rÍ  r~  rÄ  rÅ  ry  N©T)rG   )rf   rg   rh   ri   rj   r]   rw  r8  rB  rx  rk   rl   r~   s   @r,   r•  r•  x  s-   ø‡ € ñô
Qoòh
	Pò4<òl÷.>ò >r.   r•  c              #  óÀ   "  € \         P                  RV,          4       \        WW#V4      pVP                  4        VP	                  4        F  w  rgpWgV3x € K  	  R# 5i)aé  
Extract VBA macros from an OleFileIO object.
Internal function, do not call directly.

vba_root: path to the VBA root storage, containing the VBA storage and the PROJECT stream
vba_project: path to the PROJECT stream
:param relaxed: If True, only create info/debug log entry if data is not as expected
                (e.g. opening substream fails); if False, raise an error in this case
This is a generator, yielding (stream path, VBA filename, VBA source code) for each VBA code stream
zrelaxed is %sN)rU   r  r•  r8  rB  )	rz  ry  rÁ  rÂ  r~  rf  ru  r_   r�  s	   &&&&&    r,   Ú_extract_vbarH  5  sV   é € ô ‡I�Iˆo Õ'Ô(ä˜#¨ÀÓI€GØ× Ñ Ô"à*1×*?Ñ*?Ö*AÑ&ˆ	˜YØ IÐ.Ô.ó +Bùs   ‚AAc                óÊ   €  V P                  RR4      p V P                  RR4      p V P                  RR4      p V #    \        P                  R\        T 4      ,          4       h ; i)zû
Parse a VBA module code to detect continuation line characters (underscore) and
collapse split lines. Continuation line characters are replaced by spaces.

:param vba_code: str, VBA module code
:return: str, VBA module code with long lines collapsed
z _
Ú z _z _
ztype(vba_code)=%s)rG   rU   rÖ   r’   )Úvba_codes   &r,   Úvba_collapse_long_linesrL  I  sd   € ðØ×#Ñ# H¨cÓ2ˆØ×#Ñ# F¨CÓ0ˆØ×#Ñ# F¨CÓ0ˆð €OøðÜ�‰Ð)¬D°«NÕ:Ô;Øús	   ‚6: º(A"c                ó´   € V P                  4       p^ pV F,  pVP                  R4      '       d   RV9   g   V^,          pK,   M	  RP                  WR 4      pV# )a¨  
Filter VBA source code to remove the first lines starting with "Attribute VB_",
which are automatically added by MS Office and not displayed in the VBA Editor.
This should only be used when displaying source code for human analysis.

Note: lines are not filtered if they contain a colon, because it could be
used to hide malicious instructions.

:param vba_code: str, VBA source code
:return: str, filtered VBA source code
zAttribute VB_Ú:Ú
N)Ú
splitlinesr  r>   )rK  Ú	vba_linesr@   r7  re  s   &    r,   Ú
filter_vbarR  \  s\   € ð ×#Ñ#Ó%€IØ€EÛˆØ�?‰?˜?×+Ò+°C¸4´KØ�Q�JŠEáñ	 ð �)‰)�I˜fÐ%Ó
&€CØ€Jr.   c                óP  € . pRpV'       d
   RV,          p\         P                  4        Fz  w  rEV Fo  p\        P                  ! R\        P                  ! V4      ,           R,           V 4      pV'       g   KF  VP                  4       pVP                  W„V,           34       Kq  	  K|  	  \        P                  4        Ff  w  rEV F[  p\        P                  ! RV,           R,           V 4      pV'       g   K2  VP                  4       pVP                  W„V,           34       K]  	  Kh  	  V# )aQ  
Detect if the VBA code contains keywords corresponding to macros running
automatically when triggered by specific actions (e.g. when a document is
opened or closed).

:param vba_code: str, VBA source code
:param obfuscation: None or str, name of obfuscation to be added to description
:return: list of str tuples (keyword, description)
r3   ú (obfuscation: %s)ú(?i)\bú\b)ÚAUTOEXEC_KEYWORDSÚitemsÚreÚsearchÚescapeÚgroupr>  ÚAUTOEXEC_KEYWORDS_REGEX©	rK  ÚobfuscationÚresultsÚobf_textÚdescriptionÚkeywordsÚkeywordr#  Úfound_keywords	   &&       r,   Údetect_autoexecrf  t  sî   € ð €GØ€HßØ'¨+Õ5ˆä!2×!8Ñ!8Ö!:ÑˆÛˆGô —I’I˜i¬"¯)ª)°GÓ*<Õ<¸uÕDÀhÓOˆEß‰uØ %§¡£�Ø—‘ ¸XÕ/EÐFÖGó  ñ ";ô "9×!>Ñ!>Ö!@ÑˆÛˆGô —I’I˜i¨'Õ1°EÕ9¸8ÓDˆEß‰uØ %§¡£�Ø—‘ ¸XÕ/EÐFÖGó  ñ "Að €Nr.   c                ó  € . pRpV'       d
   RV,          p\         P                  4        Fz  w  rEV Fo  p\        P                  ! R\        P                  ! V4      ,           R,           V 4      pV'       g   KF  VP                  4       pVP                  W„V,           34       Kq  	  K|  	  \        P                  4        Ff  w  rEV F[  p\        P                  ! RV,           R,           V 4      pV'       g   K2  VP                  4       pVP                  W„V,           34       K]  	  Kh  	  \        P                  4        FK  w  rEV F@  pVP                  4       V 9   g   K  VR8X  d   Ve   K'  VP                  WdV,           34       KB  	  KM  	  V# )a  
Detect if the VBA code contains suspicious keywords corresponding to
potential malware behaviour.

:param vba_code: str, VBA source code
:param obfuscation: None or str, name of obfuscation to be added to description
:return: list of str tuples (keyword, description)
r3   rT  rU  rV  r´   )
ÚSUSPICIOUS_KEYWORDSrX  rY  rZ  r[  r\  r>  ÚSUSPICIOUS_KEYWORDS_REGEXÚSUSPICIOUS_KEYWORDS_NOREGEXr�  r^  s	   &&       r,   Údetect_suspiciousrk  š  s?  € ð €GØ€HßØ'¨+Õ5ˆÜ!4×!:Ñ!:Ö!<ÑˆÛˆGô —I’I˜i¬"¯)ª)°GÓ*<Õ<¸uÕDÀhÓOˆEß‰uØ %§¡£�Ø—‘ ¸XÕ/EÐFÖGó  ñ "=ô ";×!@Ñ!@Ö!BÑˆÛˆGô —I’I˜i¨'Õ1°EÕ9¸8ÓDˆEß‰uØ %§¡£�Ø—‘ ¸XÕ/EÐFÖGó  ñ "Cô "=×!BÑ!BÖ!DÑˆÛˆGØ�}‰}‹ (Ö*à ”}¨Ô)@Ø—N‘N G¸8Õ-CÐ#DÖEó	  ñ "Eð €Nr.   c                ó~  € . p\        4       pRpV'       d
   RV,          p\         F“  w  rVVP                  V 4       Fy  pVP                  4       pRp	\         F  p
VP                  V
4      '       g   K  Rp	K   	  Wƒ9  g   KE  V	'       d   KO  VP                  WT,           V34       VP                  V4       K{  	  K•  	  V# )zÖ
Detect if the VBA code contains specific patterns such as IP addresses,
URLs, e-mail addresses, executable file names, etc.

:param vba_code: str, VBA source code
:return: list of str tuples (pattern type, value)
r3   rT  FT)r&  ÚRE_PATTERNSr   r\  ÚEXCLUDE_URLS_PATTERNSr  r>  Úadd)rK  r_  r`  Úfoundra  Úpattern_typeÚ
pattern_rer#  r–   Úexclude_pattern_foundÚurl_exclude_patterns   &&         r,   Údetect_patternsru  Â  s­   € ð €GÜ‹E€EØ€HßØ'¨+Õ5ˆß$/Ñ ˆØ×(Ñ(¨Ö2ˆEØ—K‘K“MˆEØ$)Ð!ß'<Ð#Ø×#Ñ#Ð$7×8Ô8Ø,0Ò)ñ (=ð Ö!×*?Ñ*?Ø—‘ Õ 7¸Ð?Ô@Ø—	‘	˜%Ö ó 3ñ %0ð €Nr.   c                ó
  € . p\        4       p\        P                  V 4       F]  pVP                  4       pWB9  g   K  \	        \
        P                  ! V4      4      pVP                  WE34       VP                  V4       K_  	  V# )z¥
Detect if the VBA code contains strings encoded in hexadecimal.

:param vba_code: str, VBA source code
:return: list of str tuples (encoded string, decoded string)
)	r&  Úre_hex_stringr   r\  rR   rç   Ú	unhexlifyr>  ro  )rK  r`  rp  r#  r–   Údecodeds   &     r,   Údetect_hex_stringsrz  Ü  sm   € ð €GÜ‹E€EÜ×'Ñ'¨Ö1ˆØ—‘“ˆØÖÜ¤× 2Ò 2°5Ó 9Ó:ˆGØ�N‰N˜EÐ+Ô,Ø�I‰I�eÖñ 2ð €Nr.   c                ó  € . p\        4       p\        P                  V 4       F¥  pVP                  4       P	                  R4      p\
        P                  V4      '       g   K?  WB9  g   KG  VP                  4       \        9  g   Kb   \        \        P                  ! V4      4      pVP                  WE34       VP                  V4       K§  	  V#   \        \        3 d(   p\         P#                  RT,          4        Rp?KÞ  Rp?ii ; i)z 
Detect if the VBA code contains strings encoded in base64.

:param vba_code: str, VBA source code
:return: list of str tuples (encoded string, decoded string)
r¸   zFailed to base64-decode (%s)N)r&  Úre_base64_stringr   r\  rÞ   Úre_nothex_checkrZ  r�  ÚBASE64_WHITELISTrR   Úbase64Ú	b64decoder>  ro  Ú	TypeErrorr‘   rU   r  ©rK  r`  rp  r#  r–   ry  rC   s   &      r,   Údetect_base64_stringsrƒ  î  sÎ   € ð €GÜ‹E€EÜ!×*Ñ*¨8Ö4ˆà—‘“×#Ñ# CÓ(ˆä×%Ñ% e×,Ò,ÙàÖ %§+¡+£-Ô7GÖ"Gð@Ü#¤F×$4Ò$4°UÓ$;Ó<�Ø—‘ Ð/Ô0Ø—	‘	˜%Ö ñ 5ð €Nøô œzÐ*ô @Ü—	‘	Ð8¸3Õ>×?Ò?ûð@ús   ÂACÃDÃD Ä Dc                 ón   € R pV  F#  pVP                  4       '       g   K  W,          pK%  	  \        V4      # )r3   ©Úisdigitr�   ©ÚinputÚresultr8   s   &  r,   Ú
StripCharsrŠ  	  s/   € Ø€FÛˆØ�9‰9�;Œ;Ø�KŠFñ ô ˆv‹;Ðr.   c                 ó€   € R pV  F,  pVP                  4       '       d   W,          pK#  VR,          pK.  	  \        V4      # )r3   Ú0r…  r‡  s   &  r,   ÚStripCharsWithZeror�  	  s8   € Ø€FÛˆØ�9‰9�;Š;Ø�KŠFà�c�MŠFñ	 ô
 ˆv‹;Ðr.   c                 óV  € V ^R p\        V\        V4      ^,          ^,
          \        V4      ^,           4      p\        V\        V4      ^,          \        V4      ^,          ^,            4      pW2,
          pVR\        V4      ^,          ^,
           V\        V4      ^,          ^,           R ,           p\        V\        V4      ^,          V^,          ,
          \        V4      ^,          V^,          ,            4      pVR\        V4      ^,          V^,          ,
           V\        V4      ^,          V^,          ,           R ,           p\        ^ \        V4      V4       Uu. uF  qaWfV,            NK  	  ppRpV F%  p	V\	        \        V	4      V,          4      ,          pK'  	  V# u upi )é   Nr3   éüÿÿÿ)r�  r9  rŠ  ÚrangerÔ   )
Ú	inputTextÚworkÚ	strKeyEncÚ
strKeySizeÚ	nCharSizeÚ
strKeyEnc2r×   Ú
work_splitry  r\  s
   &         r,   ÚDridexUrlDecoder™  	  sg  € Ø�Q�rˆ?€DÜ" 4¬¨T«°Q­¸!Õ(;¼cÀ$»iÈ!½mÐ#MÓN€IÜ# D¬#¨d«)°a­-¼3¸t»9Àq½=ÈAÕ:MÐ$NÓO€JØÕ&€IØÐ$”#�d“)˜a•- 1Õ$Ð%¨¬c°$«i¸!­m¸qÕ-@Ð-AÐ(BÕB€DÜ˜D¤# d£)¨a¥-°I¸aµKÕ!@Ä3ÀtÃ9ÈqÅ=ÐU^Ð_`ÕU`ÕBaÐbÓc€JØÐ0”#�d“)˜a•- I¨a¥KÕ0Ð1°D¼#¸d»)Àa½-ÈIÐVWÍKÕ9XÐ9YÐ4ZÕZ€DÜ/4°Q¼¸D»	À9Ô/MÓNÑ/M¨!�q˜9�Ó%Ñ/M€JÐNØ€GÛˆà”3”z %Ó(¨Õ3Ó4Õ4Šñ ð €Nùò Os   Å"F&c                ó   € . p\        4       p\        P                  V 4       Fs  pVP                  4       ^R p\        P                  V4      '       g   K3  WB9  g   K;   \        \        V4      4      pVP                  WE34       VP                  V4       Ku  	  V#   \         d(   p\        P                  RT,          4        Rp?K¦  Rp?ii ; i)zË
Detect if the VBA code contains strings obfuscated with a specific algorithm found in Dridex samples.

:param vba_code: str, VBA source code
:return: list of str tuples (encoded string, decoded string)
zFailed to Dridex-decode (%s)Nrà   )r&  Úre_dridex_stringr   r\  r}  rZ  rR   r™  r>  ro  r‚  rU   r  r‚  s   &      r,   Údetect_dridex_stringsrœ  2	  s±   € ð €GÜ‹E€EÜ!×*Ñ*¨8Ö4ˆØ—‘“˜a Ð#ˆä×%Ñ% e×,Ò,ÙØÖð@Ü#¤O°EÓ$:Ó;�Ø—‘ Ð/Ô0Ø—	‘	˜%Ö ñ 5ð €Nøô ô @Ü—	‘	Ð8¸3Õ>×?Ò?ûð@ús   Á7BÂCÂ&CÃCc                óZ  € . p\        4       pV P                  4       p V P                  4        Fz  p\        P	                  V4       F^  w  rEpW5V pV^ ,          p\        V\        4      '       g   K+  Wr9  g   K3  W‡8w  g   K;  VP                  Wx34       VP                  V4       K`  	  K|  	  V# )zä
Detect if the VBA code contains strings obfuscated with VBA expressions
using keywords such as Chr, Asc, Val, StrReverse, etc.

:param vba_code: str, VBA source code
:return: list of str tuples (encoded string, decoded string)
)	r&  Ú
expandtabsrP  Úvba_expr_strÚ
scanStringr<   r»   r>  ro  )	rK  r`  rp  Úvba_linerð   r@   rA   Úencodedry  s	   &        r,   Údetect_vba_stringsr£  K	  sž   € ð €GÜ‹E€Eð ×"Ñ"Ó$€Hà×'Ñ'Ö)ˆÜ".×"9Ñ"9¸(Ö"CÑˆF˜3Ø SÐ)ˆGØ˜Q•iˆGÜ˜'Ô#6×7Ô7ð Ö'¨GÖ,>Ø—N‘N GÐ#5Ô6Ø—I‘I˜gÖ&ó #Dñ *ð$ €Nr.   c                ó6  € V f    V # \        V \        \        \        34      '       d    V # \        V \        4      '       d“   \
        '       d…   V P                  W4      P                  W4      pW08w  d]   \        P                  RP                  V \        V 4      4      4       \        P                  RP                  V\        V4      4      4       V# V # \        V \        4      '       dD   \
        '       d8   V P                  W4      p\        P                  RP                  V4      4       V# \        V \        4      '       dD   \
        '       g8   V P                  W4      p\        P                  RP                  V4      4       V# \        V \        4      '       d   V  F  p\        W,          4      W&   K  	  V # \        V \         \"        34      '       d   V  F  p\        V4      pK  	  V # \        P                  RP                  \%        V 4      4      4       V # )zÔ
ensure there is no unicode in json and all strings are safe to decode

works recursively, decodes and re-encodes every string to/from unicode
to ensure there will be no trouble in loading the dumped json output
z#json2ascii: replaced: {0} (len {1})z#json2ascii:     with: {0} (len {1})zjson2ascii: encode unicode: {0}z1unexpected type in json2ascii: {0} -- leave as is)r<   Úboolr�   Úfloatr„   rJ   rO   rK   rU   r  r6   r9  Úunicoder?  ÚdictÚ
json2asciiÚlistr�   r’   )Újson_objrQ   rI   ÚdencodedÚjson_obj_bytesÚjson_obj_strÚkeyÚitems   &&&     r,   r©  r©  p	  s±  € ð ÒØðP €OôO 
�Hœt¤S¬%Ð0×	1Ò	1ØðL €OôK 
�Hœc×	"Ò	"ß‹7à—‘ xÓ8×?Ñ?ÀÓQˆHØÔ#Ü—	‘	Ð?ß ™& ¬3¨x«=Ó9ô;ä—	‘	Ð?ß ™& ¬3¨x«=Ó9ô;àˆOð ˆOä	�Hœg×	&Ò	&¯7«7à!Ÿ™¨Ó:ˆÜ�	‰	Ð3×:Ñ:¸>ÓJÔKð ÐÜ	�Hœe×	$Ò	$¯W«Wà—‘ xÓ8ˆÜ�	‰	Ð3×:Ñ:¸<ÓHÔIð ÐÜ	�Hœd×	#Ò	#ÛˆCÜ& x¥}Ó5ˆH‹Mñ ð €Oô 
�Hœt¤E˜l×	+Ò	+ÛˆDÜ˜dÓ#ŠDñ ð
 €Oô 	�	‰	ÐEß‘6œ$˜x›.Ó)ô	+à€Or.   c                ó  € V '       d   V'       d   \        R4      hV e:   \        V \        4      '       g$   \        RP                  \	        V 4      4      4      hV'       d   Tp \
        P                  ! \        V 4      R^RR7      P                  4       pV'       g   R# V'       d   \        RV^ ,          ,           4       M\        RV^ ,          ,           4       VR,           F#  p\        RVP                  4       ,           4       K%  	  R# )	aÞ  line-wise print of json.dumps(json2ascii(..)) with options and indent+1

can use in two ways:
(1) print_json(some_dict)
(2) print_json(key1=value1, key2=value2, ...)

This is compatible with :py:mod:`oletools.common.log_helper`: log messages
can be mixed if arg `use_json` was `True` in
:py:func:`log_helper.enable_logging` provided this function is called
before the first "regular" logging with `_json_is_first=True` (and
non-empty input) but after log_helper.enable_logging.
zOInvalid json argument: want either single dict or key=value parts but got both)Nz^Invalid json argument: want either single dict or key=value parts but got {0} instead of dict)F)Úcheck_circularÚindentÚensure_asciiz      z,     ºé   NN)r‘   r<   r¨  r6   r’   ÚjsonÚdumpsr©  rP  ÚprintÚrstrip)Ú	json_dictÚ_json_is_firstÚ
json_partsÚlinesr7  s   &&,  r,   Ú
print_jsonr¿  £	  sÌ   € ÷ —ZÜð 9ó :ð 	:à
Ò
¬*°YÄ×*EÒ*EÜð Hç ™&¤ i£Ó1ó3ð 	3÷ Øˆ	ä�JŠJ”z )Ó,¸UØ¨eô5ß5?±Z³\ð 
çÙçÜˆh˜˜q�Õ!Õ"äˆh˜˜q�Õ!Ô"à�b—	�	ˆÜˆh˜Ÿ™›Õ&Ö'ó r.   c                   ó:   a € ] tR tRt o RtR tRR ltR tRtV t	R# )	ÚVBA_ScanneriÈ	  zƒ
Class to scan the source code of a VBA module to find obfuscated strings,
suspicious keywords, IOCs, auto-executable macros, etc.
c                óø   € \        V4      V n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n	        RV n
        RV n        RV n        RV n        RV n        RV n        RV n        R# )zO
VBA_Scanner constructor

:param vba_code: str, VBA source code to be analyzed
r3   N)rL  rr  Úcode_hexÚcode_hex_revÚcode_rev_hexÚcode_base64Úcode_dridexÚcode_vbaÚ
strReverser`  Úautoexec_keywordsÚsuspicious_keywordsÚiocsÚhex_stringsÚbase64_stringsÚdridex_stringsÚvba_strings)ra   rK  s   &&r,   r]   ÚVBA_Scanner.__init__Î	  sƒ   € ô ,¨HÓ5ˆŒ	ØˆŒØˆÔØˆÔØˆÔØˆÔØˆŒØˆŒàˆŒØ!%ˆÔØ#'ˆÔ ØˆŒ	ØˆÔØ"ˆÔØ"ˆÔØˆÖr.   c                ó  € \        V P                  4      V n        RV n        RV P                  P	                  4       9   d   RV n        V P                   Fª  w  r4V ;P
                  RV,           ,          un        V P                  '       g   K9  V ;P                  RVRRR1,          ,           ,          un        V ;P                  R\        \        P                  ! VRRR1,          4      4      ,           ,          un        K¬  	  \        V P                  4      V n        V P                   F%  w  r4V ;P                  RV,           ,          un        K'  	  \        V P                  4      V n        V P                   F%  w  r4V ;P                   RV,           ,          un        K'  	  V'       d   \#        V P                  4      V n        M. V n        V P$                   F%  w  r4V ;P&                  RV,           ,          un        K'  	  . p. V n        . V n        . V n        V P                  R3V P
                  R3V P                  R3V P                  R3V P                  R	3V P                   R
3V P&                  R33 Fk  w  rgV ;P(                  \/        Wg4      ,          un        V ;P*                  \1        Wg4      ,          un        V ;P,                  \3        Wg4      ,          un        Km  	  V P                  '       d   V P*                  P5                  R4       V P                  '       d   V P*                  P5                  R4       V P                  '       d   V P*                  P5                  R4       V P$                  '       d   V P*                  P5                  R4       \7        4       pV P(                   F1  w  ršW˜9  g   K  VP5                  RWš34       VP9                  V	4       K3  	  \7        4       pV P*                   F1  w  ršW˜9  g   K  VP5                  RWš34       VP9                  V	4       K3  	  \7        4       pV P,                   F1  w  r¼WÈ9  g   K  VP5                  RWË34       VP9                  V4       K3  	  V P                   F3  w  r4V'       g   \;        V4      '       g   K   VP5                  RWC34       K5  	  V P                   F3  w  r4V'       g   \;        V4      '       g   K   VP5                  RWC34       K5  	  V P                   F3  w  r4V'       g   \;        V4      '       g   K   VP5                  RWC34       K5  	  V P$                   F3  w  r4V'       g   \;        V4      '       g   K   VP5                  RWC34       K5  	  WPn        V# )aç  
Analyze the provided VBA code to detect suspicious keywords,
auto-executable macros, IOC patterns, obfuscation patterns
such as hex-encoded strings.

:param include_decoded_strings: bool, if True, all encoded strings will be included with their decoded content.
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)
:return: list of tuples (type, keyword, description)
(type = 'AutoExec', 'Suspicious', 'IOC', 'Hex String', 'Base64 String' or 'Dridex String')
FÚ
strreverseTrO  NÚHexzHex+StrReversezStrReverse+HexÚBase64ÚDridexzVBA expressionÚAutoExecÚ
SuspiciousÚIOCz
Hex StringzBase64 StringzDridex stringú
VBA stringrà   )zHex Stringsz`Hex-encoded strings were detected, may be used to obfuscate strings (option --decode to see all))zBase64 StringszcBase64-encoded strings were detected, may be used to obfuscate strings (option --decode to see all))zDridex StringszcDridex-encoded strings were detected, may be used to obfuscate strings (option --decode to see all))zVBA obfuscated StringszcVBA string expressions were detected, may be used to obfuscate strings (option --decode to see all))rz  rr  rÍ  rÉ  r�  rÃ  rÄ  rÅ  rR   rç   rx  rƒ  rÎ  rÆ  rœ  rÏ  rÇ  r£  rÐ  rÈ  rÊ  rË  rÌ  rf  rk  ru  r>  r&  ro  r*  r`  )ra   Úinclude_decoded_stringsÚdeobfuscater¢  ry  r`  rr  r_  Úkeyword_setrd  rb  rq  r–   s   &&&          r,   ÚscanÚVBA_Scanner.scanè	  sj  € ô .¨d¯i©iÓ8ˆÔàˆŒØ˜4Ÿ9™9Ÿ?™?Ó,Ô,À¨d¬oà $× 0Ô 0ÑˆGØ�MŠM˜T G�^Õ+�Mà��Šà×!Ò! T¨G±D°b°D­MÕ%9Õ9Õ!à×!Ò! T¬I´h×6HÒ6HÈÑQUÐSUÐQUÍÓ6WÓ,XÕ%XÕX×!ñ !1ô 4°D·I±IÓ>ˆÔØ $× 3Ô 3ÑˆGØ×Ò  w¥Õ.×ñ !4ô 4°D·I±IÓ>ˆÔØ $× 3Ô 3ÑˆGØ×Ò  w¥Õ.×ñ !4÷ Ü1°$·)±)Ó<ˆDÕà!ˆDÔØ $× 0Ô 0ÑˆGØ�MŠM˜T G�^Õ+�Mñ !1àˆØ!#ˆÔØ#%ˆÔ ØˆŒ	ð —‘˜DÐ!Ø—‘ Ð&Ø×"Ñ"Ð$4Ð5Ø×"Ñ"Ð$4Ð5Ø×!Ñ! 8Ð,Ø×!Ñ! 8Ð,Ø—‘Ð 0Ð1ó"
ÑˆDð ×"Ò"¤o°dÓ&HÕHÕ"Ø×$Ò$Ô(9¸$Ó(LÕLÕ$Ø�IŠIœ¨Ó;Õ;�Iñ"
ð ××ÐØ×$Ñ$×+Ñ+ð -Qô Rà××ÐØ×$Ñ$×+Ñ+ð -Tô Uà××ÐØ×$Ñ$×+Ñ+ð -Tô Uà××ÐØ×$Ñ$×+Ñ+ð -Tô Uô “eˆØ$(×$:Ô$:Ñ ˆGØÖ)Ø—‘ 
¨GÐAÔBØ—‘ Ö(ñ %;ô “eˆØ$(×$<Ô$<Ñ ˆGØÖ)Ø—‘ ¨gÐCÔDØ—‘ Ö(ñ %=ô “eˆØ#'§9¤9ÑˆLØÖ'Ø—‘  uÐ;Ô<Ø—‘ Ö&ñ $-ð !%× 0Ô 0ÑˆGß&¬,°w×*?Ô*?Ø—‘ ¨gÐ?Ö@ñ !1ð !%× 3Ô 3ÑˆGß&¬,°w×*?Ô*?Ø—‘ °ÐBÖCñ !4ð !%× 3Ô 3ÑˆGß&¬,°w×*?Ô*?Ø—‘ °ÐBÖCñ !4ð !%× 0Ô 0ÑˆGß&¬,°w×*?Ô*?Ø—‘ ¨gÐ?Ö@ñ !1ð ŒØˆr.   c           	     óZ  € V P                   f   V P                  4        \        V P                  4      \        V P                  4      \        V P
                  4      \        V P                  4      \        V P                  4      \        V P                  4      \        V P                  4      3# )a  
Analyze the provided VBA code to detect suspicious keywords,
auto-executable macros, IOC patterns, obfuscation patterns
such as hex-encoded strings.

:return: tuple with the number of items found for each category:
    (autoexec, suspicious, IOCs, hex, base64, dridex, vba)
)
r`  rÞ  r9  rÊ  rË  rÌ  rÍ  rÎ  rÏ  rÐ  ©ra   s   &r,   Úscan_summaryÚVBA_Scanner.scan_summaryR
  s~   € ð �<‰<ÒØ�I‰IŒKÜ�D×*Ñ*Ó+¬S°×1IÑ1IÓ-JÜ�D—I‘I“¤ D×$4Ñ$4Ó 5´s¸4×;NÑ;NÓ7OÜ�D×'Ñ'Ó(¬#¨d×.>Ñ.>Ó*?ðAð 	Ar.   )rÊ  rÎ  rr  rÆ  rÇ  rÃ  rÄ  rÅ  rÈ  rÏ  rÍ  rÌ  r`  rÉ  rË  rÐ  N©FF)
rf   rg   rh   ri   rj   r]   rÞ  râ  rk   rl   r~   s   @r,   rÁ  rÁ  È	  s"   ø‡ € ñò
 ô4h÷TAð Ar.   rÁ  c                ó6   € \        V 4      P                  W4      # )aN  
Analyze the provided VBA code to detect suspicious keywords,
auto-executable macros, IOC patterns, obfuscation patterns
such as hex-encoded strings.
(shortcut for VBA_Scanner(vba_code).scan())

:param vba_code: str, VBA source code to be analyzed
:param include_decoded_strings: bool, if True all encoded strings will be included with their decoded content.
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)
:return: list of tuples (type, keyword, description)
    with type = 'AutoExec', 'Suspicious', 'IOC', 'Hex String', 'Base64 String' or 'Dridex String'
)rÁ  rÞ  )rK  rÛ  rÜ  s   &&&r,   Úscan_vbaræ  c
  s   € ô �xÓ ×%Ñ%Ð&=ÓKÐKr.   c                   óò   a € ] tR tRt o RtRRR]R3R ltR tR tR	 t	R
 t
R tR tR tR tR%R ltR tR tR tR tR tR tR tR%R ltR tR tR tR tR&R ltR tR tR tR  t R! t!R" t"R# t#R$t$V t%R# )'Ú
VBA_Parseriu
  zR
Class to parse MS Office files, to detect VBA macros and extract VBA source code
NTFc                óv  € Vf   TpRV n         M\        V4      pRV n         RV n        . V n        Wn        W0n        W@n        RV n        RV n        RV n	        RV n
        RV n        RV n        RV n        RV n        ^ V n        ^ V n        ^ V n        ^ V n        ^ V n        ^ V n        ^ V n        ^ V n        WPn        . V n        RV n        W`n        RV n        RV n        RV n        RV n        RV n        \@        PB                  ! V P                  VR7      V n"        \F        PI                  RV PD                  PJ                  PL                  : RV PD                  P
                  : 24       \N        PP                  ! V4      '       d"   V PS                  V4       V PU                  4        V P                  f.   \V        PX                  ! V4      '       d   V P[                  V4       V P                  Efz   Vf.   \]        VR4      ;_uu_ 4       pVP_                  4       pRRR4       RV9   d   V Pa                  V4       R	V9   d   V Pc                  V4       VPe                  4       p	V P                  f\   R
V	9   dU   RV	9   dN   RV	9   dG   \g        V	Pi                  R4      V	Pi                  R
4      ,
          4      ^8  d   V Pk                  V4       \l        Pn                  ! VRR7      '       d4   RV P                  ,          p
\F        Pq                  V
4       \s        V
4      hVPu                  R4      '       d   V Pw                  V4       V P                  f   RV9  d   V Py                  V4       V P                  f4   RV P                  ,          p
\F        Pq                  V
4       \s        V
4      hR#   + '       g   i     ELœ; i)a‰  
Constructor for VBA_Parser

:param str filename: filename or path of file to parse, or file-like object

:param bytes data: None or bytes str, if None the file will be read from disk (or from the file-like object).
    If data is provided as a bytes string, it will be parsed as the content of the file in memory,
    and not read from disk. Note: files must be read in binary mode, i.e. open(f, 'rb').

:param str container: str, path and filename of container if the file is within
    a zip archive, None otherwise.

:param bool relaxed: if True, treat mal-formed documents and missing streams more like MS office:
    do nothing; if False (default), raise errors in these cases

:param str encoding: encoding for VBA source code and strings.
    Default: UTF-8 bytes strings on Python 2, unicode strings on Python 3 (None)

raises a FileOpenError if all attempts to interpret the data header failed.
NTFr  zftguess: file type=z - container=Úrbs4   http://schemas.microsoft.com/office/word/2003/wordmls3   http://schemas.microsoft.com/office/2006/xmlPackages   mimes   versions	   multipart)Útreat_str_as_datazL%s is RTF, which cannot contain VBA Macros. Please use rtfobj to analyse it.s   IDó    z;%s is not a supported file type, cannot extract VBA Macros.)=Úfile_on_diskr   Úole_fileÚole_subfilesr_   Ú	containerr~  r’   Úvba_projectsÚ	vba_formsÚcontains_vba_macrosÚcontains_xlm_macrosÚvba_code_all_modulesrÃ  Úanalysis_resultsÚ	nb_macrosÚnb_autoexecÚnb_suspiciousÚnb_iocsÚnb_hexstringsÚnb_base64stringsÚnb_dridexstringsÚnb_vbastringsrQ   Ú
xlm_macrosÚno_xlmÚdisable_pcodeÚpcodedmp_outputÚvba_stomping_detectedÚis_encryptedÚxlm_macrosheet_foundÚtemplate_injection_foundr%   ÚFileTypeGuesserÚftgrU   r  Úftyper¬   ÚolefileÚ	isOleFileÚopen_oleÚopen_pptÚzipfileÚ
is_zipfileÚopen_openxmlÚopenrv  Úopen_word2003xmlÚopen_flatopcr�  ÚabsrR  Úopen_mhtr!   Úis_rtfr  rq   r  Úopen_slkÚ	open_text)ra   r_   r  rð  r~  rQ   r  Ú_fileÚfile_handleÚdata_lowercaser^   s   &&&&&&&    r,   r]   ÚVBA_Parser.__init__{
  s  € ð2 Š<àˆEØ $ˆDÕô ˜D“MˆEØ %ˆDÔàˆŒØˆÔØ ŒØ"ŒØŒØˆŒ	Ø ˆÔØˆŒØ#'ˆÔ Ø#'ˆÔ Ø$(ˆÔ!àˆŒà $ˆÔàˆŒØˆÔØˆÔØˆŒØˆÔØ !ˆÔØ !ˆÔØˆÔà ŒØˆŒØˆŒà*ÔØ#ˆÔà%)ˆÔ"à!ˆÔà$)ˆÔ!Ø(-ˆÔ%ô ×*Ò*¨4¯=©=¸tÔDˆŒÜ�	Š	¸D¿H¹H¿N¹N×<OÔ<OÐQU×QYÑQY×QcÓQcÐdÔeô ×Ò˜U×#Ò#à�M‰M˜%Ô ð �M‰MŒOØ�9‰9Ò¤×!3Ò!3°E×!:Ò!:à×Ñ˜eÔ$Ø�9‰9Óð Š|Ü˜( D×)Ô)¨[Ø&×+Ñ+Ó-�D÷ *ð GÈ$ÔNØ×%Ñ% dÔ+àEÈÔMØ×!Ñ! $Ô'à!ŸZ™Z›\ˆNð —	‘	Ò!Ø˜>Ô)Ø˜nÔ,Ø Ô.Ü�N×(Ñ(¨Ó4°~×7KÑ7KÈGÓ7TÕTÓUÐXZÔZØ—‘˜dÔ#ô �}Š}˜T°T×:Ó:ð eÐgk×gtÑgtÕt�Ü—‘˜”Ü# CÓ(Ð(ð �‰˜u×%Ò%Ø—‘˜dÔ#ð �y‰yÒ  W°DÔ%8Ø—‘˜tÔ$Ø�9‰9ÒàOÐRV×R_ÑR_Õ_ˆCÜ�H‰H�SŒMÜ Ó$Ð$ñ	 ÷O *×)Ð)ús   ÈN'Î'N8	c                ój  € \         P                  RV P                  ,          4        \        P                  ! VRR7      V n        \        V n        R#   \        \        \        3 dK   p\         P                  RT P                  : RT: R24       \         P                  RRR	7        Rp?R# Rp?ii ; i)
z\
Open an OLE file
:param _file: filename or file contents in a file object
:return: nothing
zOpening OLE file %sN)Úpath_encodingzFailed OLE parsing for file r  rµ   r  Tr  )rU   r  r_   r
  Ú	OleFileIOrî  ÚTYPE_OLEr’   r|  r�  r‘   r  )ra   r  rC   s   && r,   r  ÚVBA_Parser.open_ole
  sy   € ô 	�‰Ð&¨¯©Õ6Ô7ð	/ä#×-Ò-¨eÀ4ÔHˆDŒMä ˆDŽIøÜœ¤JÐ/ô 	/ä�HŠH¸d¿m¼mËSÐQÔRÜ�I‰I�h¨ˆI×.Ò.ûð	/ús   ¨(A ÁB2Á(?B-Â-B2c           
     óÌ  € \         P                  RV P                  ,          4        \        P                  ! V4      pVP                  4        Fè  p\         P                  RP                  V4      4       VP                  V4      ;_uu_ 4       pVP                  \        \        P                  4      4      pV\        P                  8X  dc   \         P                  RV,          4       VP                  V4      ;_uu_ 4       pVP                  4       pRRR4        V P                  VXR7       RRR4       Kê  	  VP#                  4        \$        V n        R#   + '       g   i     LM; i  \         dr   pT P                  '       dD   \         P                  T: RT: R24       \         P                  RR	R
7        Rp?RRR4       EK|  \!        T P                  TT4      hRp?ii ; i  + '       g   i     EK­  ; i  \         dd   pT P                  '       dL   \         P                  RP                  YpP                  4      4       \         P                  RR	R
7        Rp?R# h Rp?i\(        \        P*                  \        P,                  \.        3 dK   p\         P                  RT P                  : RT: R24       \         P                  RR	R
7        Rp?R# Rp?ii ; i)z`
Open an OpenXML file
:param _file: filename or file contents in a file object
:return: nothing
zOpening ZIP/OpenXML file %szOpenXML subfile {}zOpening OLE file %s within zipN©r_   r  z is not a valid OLE file (rµ   r  Tr  z4Error {0} caught in Zip/OpenXML parsing for file {1}z$Failed Zip/OpenXML parsing for file r  )rU   r  r_   r  ÚZipFileÚnamelistr  r6   r  rv  r9  r
  ÚMAGICÚappend_subfilerZ   r~  r€   ÚcloseÚTYPE_OpenXMLr’   ÚRuntimeErrorÚ
BadZipfileÚLargeZipFiler|  )ra   r  ÚzÚsubfiler  ÚmagicÚole_datarC   s   &&      r,   r  ÚVBA_Parser.open_openxml  s  € ô 	�‰Ð.°·±Õ>Ô?ðE	/Ü—’ Ó&ˆAð Ÿ:™:ž<�Ü—	‘	Ð.×5Ñ5°gÓ>Ô?Ø—V‘V˜G—_”_¨ð (×,Ñ,¬S´·±Ó-?Ó@�EØ¤§¡Ô-ô< Ÿ	™	Ð"BÀWÕ"LÔMØŸV™V GŸ_œ_°Ø'2×'7Ñ'7Ó'9˜H÷ -ð	>Ø ×/Ñ/¸ÀxÐ/ÔP÷O %‘_ñ (ðd �G‰GŒIä$ˆDŽI÷ -Ÿ_ûô  3ô >Ø#Ÿ|Ÿ|˜|Ü #§¡ËgÓWZÐ)[Ô \Ü #§	¡	¨(¸T 	Ô BÛ (÷Y %’_ô\ '9¸¿¹ÈØ9<ó'>ð !>ûð>ú÷Q %—_‘_ûôf #ô 	Ø�|�|ˆ|Ü—‘ÐOß ™& §m¡mÓ4ô6ä—	‘	˜(¨T�	×2Ò2àûÜœg×0Ñ0´'×2FÑ2FÌÐPô 	/ä�HŠHØ!Ÿ]œ]«Cð1ô 2ä�I‰I�h¨ˆI×.Ò.ûð		/ús“   ¨A&G> ÂA3G)ÄEÄG)ÄE*Ä.'G> ÅE'Å"G)Å*G&	Å5AG!	Æ;G)Æ?G> Ç
G!	Ç!G&	Ç&G)Ç)G;Ç4
G> Ç>K#È	AI'É&I'É'0K#ÊK#Ê?KËK#c                óH  € \         P                  RV P                  ,          4        \        P                  ! V4      pVP                  \        4       F†  pVP                  \        R4      p\        P                  ! VP                  4      p\        V4      '       d!    \        V4      pV P                  WFR7       Kj  \         P                  R	V,          4       Kˆ  	  \(        V n        R#   \         do   pT P                   '       dB   \         P                  RP#                  YG4      4       \         P%                  RRR7        Rp?Kõ  \'        T P                  YG4      hRp?ii ; i  \         d^   pT P                   '       dF   \         P                  R
T P                  : RT: R24       \         P%                  RRR7        Rp?R# h Rp?i\,         dK   p\         P                  R
T P                  : RT: R24       \         P%                  RRR7        Rp?R# Rp?ii ; i)z\
Open a Word 2003 XML file
:param data: file contents in a string or bytes
:return: nothing
zOpening Word 2003 XML file %sz
noname.msor#  úError parsing subfile {0}: {1}r  Tr  Nz%s is not a valid MSO fileúFailed XML parsing for file r  rµ   )rU   r  r_   ÚETÚ
fromstringÚiterÚTAG_BINDATAr€  Ú	ATTR_NAMErç   rì   Útextr  r$  r'  rZ   r~  r6   r  r€   ÚTYPE_Word2003_XMLr’   r‚  )ra   r  ÚetÚbindataÚfnameÚmso_datar0  rC   s   &&      r,   r  ÚVBA_Parser.open_word2003xmlm  s„  € ô 	�‰Ð0°4·=±=Õ@ÔAð(	/ô —’˜tÓ$ˆBàŸ7™7¤;Ö/�ð  Ÿ™¤I¨|Ó<�ä#×.Ò.¨w¯|©|Ó<�Ü˜x×(Ò(ð	PÜ#3°HÓ#=˜Ø×+Ñ+°UÐ+ÖJô —H‘HÐ9¸EÕAÖBñ+ 0ô. *ˆDŽIøô /ô PØŸ<Ÿ<˜<ÜŸH™HÐ%Eß&,¡f¨UÓ&8ô:äŸI™I h¸˜I×>Ò>ä"4°T·]±]ÀEÓ"OÐOûðPûô #ô 	Ø�|�|ˆ|Ü—’À$Ç-Ä-ÓQTÐUÔVÜ—	‘	˜(¨T�	×2Ò2àûÜô 	/ô �HŠH¸d¿m¼mËSÐQÔRÜ�I‰I�h¨ˆI×.Ò.ûð	/úsb   ¨A5E& ÂC*Â;-E& Ã*E#Ã5AEÅE& ÅEÅE#Å#E& Å&H!Å1AG	ÇG	Ç	H!ÇH!Ç?HÈH!c           	     óR  € \         P                  RV P                  ,          4        \        P                  ! V4      pVP                  \        4       F‹  pVP                  \        R4      pVP                  \        R4      pV\        8X  g   K<  VP                  \        4       F6  p \        P                  ! VP                  4      pV P!                  WGR7       K8  	  K�  	  \,        V n        R#   \"         do   pT P$                  '       dB   \         P                  RP'                  YH4      4       \         P)                  RRR7        Rp?K©  \+        T P                  YH4      hRp?ii ; i  \"         d^   pT P$                  '       dF   \         P                  R	T P                  : R
T: R24       \         P)                  RRR7        Rp?R# h Rp?i\0         dK   p\         P                  R	T P                  : R
T: R24       \         P)                  RRR7        Rp?R# Rp?ii ; i)z{
Open a Word or PowerPoint 2007+ XML file, aka "Flat OPC"
:param data: file contents in a string or bytes
:return: nothing
z,Opening Flat OPC Word/PowerPoint XML file %sÚunknownr#  r3  r  Tr  Nr4  r  rµ   )rU   r  r_   r5  r6  r7  ÚTAG_PKGPARTr€  ÚATTR_PKG_NAMEÚATTR_PKG_CONTENTTYPEÚCTYPE_VBAPROJECTÚiterfindÚTAG_PKGBINDATArç   rì   r:  r'  rZ   r~  r6   r  r€   ÚTYPE_FlatOPC_XMLr’   r‚  )	ra   r  r<  Úpkgpartr>  Úcontent_typer=  r0  rC   s	   &&       r,   r  ÚVBA_Parser.open_flatopcž  s‹  € ô 	�‰Ð?À$Ç-Á-ÕOÔPð"	/ô —’˜tÓ$ˆBð Ÿ7™7¤;Ö/�ØŸ™¤M°9Ó=�Ø&Ÿ{™{Ô+?ÀÓK�ØÔ#3Ö3Ø#*×#3Ñ#3´NÖ#C˜ð	TÜ'/×':Ò':¸7¿<¹<Ó'H˜HØ ×/Ñ/¸Ð/ÖNó $Dñ	 0ô  )ˆDŽIøô  3ô TØ#Ÿ|Ÿ|˜|Ü #§¡Ð)Iß*0©&°Ó*<ô!>ä #§	¡	¨(¸T 	× BÒ Bä&8¸¿¹ÈÓ&SÐ SûðTûô #ô 	Ø�|�|ˆ|Ü—’À$Ç-Ä-ÓQTÐUÔVÜ—	‘	˜(¨T�	×2Ò2àûÜô 	/ô �HŠH¸d¿m¼mËSÐQÔRÜ�I‰I�h¨ˆI×.Ò.ûð	/úsh   ¨A"E+ ÂE+ Â(2C/ÃE+ Ã/E(Ã:AE#ÅE+ ÅE#Å#E(Å(E+ Å+H&Å6AGÇGÇH&ÇH&Ç?H!È!H&c                ó�  € \         P                  RV P                  ,          4        VP                  R4      pVP	                  R4      pVP	                  R4      pRTu;8  d   V8:  d	   M MW#R pMVR8”  d   W$R p\
        P                  P                  p\        P                  ! R4      pV\
        P                  n         \        '       d   \
        P                  ! V4      pM\
        P                  ! V4      pV\
        P                  n        VP                  4        Fø  pVP                  4       p	VP                  R4      p
\         P!                  RV
: RV	: 24       VP#                  R	R
7      p\%        V\&        4      '       dG   \)        V4      '       d6   \         P!                  R4        \+        V4      pV P-                  W¬R7       K¯  \         P!                  R\5        V4      ,          4        \         P!                  RVR,          ,          4       Kú  	  \8        V n        R#   T\
        P                  n        i ; i  \.         di   pT P0                  '       d<   \         P                  T
: RT: R24       \         P!                  RR	R7        Rp?EK{  \3        T P                  Y­4      hRp?ii ; i  \6         d"   p\         P!                  R4        Rp?EKÀ  Rp?ii ; i  \.         d    h \:         dG    \         P                  RT P                  : R\<        : 24       \         P!                  RR	R7        R# i ; i)zT
Open a MHTML file
:param data: file contents in a string or bytes
:return: nothing
zOpening MHTML file %ss   
	 s   MIMEs   ContentNz)^(From |[\041-\071\073-\176]{1,}:?|[\t ])zMHTML part: filename=z, content-type=T)rO   z4Found ActiveMime header, decompressing MSO containerr#  z$ does not contain a valid OLE file (rµ   r  r  ztype(part_data) = %szpart_data[0:20] = %r:rÀ   é   Nzpart_data has no __getitem__zFailed MIME parsing for file r¦  rà   )rU   r  r_   ÚlstripÚfindÚemailÚ
feedparserÚheaderRErY  ÚcompilerJ   Úmessage_from_stringÚmessage_from_bytesÚwalkÚget_content_typeÚget_filenamer  Úget_payloadr<   r?  r  r$  r'  rZ   r~  r€   r’   r�  Ú
TYPE_MHTMLr‚  ÚMSG_OLEVBA_ISSUES)ra   r  Ústripped_dataÚmime_offsetÚcontent_offsetÚoldHeaderREÚloosyHeaderREÚmhtmlr®   rK  r>  Ú	part_datar0  rC   Úerrs   &&             r,   r  ÚVBA_Parser.open_mhtÉ  s•  € ô 	�‰Ð(¨4¯=©=Õ8Ô9ðG	/ð !ŸK™K¨
Ó3ˆMð (×,Ñ,¨WÓ5ˆKØ*×/Ñ/°
Ó;ˆNà�KÖ1 >×1Ø -¨lÐ ;‘ð   "Ô$Ø -¨oÐ >�ô  ×*Ñ*×3Ñ3ˆKÜŸJšJÐ'SÓTˆMØ(5ŒE×ÑÔ%ð8ß“7Ü!×5Ò5°mÓD‘Eô "×4Ò4°]ÓC�Eà,7”× Ñ Ô)àŸ
™
ž�Ø#×4Ñ4Ó6�Ø×)Ñ)¨$Ó/�ä—	’	ËÊ|Ð\Ô]Ø ×,Ñ,°DÐ,Ó9�	ô ˜i¬×/Ò/´KÀ	×4JÒ4JÜ—I‘IÐTÔUðPÜ#3°IÓ#>˜ð ×+Ñ+°UÐ+ÖJô —I‘IÐ4´t¸I³ÕFÔGðBÜŸ	™	Ð"8¸9ÀT½?Õ"JÖKñ= %ôD #ˆDŽIøðI -8”× Ñ Õ)ûô* /ô PØŸ<Ÿ<˜<ÜŸH™HÛ).³ð&5ô 6äŸI™I h¸˜I×>Ó>ô #5°T·]±]ÀEÓ"OÐOûðPûô %ô BÜŸ	™	Ð"@×AÓAûðBûô #ô 	ØÜô 	/Ü�HŠHØ!Ÿ]œ]Ö,=ð?ô @ä�I‰I�h¨ˆI×.ð	/ús“   ¨BK) ÃH* Ã-H* Ã<B4K) Æ1IÇ'K) Ç6#J:ÈK) È*IÉK) ÉJ7ÉAJ2ÊK) ÊJ2Ê2J7Ê7K) Ê:K&ËK!ËK) Ë!K&Ë&K) Ë)MË>AMÍMc                ó0  € \         P                  R4        \        P                  ! V P                  RR7      pVP                  4        F  pV P                  RVRR7       K  	  \         P                  R4       V P                  P                  4        RV n        \        V n	        R#   \        P                  \        3 dT   pT P                  R8X  d   \         P                  R4        Rp?R# \         P                  R	T,          4        Rp?R# Rp?ii ; i)
až  try to interpret self.ole_file as PowerPoint 97-2003 using PptParser

Although self.ole_file is a valid olefile.OleFileIO, we set
self.ole_file = None in here and instead set self.ole_subfiles to the
VBA ole streams found within the main ole file. That makes most of the
code below treat this like an OpenXML file and only look at the
ole_subfiles (except find_vba_* which needs to explicitly check for
self.type)
zCheck whether OLE file is PPTT)Ú	fast_failNÚ	PptParser)rð  zFile is PPTzPPT subfile is not a PPT filez&File appears not to be a ppt file (%s))rU   r  r   rh  rî  Úiter_vba_datar'  r(  ÚTYPE_PPTr’   ÚPptUnexpectedDatar‘   rð  r  )ra   ÚpptÚvba_datarC   s   &   r,   r  ÚVBA_Parser.open_ppt  sÍ   € ô 	�‰Ð0Ô1ð	JÜ×&Ò& t§}¡}ÀÔEˆCØ×-Ñ-Ö/�Ø×#Ñ# D¨(¸kÐ#ÖJñ 0ä�H‰H�]Ô#Ø�M‰M×ÑÔ!Ø ˆDŒMÜ ˆDŽIøÜ×,Ñ,¬jÐ9ô 	JØ�~‰~ Ô,ä—	‘	Ð9×:Ò:ä—	‘	ÐBÀSÕH×IÒIûð	Jús   —BB' Â'DÃ&DÃ.DÄDc           	     óÐ  € \         P                  RV P                  ,          4       Rp. pVP                  R4       VP	                  R4       EFt  pVP                  R4      '       dK   VP                  R4       F3  pVP                  R4      '       g   K  Rp\         P                  R4       K5  	  Ke  VP                  R	4      '       d{   V'       ds   VP                  R4       F[  pVP                  R
4      '       g   K  VP                  4       R	8w  g   K3  VP                  R\        VR,          4      ,          4       K]  	  Kö  VP                  R4      '       g   EK  V'       g   EK  VP                  R4       FD  pVP                  R4      '       g   K  VP                  R\        VR,          4      ,          4       KF  	  EKw  	  V'       d   RV n
        W0n        \        V n        R# )zu
Open a SLK file, which may contain XLM/Excel 4 macros
:param data: file contents in a bytes string
:return: nothing
zOpening SLK file %sFz8Formulas and XLM/Excel 4 macros extracted from SLK file:ó   Oó   ;ó   ETzSLK parser: found macro sheets   NNó   NzNamed cell: %srµ  ó   CzFormula or Macro: %sN)rU   r  r_   r>  rP  r  r2  r  rÞ   rR   rô  rÿ  ÚTYPE_SLKr’   )ra   r  Úxlm_macro_foundrÿ  r7  r)  s   &&    r,   r  ÚVBA_Parser.open_slk5  sU  € ô 	�‰Ð&¨¯©Õ6Ô7ØˆØˆ
Ø×ÑÐTÔUØ—O‘O E×*ˆDØ�‰˜t×$Ò$àŸ™ DÖ)�AØ—|‘| D×)Ô)Ø*.˜ÜŸ	™	Ð"AÖBó *ð —‘ ×'Ò'¯OàŸ™ DÖ)�AØ—|‘| D×)Ô)¨a¯g©g«i¸5Ö.@Ø"×)Ñ)Ð*:¼YÀqÈÅuÓ=MÕ*MÖNó *ð —‘ ×&Õ&¯?ª?àŸ™ DÖ)�AØ—|‘| D×)Ô)Ø"×)Ñ)Ð*@Ä9ÈQÈrÍUÓCSÕ*SÖTô *ñ +÷" Ø'+ˆDÔ$Ø(ŒOÜˆŽ	r.   c                ó–   € \         P                  RV P                  ,          4       \        V4      V n        RV n        \        V n        R# )zz
Open a text file containing VBA or VBScript source code
:param data: file contents in a string or bytes
:return: nothing
zOpening text file %sTN)rU   r  r_   rR   rõ  ró  Ú	TYPE_TEXTr’   )ra   r  s   &&r,   r  ÚVBA_Parser.open_textW  s7   € ô 	�‰Ð'¨$¯-©-Õ7Ô8ô %.¨d£OˆÔ!Ø#'ˆÔ äˆŽ	r.   c                ó”   € V P                   P                  \        WVV P                  V P                  V P
                  R7      4       R# )zB
Create sub-parser for given subfile/data and append to subfiles.
)r~  rQ   r  N)rï  r>  rè  r~  rQ   r  )ra   r_   r  rð  s   &&&&r,   r'  ÚVBA_Parser.append_subfilef  s<   € ð 	×Ñ× Ñ ¤¨H¸IØ48·L±LØ59·]±]Ø:>×:LÑ:Lô"Nö 	Or.   c                óF  € \         P                  R4       V P                  f   V P                  \        8w  d   R# V P
                  e   V P
                  # V P                  \        8X  de   \         P                  R4       . V n        V P                   F,  pV P
                  P                  VP                  4       4       K.  	  V P
                  # R p. V n        V P                  pVP                  RRR7       EF  p\         P                  RV,          4       VR,          P                  4       R	8X  g   K>  \         P                  R
RP                  V4      ,          4       RP                  VRR 4      pVR8w  d
   VR,          p\         P                  RV,          4       V! W5R4      pV'       g   K¼  V! W5R4      pV'       g   KÏ  V! W5R4      pV'       g   Kâ  \         P                  RV,          4       V P
                  P                  WVV34       EK  	  V P
                  # )aï  
Finds all the VBA projects stored in an OLE file.

Return None if the file is not OLE but OpenXML.
Return a list of tuples (vba_root, project_path, dir_path) for each VBA project.
vba_root is the path of the root OLE storage containing the VBA project,
including a trailing slash unless it is the root of the OLE file.
project_path is the path of the OLE stream named "PROJECT" within the VBA project.
dir_path is the path of the OLE stream named "VBA/dir" within the VBA project.

If this function returns an empty list for one of the supported formats
(i.e. Word, Excel, Powerpoint), then the file does not contain VBA macros.

:return: None if OpenXML file, list of tuples (vba_root, project_path, dir_path)
for each VBA project found if OLE file
zVBA_Parser.find_vba_projectsNú,Returned info is not complete for PPT types!c                 ó  € W,           pV P                  V4      '       dD   V P                  V4      \        P                  8X  d    \        P                  R V: RV: 24       V# \        P                  RV,          4       R# )zFound z	 stream: z<Missing %s stream, this is not a valid VBA project structureF)ÚexistsÚget_typer
  ÚSTGTY_STREAMrU   r  )rz  ry  r“   Ú	full_paths   &&& r,   Úcheck_vba_streamÚ6VBA_Parser.find_vba_projects.<locals>.check_vba_stream¥  s\   € Ø Õ.ˆIØ�z‰z˜)×$Ò$¨¯©°iÓ)@ÄG×DXÑDXÔ)XÜ—	’	³;Â	ÐJÔKØ Ð ä—	‘	ÐXÐ[fÕfÔgÙr.   FT©ÚstreamsÚstoragesúChecking storage %rÚVBAzFound VBA storage: %srƒ   r3   zChecking vba_root="%s"ÚPROJECTzVBA/_VBA_PROJECTzVBA/dirzVBA root storage: "%s"rà   )rU   r  rî  r’   rj  rñ  r;  rï  r=  Úfind_vba_projectsÚlistdirÚupperr>   r>  )	ra   r.  r„  rz  Ústoragery  rÁ  Úvba_project_pathrÂ  s	   &        r,   rŒ  ÚVBA_Parser.find_vba_projectso  s½  € ô" 	�	‰	Ð0Ô1ð �=‰=Ò  T§Y¡Y´(Ô%:Ùð ×ÑÒ(Ø×$Ñ$Ð$ð
 �9‰9œÔ ô �K‰KÐFÔGØ "ˆDÔØ×,Ô,�Ø×!Ñ!×(Ñ(¨×)BÑ)BÓ)DÖEñ -à×$Ñ$Ð$ò 	ð ˆÔà�m‰mˆØ—{‘{¨5¸4�{×@ˆGÜ�I‰IÐ+¨gÕ5Ô6à�r�{× Ñ Ó" eÖ+Ü—	‘	Ð1°S·X±X¸gÓ5FÕGÔHØŸ8™8 G¨C¨R LÓ1�ð ˜r”>Ø •O�HÜ—	‘	Ð2°XÕ=Ô>ñ  0°¸yÓI�ß#¡Xá#3°CÐCUÓ#VÐ ß'©á+¨C¸9ÓE�ß¡ä—	‘	Ð2°XÕ=Ô>à×!Ñ!×(Ñ(¨(À(Ð)K×Lñ1 Að2 × Ñ Ð r.   c                ó‚   € V P                  4       pRpV P                  '       g   V P                  4       pT;'       g    T# )a  
Detect the potential presence of VBA or Excel4/XLM macros in the file,
by calling detect_vba_macros and detect_xlm_macros.
(if the no_xlm option is set, XLM macros are not checked)

:return: bool, True if at least one VBA project has been found, False otherwise
F)Údetect_vba_macrosr   Údetect_xlm_macros)ra   re  Úxlms   &  r,   Údetect_macrosÚVBA_Parser.detect_macrosÍ  s:   € ð ×$Ñ$Ó&ˆØˆØ�{�{ˆ{Ø×(Ñ(Ó*ˆCØ—
�
�sÐr.   c                óP  € \         P                  R4       V P                  e   V P                  # V P                  fr   V P                   FX  p\         P                  RP                  V4      4       V P                  Vn        VP                  4       '       g   KP  RV n         R# 	  RV n        R# V P                  4       p\        V4      ^ 8X  d	   RV n        MRV n        V P                  p\        \        VP                  4      4       EF…  p\         P                  RV,          4       VP                  V,          pVf'   VP                  V4      p\         P                  R4       VP                  \        P                  8X  g   K~  \         P                  RVP                   VP"                  3,          4        VP%                  VP&                  VP"                  4      P)                  4       p\         P                  R	\        V4      ,          4       \        V4      ^È8”  d(   \         P                  VR
,          : RVRR : 24       M\         P                  \+        V4      4       RV9   d    \         P                  R4       RV n        EK…  EKˆ  	  V P                  #   \,         d}   pT P.                  '       dE   \         P1                  RTP                   ,          4       \         P                  RRR7        Rp?EK÷  \3        T P4                  TP                   T4      hRp?ii ; i)ay  
Detect the potential presence of VBA macros in the file, by checking
if it contains VBA projects. Both OLE and OpenXML files are supported.

Important: for now, results are accurate only for Word, Excel and PowerPoint

Note: this method does NOT attempt to check the actual presence or validity
of VBA macro source code, so there might be false positives.
It may also detect VBA macros in files embedded within the main file,
for example an Excel workbook with macros embedded into a Word
document without macros may be detected, without distinction.

:return: bool, True if at least one VBA project has been found, False otherwise
zdetect vba macrosNzole subfile {}TFúChecking DirEntry #%dú$This DirEntry is an orphan or unusedz,Reading data from stream %r - size: %d byteszRead %d bytes:Néd   Nz...[much more data]...s	   Attribut zFound VBA compressed codez Error when reading OLE Stream %rr  )Ú	exc_traceiÎÿÿÿ)rU   r  ró  rî  rï  r6   r   r“  rŒ  r9  r>  Ú
direntriesÚ_load_direntryÚ
entry_typer
  r‚  r¬   r†  Ú_openÚ
isectStartrv  Úreprr|  r~  r  r€   r_   )ra   Úole_subfilerñ  rz  ÚsidÚdr  rC   s   &       r,   r“  ÚVBA_Parser.detect_vba_macrosÛ  sW  € ô 	�	‰	Ð%Ô&ð ×#Ñ#Ò/Ø×+Ñ+Ð+à�=‰=Ò Ø#×0Ô0�Ü—	‘	Ð*×1Ñ1°+Ó>Ô?Ø%)§[¡[�Ô"Ø×0Ñ0×2Ô2Ø/3�DÔ,Úñ  1ð (-ˆDÔ$Ùà×-Ñ-Ó/ˆÜˆ|Ó Ô!Ø',ˆDÕ$à'+ˆDÔ$ð �m‰mˆÜœ#˜cŸn™nÓ-×.ˆCä�I‰IÐ-°Õ3Ô4Ø—‘˜sÕ#ˆAØŠyà×&Ñ& sÓ+�Ü—	‘	Ð@ÔAØ�|‰|œw×3Ñ3Ö3ä—	‘	ÐHÈAÏFÉFÐTU×TZÑTZÐK[Õ[Ô\ðMØŸ9™9 Q§\¡\°1·6±6Ó:×?Ñ?ÓA�DÜ—I‘I˜o´°D³	Õ9Ô:Ü˜4“y 3”ÜŸ	™	À$ÀtÇ*À*ÈdÐSVÐSWÊjÐ"YÕZäŸ	™	¤$ t£*Ô-Ø&¨$Ô.ÜŸ	™	Ð"=Ô>Ø37˜×0ò /ñ% /ð6 ×'Ñ'Ð'øô ô MØ—|—|�|ÜŸ™Ð!CÀaÇfÁfÕ!LÔMÜŸ	™	 (°d˜	×;Ó;ä0°·±ÀÇÁÈÓLÐLûðMús    Æ9CJÊL%Ê)AL Ë?!L Ì L%c                ó  € \         P                  R4       V P                  e   V P                  # V P                  \        8X  d   V P                  # . V n        V P                  P                  4       '       g
   RV n        R# \        '       d:   V P                  '       g   \         P                  R4       M V P                  4       # V P                  f   R# V P                  4       #   \         d    \         P                  R4        LBi ; i)aÎ  
Detect the potential presence of Excel 4/XLM macros in the file, by checking
if it contains a macro worksheet. Both OLE and OpenXML files are supported.
Only Excel files may contain XLM macros, and also SLK and CSV files.

If XLMMacroDeobfuscator is available, it will be used. Otherwise plugin_biff
is used as fallback (plugin_biff only supports OLE files, not XLSX or XLSB)

:return: bool, True if at least one macro worksheet has been found, False otherwise
zdetect xlm macrosFzcXLMMacroDeobfuscator only works with files on disk, not in memory. Analysis might be less complete.z'Error when running XLMMacroDeobfuscator)rU   r  rô  r’   ru  rÿ  r  Úis_excelÚXLMDEOBFUSCATORrí  r;  Ú_extract_xlm_xlmdeobfr‚  r  rî  Ú_extract_xlm_plugin_biffrá  s   &r,   r”  ÚVBA_Parser.detect_xlm_macros!  sß   € ô 	�	‰	Ð%Ô&à×#Ñ#Ò/Ø×+Ñ+Ð+à�9‰9œÔ Ø×+Ñ+Ð+àˆŒà�x‰x× Ñ ×"Ò"Ø',ˆDÔ$Ùß‹?ð ×$×$Ð$Ü—‘ð  Bõ  CðIØ×5Ñ5Ó7Ð7ð �=‰=Ò áØ×,Ñ,Ó.Ð.øô !ô IÜ—I‘IÐGÖHðIús   Â6C& Ã& D	ÄD	c           	     ó¼  € \         P                  R4       R\        n        R.p\        P                  ! V P
                  RRR^RR7      p\        V4      ^ 8X  d
   RV n        R# W,          pVP                  R4       VP                  R4       \        P                  ! V P
                  RRR^R7      pW,          p\         P                  V4       Wn	        RV n        R# )	z�
Run XLMMacroDeobfuscator to detect and extract XLM macros
:return: bool, True if at least one macro worksheet has been found, False otherwise
z=Calling XLMMacroDeobfuscator to detect and extract XLM macrosTzRAW EXCEL4/XLM MACRO FORMULAS:)ÚfileÚnoninteractiveÚnoindentÚreturn_deobfuscatedÚtimeoutÚextract_onlyFz3EMULATION - DEOBFUSCATED EXCEL4/XLM MACRO FORMULAS:)r®  r¯  r°  r±  r²  zL- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - )
rU   r  ÚxlmdeobfuscatorÚSILENTÚprocess_filer_   r9  rô  r>  rÿ  )ra   r•  r‰  s   &  r,   rª  Ú VBA_Parser._extract_xlm_xlmdeobfI  sÅ   € ô
 	�	‰	ÐQÔRØ!%ŒÔà/Ð0ˆä ×-Ò-°4·=±=Ø:>Ø48à?CØ35Ø8<ô-ˆô ˆv‹;˜!Ôà',ˆDÔ$ÙØ�ˆØ�
‰
�9ÔØ�
‰
ÐHÔIÜ ×-Ò-°4·=±=Ø:>Ø48à?CØ35ô-ˆð 	�ˆÜ�	‰	�#ŒØŒØ#'ˆÔ Ùr.   c                ó¬  € \         P                  R4       R EF‡  pV P                  P                  V4      '       g   K'  \         P                  RV,          4       V P                  P	                  V4      P                  4       p\         P                  R4        \        V.VRR7      pVP                  4       V n        RRP                  V P                  4      9   dÂ   \         P                  R4       \        V.VR	R7      pV ;P                  VP                  4       ,          un        \        V.VR
R7      pV ;P                  VP                  4       ,          un        \        V.VRR7      pV ;P                  VP                  4       ,          un        RV n
         R# EKŠ  	  RV n
        R#    \         P                  R\        ,          4        EK»  ; i)z†
Run plugin_biff to detect and extract XLM macros
:return: bool, True if at least one macro worksheet has been found, False otherwise
r«  zFound Excel stream %rz Running BIFF plugin from oledumpz-o BOUNDSHEET)r¬   ÚstreamÚoptionszExcel 4.0 macro sheetrO  zFound XLM macrosz-o LABEL -r LNz-c -r LNz-o DCONN -sTz;Error when running oledump.plugin_biff, please report to %sF)ÚWorkbookÚBook)rU   r  rî  r€  r{  rv  r   ÚAnalyzerÿ  r>   rô  rÖ   ÚURL_OLEVBA_ISSUES)ra   Úexcel_streamr  Úbiff_plugins   &   r,   r«  Ú#VBA_Parser._extract_xlm_plugin_biffp  sm  € ô
 	�	‰	Ð,Ô-Ü0ˆLØ�}‰}×#Ñ# L×1Ô1Ü—	‘	Ð1°LÕ@ÔAØ—}‘}×/Ñ/°Ó=×BÑBÓD�Ü—	‘	Ð<Ô=ðuô #(¨l¨^ÀDÐRaÔ"b�KØ&1×&9Ñ&9Ó&;�D”OØ.°$·)±)¸D¿O¹OÓ2LÔLÜŸ	™	Ð"4Ô5ä&+°,°ÈÐVfÔ&g˜ØŸš¨;×+>Ñ+>Ó+@Õ@�Ü&+°,°ÈÐV`Ô&a˜ØŸš¨;×+>Ñ+>Ó+@Õ@�ô ',°,°ÈÐVcÔ&d˜ØŸš¨;×+>Ñ+>Ó+@Õ@�Ø37˜Ô0Ú#ò Mñ 1ð4 $)ˆÔ ÙøðuÜ—M‘MÐ"_ÔbsÕ"s×tÐtús   ÂDF-Æ-"Gc                óˆ   € V P                   '       d&   \        P                  ! V P                   4      V n        V P                  # r)   )rî  r"   r  rá  s   &r,   Údetect_is_encryptedÚVBA_Parser.detect_is_encrypted“  s.   € Ø�=�=ˆ=Ü &× 3Ò 3°D·M±MÓ BˆDÔØ× Ñ Ð r.   c                óö   € R pV P                  4       '       da   \        P                  pV'       d(   \        V\        4      '       d   VP                  V4       \        P                  ! V P                  V4      pV# r)   )rÃ  r"   ÚDEFAULT_PASSWORDSr<   rª  r=  Údecryptr_   )ra   Úpasswords_listÚdecrypted_fileÚ	passwordss   &&  r,   Údecrypt_fileÚVBA_Parser.decrypt_file˜  sX   € ØˆØ×#Ñ#×%Ò%Ü×0Ñ0ˆIß¤*¨^¼T×"BÒ"BØ× Ñ  Ô0Ü#Ÿ^š^¨D¯M©M¸9ÓEˆNàÐr.   c                ó\   € V P                   f   V# VP                  V P                   RR7      # )zù
Encode a unicode string to bytes or str, using the specified encoding
for the VBA_parser. By default, it will be bytes/UTF-8 on Python 2, and
a normal unicode string on Python 3.
:param str unicode_str: string to be encoded
:return: encoded string
rG   rH   )rQ   rK   )ra   Úunicode_strs   &&r,   Úencode_stringÚVBA_Parser.encode_string¢  s.   € ð �=‰=Ò ØÐà×%Ñ% d§m¡m¸IÐ%ÓFÐFr.   c              #  ó¼	  "  € \         P                  R4       V P                  Ef   V P                  \        8X  d)   V P
                  RV P
                  V P                  3x € R# V P                  \        8X  dK   V P                  '       d7   RpV P                   F  pVRV,           R,           ,          pK  	  RRRV3x € R# R# V P                   F  pVP                  4        F  pVx € K	  	  K   	  V P                  '       d7   RpV P                   F  pVRV,           R,           ,          pK  	  RRRV3x € R# R# V P                  4        \        4       pV P                   Fm  w  rgp \        V P                  WgW€P                  4       FA  w  ršpVP!                  V P                  P#                  V	4      4       V P
                  WšV3x € KC  	  Ko  	  V P                  p\)        \+        VP,                  4      4       EF£  p\         P                  R	V,          4       WÕ9   d   \         P                  R
4       K=  VP,                  V,          pVf'   VP/                  V4      p\         P                  R4       VP0                  \2        P4                  8X  g   K›  \         P                  RVP6                  ,          4       VP9                  VP:                  VP<                  4      P?                  4       p\@        PB                  ! RV\@        PD                  R7       Fƒ  pVPG                  4       ^,
          p\         P                  RV,          4       VVR p \I        \K        V4      4      p\M        VRR7      pV P
                  VP6                  VP6                  V3x € K…  	  EK¦  	  V P                  '       d5   RpV P                   F  pVRV,           R,           ,          pK  	  RRRV3x € V PO                  4       '       dE   RpV PP                  PS                  4        F  pVRV,           R,           ,          pK  	  RRRV3x € R# R#   \$         d"   p\         P'                  R4        Rp?EK  Rp?ii ; i  \$         dZ   p\         P                  RTP6                  : RT P
                  : RT: R24       \         P                  RRR7        Rp?EK¼  Rp?ii ; i5i)a§  
Extract and decompress source code for each VBA macro found in the file

Iterator: yields (filename, stream_path, vba_filename, vba_code) for each VBA macro found
If the file is OLE, filename is the path of the file.
If the file is OpenXML, filename is the path of the OLE subfile containing VBA macros
within the zip archive, e.g. word/vbaProject.bin.
If the file is PPT, result is as for OpenXML but filename is useless
zextract_macros:Nr3   z' rO  Ú	xlm_macrozxlm_macro.txtzError in _extract_vbar™  zAlready extractedrš  zReading data from stream %rs   \x00Attribut[^e])Úflagsz%Found VBA compressed code at index %XÚcp1252)rQ   zError processing stream z	 in file r  rµ   ú
Traceback:Tr  z
VBA P-codezVBA_P-code.txt)*rU   r  rî  r’   ry  r_   rõ  ru  rÿ  rï  Úextract_macrosrŒ  r&  rñ  rH  r~  ro  Ú_findr‚  rÖ   r>  r9  r�  rž  rŸ  r
  r‚  r¬   r   r¡  r†  rv  rY  r   Ú
IGNORECASEr@   rS  r8  rR   Údetect_vba_stompingr  rP  )ra   rK  r7  r£  r`  Úvba_stream_idsry  rÁ  rÂ  r“   Úvba_filenamer�   rz  r¤  r¥  r  r#  r@   Úcompressed_codeÚvba_code_bytesÚvba_code_strrC   s   &                     r,   rÖ  ÚVBA_Parser.extract_macros¯  sÜ  é € ô 	�	‰	Ð#Ô$Ø�=‰=Ó à�y‰yœIÔ%à—}‘} b¨$¯-©-¸×9RÑ9RÐSÔSØ—‘œhÔ&Ø—?—?�?Ø!�HØ $§¤˜Ø  D¨4¥K°$Õ$6Õ6šñ !0à&¨°_ÀhÐOÔOñ	 #ð $(×#4Ô#4�KØ#.×#=Ñ#=Ö#?˜Ø%œó $@ñ $5ð —?—?�?Ø!�HØ $§¤˜Ø  D¨4¥K°$Õ$6Õ6šñ !0à&¨°_ÀhÐOÔOñ	 #ð ×"Ñ"Ô$ä ›UˆNØ48×4EÔ4EÑ0�¨ð
;ä(¨¯©¸Ø)1·<±<öAñ <˜°8ð '×*Ñ*¨4¯=©=×+>Ñ+>¸{Ó+KÔLØ#Ÿ}™}¨kÈÐRÔRó	Añ 5Fð  —-‘-ˆCÜœc #§.¡.Ó1×2�ä—	‘	Ð1°CÕ7Ô8ØÔ(Ü—I‘IÐ1Ô2ÙØ—N‘N 3Õ'�Ø’9à×*Ñ*¨3Ó/�AÜ—I‘IÐDÔEØ—<‘<¤7×#7Ñ#7Ö7ä—I‘IÐ;¸a¿f¹fÕDÔEØŸ9™9 Q§\¡\°1·6±6Ó:×?Ñ?ÓA�DÜ!#§¢Ð-AÀ4ÌrÏ}É}×!]˜Ø %§¡£°Õ 1˜ÜŸ	™	Ð"IÈEÕ"QÔRØ*.¨u¨v¨,˜ðCÜ->¼yÈÓ?YÓ-Z˜Nô ,5°^ÈhÔ+W˜LØ#'§=¡=°!·&±&¸!¿&¹&À,Ð"OÔOô "^ñ 3ðF ��ˆØ�Ø ŸOœO�DØ  t¥¨dÕ 2Õ2’Hñ ,à" K°À(ÐKÒKð ×'Ñ'×)Ò)Ø�Ø ×0Ñ0×;Ñ;Ö=�DØ  t¥¨dÕ 2Õ2’Hñ >à# \Ð3CÀXÐNÔNñ	 *øôa !ô ;Ü—M‘MÐ"9×:Ó:ûð;ûôF  )ô CäŸIšIÐVW×V\ÔV\Ð^b×^kÔ^kÓmpÐ&qÔrÜŸI™I l¸T˜I×BÓBûðCüs�   ‚BSÂA7SÄA$SÅ(A&QÇCSÊB<SÍAQ5ÎSÎ6A	SÐ ASÑQ2ÑQ-Ñ&SÑ-Q2Ñ2SÑ5SÒ ASÓSÓSÓSc                óæ   € V P                   f?   . V n         V P                  4        F#  w  rr4V P                   P                  WW434       K%  	  \        V P                   4      V n        V P                   # )a6  
Extract and decompress source code for each VBA macro found in the file
by calling extract_macros(), store the results as a list of tuples
(filename, stream_path, vba_filename, vba_code) in self.modules.
See extract_macros for details.
:returns: list of tuples (filename, stream_path, vba_filename, vba_code)
)rÃ  rÖ  r>  r9  r÷  )ra   r…   r“   rÛ  rK  s   &    r,   Úextract_all_macrosÚVBA_Parser.extract_all_macros  s`   € ð �<‰<ÒØˆDŒLØFJ×FYÑFYÖF[ÑB�¨<Ø—‘×#Ñ# [¸|Ð$VÖWñ G\ä˜TŸ\™\Ó*ˆŒØ�|‰|Ðr.   c                ó¸   € RpV P                  4        FC  w    r#\        V\        4      '       g   \        P	                  R4       K4  WR,           ,          pKE  	  V# )a  
Extract the VBA macro source code from all modules, and return it
as a single string (str) with all modules concatenated.
If an exception is triggered when decompressing a VBA module, it
will not be included. The error is logged but the exception is not
raised further.
:return: str
r3   z7VBA code returned by extract_all_macros is not a stringrO  )rá  r<   r„   rU   r  )ra   rõ  r¹   rK  s   &   r,   Úget_vba_code_all_modulesÚ#VBA_Parser.get_vba_code_all_modules(  sS   € ð  "ÐØ#'×#:Ñ#:Ö#<ÑˆQ��1Ü˜h¬×,Ò,Ü—	‘	ÐSÖTà$°4­Õ7Ò$ñ	 $=ð
 $Ð#r.   c                ót  € V P                  4       '       Ed—   V P                  e   V P                  # V P                  fP   V P                  4       V n        V P	                  4        F&  w   r4V ;P                  VR,           ,          un        K(  	  \        V P                  4      pVP                  W4      V n        V P                  4       '       dS   \        P                  R4       RpRpVP                  P                  Wg34       VP                  P                  RWg34       V P                  '       dS   \        P                  R4       RpRpVP                  P                  Wg34       VP                  P                  RWg34       V P                  '       dS   \        P                  R	4       R
pRpVP                  P                  Wg34       VP                  P                  RWg34       VP                  4       w  r‰r«rÍpV ;P                   V,          un        V ;P"                  V	,          un        V ;P$                  V
,          un        V ;P&                  V,          un        V ;P(                  V,          un        V ;P*                  V,          un        V ;P,                  V,          un        V P                  # )a[  
runs extract_macros and analyze the source code of all VBA+XLM macros
found in the file.
All results are stored in self.analysis_results.
If called more than once, simply returns the previous results.

:return: list of tuples (type, keyword, description)
(type = 'AutoExec', 'Suspicious', 'IOC', 'Hex String', 'Base64 String' or 'Dridex String')
rO  z*adding VBA stomping to suspicious keywordszVBA StompingzwVBA Stomping was detected: the VBA source code and P-code are different, this may have been used to hide malicious coderØ  z2adding XLM macrosheet found to suspicious keywordsz	XLM macroz.XLM macro found. It may contain malicious codez0adding Template Injection to suspicious keywordszTemplate Injectionz^Template injection found. A malicious template could have been uploaded from a remote location)r–  rö  rõ  rä  Úextract_form_stringsrÁ  rÞ  rÙ  rU   r  rË  r>  r`  rô  r  râ  rø  rù  rú  rû  rü  rý  rþ  )ra   Úshow_decoded_stringsrÜ  r¹   Úform_stringÚscannerrd  rb  ÚautoexecÚ
suspiciousrÌ  Ú
hexstringsÚbase64stringsÚdridexÚ
vbastringss   &&&            r,   Úanalyze_macrosÚVBA_Parser.analyze_macros:  s-  € ð ×Ñ×Óà×$Ñ$Ò0Ø×,Ñ,Ð,à×(Ñ(Ò0Ø,0×,IÑ,IÓ,K�Ô)Ø+/×+DÑ+DÖ+FÑ'�Q˜Ø×-Ò-°¸tÕ1CÕC×-ñ ,Gô " $×";Ñ";Ó<ˆGØ$+§L¡LÐ1EÓ$SˆDÔ!Ø×'Ñ'×)Ò)Ü—	‘	ÐFÔGØ(�ðE�à×+Ñ+×2Ñ2°GÐ3IÔJØ—‘×&Ñ&¨°gÐ'KÔLØ×'×'Ð'Ü—	‘	ÐNÔOØ%�ØN�Ø×+Ñ+×2Ñ2°GÐ3IÔJØ—‘×&Ñ&¨°gÐ'KÔLà×,×,Ð,Ü—	‘	ÐLÔMØ.�ð-�à×+Ñ+×2Ñ2°GÐ3IÔJØ—‘×&Ñ&¨°gÐ'KÔLØX_×XlÑXlÓXnÑUˆH $°MÈ:Ø×Ò Õ(ÕØ×Ò *Õ,ÕØ�LŠL˜DÕ �LØ×Ò *Õ,ÕØ×!Ò! ]Õ2Õ!Ø×!Ò! VÕ+Õ!Ø×Ò *Õ,Õà×$Ñ$Ð$r.   c                óx  € V P                  R R7      p\        VR RR7      p\        V P                  4      p\	        V4      pV Fr  w  r4pVR8X  g   K  VP                  RR4      pRV,          pVP                  R	4      '       d!   VP                  R
4      '       d
   RV,          pVP                  WT4      pKt  	  V# )F)rè  c                 ó&   € \        V ^,          4      # )rï   )r9  )Útype_decoded_encodeds   &r,   rÄ   Ú#VBA_Parser.reveal.<locals>.<lambda>w  s   € ÄSÐI]Ð^_ÕI`ÔEar.   T)r¯  ÚreverserÚ  r¸   rË   z"%s"rÒ   rµ   z(%s))rñ  ÚsortedrL  rõ  rR  rG   r  Úendswith)ra   ÚanalysisÚ
deobf_codeÚkw_typery  r¢  s   &     r,   ÚrevealÚVBA_Parser.revealr  s»   € à×&Ñ&¸EÐ&ÓBˆô ˜(Ñ(aÐkoÔpˆô -¨T×-FÑ-FÓGˆ
Ü 
Ó+ˆ
Û)1Ñ%ˆG˜gØ˜,Ö&ð "Ÿ/™/¨#¨tÓ4�Ø  7Õ*�ð ×%Ñ% c×*Ò*¨w×/?Ñ/?À×/DÒ/DØ$ wÕ.�GØ'×/Ñ/°ÓA’
ñ *2ð Ðr.   c           	     óš  € \         P                  R4       V P                  f   V P                  \        8w  d   R# V P                  \        8X  d#   V P
                  p\         P                  R4       MV P                  .p. V n        V EF4  pVP                  RRR7       EF  p\         P                  RV,          4       VR.,           pVR	.,           p\         P                  R
V: RV: R24       VP                  V4      '       g   Kk  VP                  V4      \        P                  8X  g   K‘  VP                  V4      '       g   Kª  VP                  V4      \        P                  8X  g   KÐ  RP                  V4      p\         P                  RV,          4       V P                  P                  V4       EK  	  EK7  	  V P                  # )aë  
Finds all the VBA forms stored in an OLE file.

Return None if the file is not OLE but OpenXML.
Return a list of tuples (vba_root, project_path, dir_path) for each VBA project.
vba_root is the path of the root OLE storage containing the VBA project,
including a trailing slash unless it is the root of the OLE file.
project_path is the path of the OLE stream named "PROJECT" within the VBA project.
dir_path is the path of the OLE stream named "VBA/dir" within the VBA project.

If this function returns an empty list for one of the supported formats
(i.e. Word, Excel, Powerpoint), then the file does not contain VBA forms.

:return: None if OpenXML file, list of tuples (vba_root, project_path, dir_path)
for each VBA project found if OLE file
zVBA_Parser.find_vba_formsNr~  FTr†  r‰  rÆ   ÚfzChecking if streams z and z existrƒ   zFound VBA Form: %r)rU   r  rî  r’   rj  rï  r;  rò  r�  r€  r�  r
  r‚  r>   r>  )ra   Ú	ole_filesrz  r�  Úo_streamÚf_streamÚ	form_paths   &      r,   Úfind_vba_formsÚVBA_Parser.find_vba_formsŽ  sM  € ô" 	�	‰	Ð-Ô.ð �=‰=Ò  T§Y¡Y´(Ô%:Ùð$ �9‰9œÔ ð ×)Ñ)ˆIÜ�K‰KÐFÕGàŸ™Ð)ˆIð ˆŒô ˆCàŸ;™;¨u¸t˜;×D�Ü—	‘	Ð/°'Õ9Ô:à" c U�?�Ø" c U�?�Ü—	’	Ã8ËXÐVÔWØ—:‘:˜h×'Ô'¨C¯L©L¸Ó,BÄg×FZÑFZÖ,ZØ—J‘J˜x×(Ô(¨S¯\©\¸(Ó-CÄw×G[ÑG[Ö-[Ø #§¡¨Ó 1�IÜ—I‘IÐ2°YÕ>Ô?Ø—N‘N×)Ñ)¨'×2ô Eñ ð �~‰~Ðr.   c              #  ó  "  € V P                   fH   V P                  \        8X  d   R# V P                   F  pVP	                  4        F  pVx € K	  	  K   	  R# V P                  4        V P                   pV P                   EF  pVR.,           p\        P                  RRP                  V4      ,          4       VP                  V4      P                  4       p\        P                  V4       F”  p\        P                  RVP                  4       ,          4       \        '       d   VP                  4       pM!VP                  4       P!                  RRR7      pVR	8w  g   Kt  V P"                  RP                  V4      V3x € K–  	  EK  	  R# 5i)
aò  
Extract printable strings from each VBA Form found in the file

Iterator: yields (filename, stream_path, form_string) for each printable string found in forms
If the file is OLE, filename is the path of the file.
If the file is OpenXML, filename is the path of the OLE subfile containing VBA macros
within the zip archive, e.g. word/vbaProject.bin.
If the file is PPT, result is as for OpenXML but filename is useless
Note: form_string is a raw bytes string on Python 2, a unicode str on Python 3
NrÆ   zOpening form object stream %rrƒ   z"Printable string found in form: %rr'   rG   rH   ÚTahoma)rî  r’   ry  rï  rç  r  rò  rU   r  r>   r{  rv  Úre_printable_stringr   r\  rJ   rO   r_   )	ra   r£  r`  rz  Úform_storager  Ú	form_dataÚmÚ	found_strs	   &        r,   rç  ÚVBA_Parser.extract_form_stringsÑ  s)  é € ð �=‰=Ò à�y‰yœIÔ%áð $(×#4Ô#4�KØ#.×#CÑ#CÖ#E˜Ø%œó $Fó $5ð
 ×ÑÔ!Ø—-‘-ˆCØ $§¥�Ø'¨3¨%Õ/�Ü—	‘	Ð9¸C¿H¹HÀXÓ<NÕNÔOØŸN™N¨8Ó4×9Ñ9Ó;�	ä,×5Ñ5°iÖ@�AÜ—I‘IÐBÀQÇWÁWÃYÕNÔOç“wØ$%§G¡G£I™	à$%§G¡G£I×$4Ñ$4°VÀIÐ$4Ó$N˜	Ø  HÖ,Ø#Ÿ}™}¨c¯h©h°xÓ.@À)ÐLÔLô Aó !/ùs   ‚EFÅ!+Fc              #  ó�  "  € V P                   fH   V P                  \        8X  d   R # V P                   F  pVP	                  4        F  pVx € K	  	  K   	  R # V P                  4        V P                   pV P                   F@  p\        P                  ! W44       F#  pV P                  RP                  V4      V3x € K%  	  KB  	  R # 5i)Nrƒ   )rî  r’   ry  rï  Úextract_form_strings_extendedr  rò  r    Úextract_OleFormVariablesr_   r>   )ra   r£  r`  rz  r
  r”   s   &     r,   r  Ú(VBA_Parser.extract_form_strings_extendedù  sž   é € Ø�=‰=Ò à�y‰yœIÔ%áð $(×#4Ô#4�KØ#.×#LÑ#LÖ#N˜Ø%œó $Oó $5ð
 ×ÑÔ!Ø—-‘-ˆCØ $§¤�Ü '× @Ò @ÀÖ S�HØŸ=™=¨#¯(©(°<Ó*@À(ÐKÔKó !Tó !/ùs   ‚CCc                ó>  € V P                   \        \        39   d
   RV n        R# V P                  '       d
   RV n        R# V P                  fÕ   \
        P                  R4        ^ RIHp \        4        \        '       d   \        4       pM
\        4       p ! R R4      p \
        P                  R4       \        P                   pT\        n        TP#                  T P$                  YCR	7       T\        n        \
        P                  R
4       TP)                  4       T n        V P                  #   \         d7   p\
        P                  RP                  T4      4       RT n         Rp?R# Rp?ii ; i  \         d    p\
        P'                  R4        Rp?LŠRp?ii ; i)ze
Extract and disassemble the VBA P-code, using pcodedmp

:return: VBA P-code disassembly
:rtype: str
r3   Nz:Calling pcodedmp to extract and disassemble the VBA P-code)Úpcodedmpz%Exception when importing pcodedmp: {}c                   ó   € ] tR tRtRtRtRtR# )Ú&VBA_Parser.extract_pcode.<locals>.argsi7  TFr*   N)rf   rg   rh   ri   Ú
disasmOnlyÚverboserk   r*   r.   r,   Úargsr  7  s   † Ø!�
Ø”r.   r  zbefore pcodedmp)Úoutput_filezafter pcodedmpzError while running pcodedmp)r’   ru  ry  r  r  rU   r  r  r‚  r  r6   rX   rJ   r   r   ÚsysÚstderrÚprocessFiler_   rÖ   Úgetvalue)ra   r  r�   Úoutputr  r  s   &     r,   Úextract_pcodeÚVBA_Parser.extract_pcode  sI  € ð �9‰9œ¤9Ð-Ô-Ø#%ˆDÔ Ùà××ÐØ#%ˆDÔ ÙØ×ÑÒ'Ü�I‰IÐRÔSðÝ-ô Ô÷
 ‹wä ›‘ô "›�÷ ñ  ð>ä—	‘	Ð+Ô,äŸ™�Ø#””
Ø×$Ñ$ T§]¡]°DÐ$ÔMØ#””
Ü—	‘	Ð*Ô+ð $*§?¡?Ó#4ˆDÔ ð ×#Ñ#Ð#øô] ô ô —‘Ð@×GÑGÈÓJÔKØ')�Ô$ÝûðûôF ô >ô —‘Ð<×=Ñ=ûð	>ús1   Á$D. Â A-E2 Ä.E/Ä9+E*Å*E/Å2FÅ=FÆFc                ót  € \         P                  R4       V P                  e   V P                  # V P                  \        \
        39   d
   RV n        R# V P                  '       g   \         P                  R4       RV n        R# V P                  Efœ   \         P                  R4       V P                  4        \         P                  R4       \        4       pV P                  P                  4        EF{  pVP                  R4      '       g   K  \         P                  RVP                  4       ,           4       VP                  R^4      pV^ ,          pR	p\        V4      ^8X  d   V^,          P                  4       pVR9   db   VP                  R
4      '       d
   VR,          pVP                  R^4      ^ ,          pVP                  R4      '       g   VP!                  V4       VR8X  g   Kü  VP                  R^4      ^,          p\        V4      ^8¼  dF   V^ ,          R8X  d   VR,          R8X  g   Q hV^R pVP#                  RR4      pRV,           R,           pVP!                  V4       EK~  	  \         P                  R\%        \'        V4      4      ,           4       RV n        V P)                  4       pV FK  p	W˜9  g   K  \         P                  RP+                  V	4      4       \         P                  R4       RV n         M	  V P                  '       g   \         P                  R4       V P                  # )z¨
Detect VBA stomping, by comparing the keywords present in the P-code and
in the VBA source code.

:return: True if VBA stomping detected, False otherwise
:rtype: bool
rÙ  NFz<For now, VBA stomping cannot be detected for files in memoryz+Analysing the P-code to detect VBA stompingzpcodedmp OKÚ	zP-code: r3   z(Call) :é   NNÚid_ÚLitStrr¸   rË   z Keywords extracted from P-code: z"Keyword {!r} not found in VBA codezVBA STOMPING DETECTED!TzNo VBA stomping detected.)ÚArgsCallÚArgsLdÚStÚLdÚMemStÚLabelrà   )rU   r  r  r’   ru  ry  rí  r;  r   r&  r  rP  r  rÞ   r2  r9  ro  rG   r¢  rø  rä  r6   )
ra   rc  r7  rð   Úmnemonicr  r¬   r)  rõ  rd  s
   &         r,   rÙ  ÚVBA_Parser.detect_vba_stompingP  s‡  € ô 	�	‰	Ð'Ô(à×%Ñ%Ò1Ø×-Ñ-Ð-à�9‰9œ¤9Ð-Ô-Ø).ˆDÔ&Ùà× × Ð Ü�K‰KÐVÔWØ).ˆDÔ&Ùà×%Ñ%Ó-Ü�I‰IÐCÔDØ×ÑÔ ä�I‰I�mÔ$ä“uˆHØ×,Ñ,×7Ñ7×9�Ø—?‘? 4×(Ô(Ü—I‘I˜j¨4¯:©:«<Õ7Ô8Ø!ŸZ™Z¨¨aÓ0�FØ% a�y�HØ�DÜ˜6“{ aÔ'Ø% a�yŸ™Ó0˜ð  Ð#WÔWàŸ?™?¨9×5Ò5Ø#'¨¥8˜Dà#Ÿz™z¨$°Ó2°1Õ5˜ð  $Ÿ™¨u×5Ò5Ø$ŸL™L¨Ô.Ø 8Ö+ð
 !ŸJ™J t¨QÓ/°Õ2˜ô ˜q›6 1œ9Ø#$ Q¥4¨¤9°°2µ¸´Ð<Ð#;Ø ! ! B ˜AØ !§	¡	¨#¨tÓ 4˜AØ # a¥¨#¥˜AØ Ÿ™ QŸñW :ôX �I‰IÐ8¼4ÄÀxÓ@PÓ;QÕQÔRØ).ˆDÔ&à#'×#@Ñ#@Ó#BÐ Û#�ØÖ6Ü—I‘IÐB×IÑIÈ'ÓRÔSÜ—I‘IÐ6Ô7Ø15�DÔ.Ùñ $ð ×-×-Ð-Ü—	‘	Ð5Ô6Ø×)Ñ)Ð)r.   c                óÀ   € V P                   f6   V P                  e&   V P                   F  pVP                  4        K  	  R# R# V P                   P                  4        R# )zm
Close all the open files. This method must be called after usage, if
the application is opening many files.
N)rî  rï  r(  )ra   r£  s   & r,   r(  ÚVBA_Parser.close§  sM   € ð
 �=‰=Ò Ø× Ñ Ò,Ø#'×#4Ô#4�KØ×%Ñ%Ö'ó $5ñ -ð �M‰M×ÑÖ!r.   ) rö  rð  ró  rô  r  rQ   rí  r_   r  r  rÃ  rø  rü  rý  rû  rú  r÷  rù  rþ  r   rî  rï  r  r~  r  r’   rõ  rò  rñ  r  rÿ  r  r)   rä  )&rf   rg   rh   ri   rj   ÚDEFAULT_API_ENCODINGr]   r  r  r  r  r  r  r  r  r'  rŒ  r–  r“  r”  rª  r«  rÃ  rË  rÏ  rÖ  rá  rä  rñ  rý  r  rç  r  r   rÙ  r(  rk   rl   r~   s   @r,   rè  rè  u
  sÔ   ø‡ € ñð
 '+°dÀDÐSgØ$ôM%ò^/ò"P/òd//òb)/òVN/ò`Jò8òDôOò\!ò|òD(òL&/òP$òN!òF!ô
òGòfOòRò $ô$5%òpò8AòF&MòPLò&B$òHU*÷n
"ð 
"r.   rè  c                   óx   a a€ ] tR tRt oRtV 3R ltRR ltRR ltRR ltR t	RR lt
RR	 ltRR
 ltRtVtV ;t# )ÚVBA_Parser_CLIiµ  zd
VBA parser and analyzer, adding methods for the command line interface
of olevba. (see VBA_Parser)
c                ó0   <€ \         \        V `
  ! V/ VB  R# )ze
Constructor for VBA_Parser_CLI.
Calls __init__ from VBA_Parser with all arguments --> see doc there
N)r\   r3  r]   )ra   r  rb   rc   s   &*,€r,   r]   ÚVBA_Parser_CLI.__init__»  s   ø€ ô
 	Œn˜dÒ,¨dÐ=°fÔ=r.   c                óÆ   € \         P                  P                  4       '       d,   \        RRR7       \         P                  P	                  4        V P                  W4       R# )a@  
Analyze the provided VBA code, without printing the results (yet)
All results are stored in self.analysis_results.

:param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content.
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)
:return: None
úAnalysis...r3   ©rA   N)r  ÚstdoutÚisattyr¹  Úflushrñ  )ra   rè  rÜ  s   &&&r,   Úrun_analysisÚVBA_Parser_CLI.run_analysisÃ  s@   € ô �:‰:×Ñ×ÒÜ�/ rÕ*Ü�J‰J×ÑÔØ×ÑÐ0Ö>r.   c                óÂ  € V P                   pV'       dÀ   \        P                  ! RRR7      pRRRRRR/pV Fh  w  rgp\        V4      '       g   \	        V4      p\        V4      '       g   \	        V4      pVP                  VR4      p	VP                  WgV3V	RR3R	7       Kj  	  VP                  4        V P                  '       d   \        R
4       R# R# \        R4       R# )zó
print the analysis results in a table

:param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content.
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)
:return: None
)Úcolumn_widthÚ
header_rowr×  ÚyellowrØ  ÚredrÙ  ÚcyanN)Úcolorsz�VBA Stomping detection is experimental: please report any false positive/negative at https://github.com/decalage2/oletools/issuesz#No suspicious keyword or IOC found.)é
   rN  é-   )ÚTypeÚKeywordÚDescription)
rö  r   ÚTableStreamr*  r¢  r€  Ú	write_rowr(  r  r¹  )
ra   rè  rÜ  r`  rÃ   Ú
COLOR_TYPErü  rd  rb  Ú
color_types
   &&&       r,   Úprint_analysisÚVBA_Parser_CLI.print_analysisÓ  sÞ   € ð ×'Ñ'ˆßÜ×'Ò'°\Ø3UôWˆAð ˜HØ˜eØ�vðˆJó
 29Ñ-� +ä# G×,Ò,Ü" 7›m�GÜ# K×0Ò0Ü"& {Ó"3�KØ'Ÿ^™^¨G°TÓ:�
Ø—‘˜W¨{Ð;ÀZÐQUÐW[ÐD\�Ö]ñ 29ð �G‰GŒIØ×)×)Ð)Üð  Zö  [ñ *ô Ð7Ö8r.   c                ó  € \         P                  P                  4       '       d,   \        RRR7       \         P                  P	                  4        V P                  W4       UUUu. uF  w  r4p\        W4VR7      NK  	  uppp# u upppi )aH  
Analyze the provided VBA code, and return the results in json format

:param vba_code: str, VBA source code to be analyzed
:param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content.
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)

:return: dict
r7  r3   r8  )r’   rd  rb  )r  r9  r:  r¹  r;  rñ  r¨  )ra   rè  rÜ  rü  rd  rb  s   &&&   r,   Úprint_analysis_jsonÚ"VBA_Parser_CLI.print_analysis_jsonò  sr   € ô �:‰:×Ñ×ÒÜ�/ rÕ*Ü�J‰J×ÑÔà59×5HÑ5HÐI]Ô5kõmÙ5kÑ1�G kô ˜'À×LÙ5kómð 	mùô ms   Á%Bc                óÌ   € V P                   pV'       dP   RRRRRR/pV FA  w  rEpVP                  VR4      pV'       g   K"  VP                  VRV: R	V: R
V: R	24      pKC  	  V# )z 
Colorize keywords found during the VBA code analysis
:param vba_code: str, VBA code to be colorized
:return: str, VBA code including color tags for Colorclass
r×  rA  rØ  rB  rÙ  rC  Nz{autoÚ}z{/)rö  r€  rG   )ra   rK  r`  rL  rü  rd  rb  rM  s   &&      r,   Úcolorize_keywordsÚ VBA_Parser_CLI.colorize_keywords  sp   € ð ×'Ñ'ˆßà˜HØ˜eØ�vðˆJó
 29Ñ-� +Ø'Ÿ^™^¨G°TÓ:�
ß‘:Ø'×/Ñ/±ËjÓZaÓcmÐ9nÓo’Hñ 29ð ˆr.   c	           	     óâ  € W€n         V'       d   V'       g   RpV P                  '       d   V P                  : RV P                  : 2p	MV P                  p	\        R4       \        RV	,          4        \        RV P                  ,          4       V P                  4       '       Ed¸   V P                  WR7       V P                  4        EFM  w  r«rÍV'       d   \        V4      pMTp\        R 4       \        RV,          4       \        RV
: R\        V4      : 24       V'       g   K`  \        R!4       VP                  4       R	8X  d   \        R
4       K�  RV9   de   \        P                  R4       \        P                  P                  4       '       d   \         P"                  ! R4      pMRpVP%                  RV4      p \        P                  P                  4       '       d&   \         P"                  ! V P'                  V4      4      p\        T4       EKP  	  V P-                  4        F@  w  r«pVf   K  \        R 4       \        RV
: RV: 24       \        R!4       \        V4       KB  	   V P/                  4        F[  w  r«pVf   K  \        R 4       \        RVR,          : RV
: RV: 24       \        R!4       \        \1        VR,          4      4       K]  	  V'       d2   \        R 4       \        R4       V P9                  4       p\        V4       V'       g   V P;                  W4       V'       d%   \        R4       \        V P=                  4       4       M\        R4        \        R	4       R#   \(         d    \        P+                  R4        EL�i ; i  \2         d?   p\        P5                  RT,          4       \        P7                  RRR7        Rp?ELRp?ii ; i  \>         d    h \2         dp   p\        P5                  RT P                  : RT: R24       \@        PB                  ! 4        \        P7                  RRR7       \E        T P                  T4      hRp?ii ; i)"a   
Process a single file

:param filename: str, path and filename of file on disk, or within the container.
:param data: bytes, content of the file if it is in a container, None if it is a file on disk.
:param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content.
:param display_code: bool, if False VBA source code is not displayed (default True)
:param global_analysis: bool, if True all modules are merged for a single analysis (default),
                        otherwise each module is analyzed separately (old behaviour)
:param hide_attributes: bool, if True the first lines starting with "Attribute VB" are hidden (default)
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)
:param show_pcode bool: if True, call pcodedmp to disassemble P-code and display it
:param no_xlm bool: if True, don't use the BIFF plugin to extract old style XLM macros
Tz in zFILE: %szType: %s©rè  rÜ  zVBA MACRO %s z	in file: z - OLE stream: r3   z(empty macro)r´   z]The VBA code contains special characters such as backspace, that may be used for obfuscation.s   {autored}\x08{/red}z\x08z;Unicode conversion to be fixed before colorizing the outputNzVBA FORM STRING IN zVBA FORM Variable "r¬   z" IN r–   zError parsing form: %srÕ  r  zP-CODE disassembly:zAMACRO SOURCE CODE WITH DEOBFUSCATED VBA STRINGS (EXPERIMENTAL):

zNo VBA or XLM macros found.úError processing file r  rµ   zO===============================================================================zO-------------------------------------------------------------------------------zN- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - )#r   rð  r_   r¹  r’   r–  r<  rá  rR  r¢  rÞ   rU   r;  r  r9  r:  Ú
colorclassÚColorrG   rU  ÚUnicodeErrorr  rç  r  r„   r‚  r  r  r   rN  rý  rZ   Ú	tracebackÚ	print_excrv   )ra   rè  Údisplay_codeÚhide_attributesÚvba_code_onlyÚshow_deobfuscated_coderÜ  Ú
show_pcoder   Údisplay_filenamer…   r“   rÛ  rK  Úvba_code_filteredÚ	backspaceré  Úform_variablesrC   Úpcodes   &&&&&&&&&           r,   r¶  ÚVBA_Parser_CLI.process_file  st  € ð( Œß§ØˆLØ�>�>ˆ>Ø-1¯]¬]¸D¿N»NÐKÑà#Ÿ}™}ÐÜˆhŒÜˆjÐ+Õ+Ô,ð[	6ä�*˜dŸi™iÕ'Ô(Ø×!Ñ!×#Ó#à×!Ñ!Ð7KÐ!ÔeàJN×JaÑJa×JcÑF�[¨|ß&ä,6°xÓ,@Ñ)à,4Ð)Ü˜(”OÜ˜/¨LÕ8Ô9Ý»KÌÈkÕIZÐ[Ô\ß#‘|Ü˜iÔ(à,×2Ñ2Ó4¸Ô:Ü! /Ö2ð  &Ð):Ô:Ü #§¡ð  -Lô  !MÜ#&§:¡:×#4Ñ#4×#6Ò#6ä0:×0@Ò0@ÐAXÓ0Y¡Ià07 Ià4E×4MÑ4MÈfÐV_Ó4`Ð 1ðiô $'§:¡:×#4Ñ#4×#6Ò#6Ü8B×8HÒ8HÈ×I_ÑI_Ð`qÓIrÓ8sÐ$5ô "Ð"3×4ñC KdðD @D×?XÑ?XÖ?ZÑ;�[¨{Ø"Ô.Ü˜hœÝË+ÒWbÐcÔdÜ˜iÔ(Ü˜kÖ*ñ @[ð
;ØFJ×FhÑFhÖFjÑB˜°>Ø)Ô5Ü! (œOÝ!ÐUcÐdj×UkÐUkÓmxò  {Fð  #Gô  HÜ! )Ô,Ü!¤# n°WÕ&=Ó">Ö?ñ Gk÷ Ü˜(”OÜÐ/Ô0Ø ×.Ñ.Ó0�EÜ˜%”L÷ %à×'Ñ'Ð(<ÔJß)ÜÐ_Ô`Ü˜$Ÿ+™+›-Ô(øäÐ3Õ4ô 	ˆbŽ	øôo $0ô iä #§	¡	Ð*g× hðiûô" !ô ;ä—H‘HÐ5¸Õ;Ô<Ü—I‘I˜l°T�I×:Ò:ûð;ûô< #ô 	ØÜô 	6ä�HŠH¸¿¼ÃsÐKÔLÜ×ÒÔ!Ü�I‰I�l¨TˆIÔ2Ü! $§-¡-°Ó5Ð5ûð	6ús¦   Á3B0O) Ä(A,O) Æ+O) Ç#M6Ç%%M6È
'O) È68O) É/N ÊAN ËO) Ë&8O) ÌO) Ì8$O) ÍO) Í6 NÎO) ÎNÎO) ÎO&Î(3O!ÏO) Ï!O&Ï&O) Ï)Q.Ï>Q.Ï?A*Q)Ñ)Q.c	                óŒ  € W€n         V'       d   V'       g   Rp/ p	V P                  '       d   V P                  V	R&   MRV	R&   V P                  V	R&   RV	R&   RV	R&   RV	R&   WiR	&   WyR
&    V P                  V	R&   . p
V P	                  4       '       dÄ   V P                  4        F\  w  r¼rÞ/ pV'       d   \        V4      pMTpWßR&   W¿R&   WÏR&   V'       d   VP                  4       VR&   MRVR&   V
P                  V4       K^  	  V'       g   V P                  VV4      V	R&   V'       d   V P                  4       V	R&   V'       d   V P                  4       V	R&   W©R&   RV	R&   V	#   \         d[   p\        P                  RT P                  : RT: R24       \        P                  RRR7       \!        T P                  T4      hRp?ii ; i)aÄ  
Process a single file

every "show" or "print" here is to be translated as "add to json"

:param filename: str, path and filename of file on disk, or within the container.
:param data: bytes, content of the file if it is in a container, None if it is a file on disk.
:param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content.
:param display_code: bool, if False VBA source code is not displayed (default True)
:param global_analysis: bool, if True all modules are merged for a single analysis (default),
                        otherwise each module is analyzed separately (old behaviour)
:param hide_attributes: bool, if True the first lines starting with "Attribute VB" are hidden (default)
:param show_deobfuscated_code: bool, if True add deobfuscated code to result
:param deobfuscate: bool, if True attempt to deobfuscate VBA expressions (slow)
:param show_pcode: bool, if True add extracted pcode to result
Trð  Nr®  FÚjson_conversion_successfulrú  Úcode_deobfuscatedÚdo_deobfuscaterc  r’   rÛ  r…   Ú
ole_streamrr  rh  ÚmacrosrY  r  rµ   rÕ  r  )r   rð  r_   r’   r–  rá  rR  rÞ   r>  rQ  rý  r   r‚  rU   r  r  rv   )ra   rè  r_  r`  ra  rb  rÜ  rc  r   r‰  ro  r…   r“   rÛ  rK  Ú
curr_macrore  rC   s   &&&&&&&&&         r,   Úprocess_file_jsonÚ VBA_Parser_CLI.process_file_json’  sÀ  € ð, Œß§ØˆLàˆà�>�>ˆ>Ø"&§.¡.ˆF�;Òà"&ˆF�;ÑØŸ™ˆˆv‰Ø/4ˆÐ+Ñ,Ø!ˆˆzÑØ&*ˆÐ"Ñ#Ø#.ÐÑ Ø)ˆ|Ñð#	6à!ŸY™YˆF�6‰NØˆFØ×!Ñ!×#Ò#ØJN×JaÑJaÖJcÑF�[¨|Ø!#�Jß&ä,6°xÓ,@Ñ)à,4Ð)à1=˜~Ñ.Ø0;˜}Ñ-Ø/:˜|Ñ,ß#Ø->×-DÑ-DÓ-F˜
 6Ò*à-1˜
 6Ñ*Ø—M‘M *Ö-ñ Kd÷  %à)-×)AÑ)AÐBVØBMó*O�F˜:Ñ&ç)Ø26·+±+³-�FÐ.Ñ/ßØ&*×&8Ñ&8Ó&:�F˜7‘OØ%�8ÑØ37ˆFÐ/Ñ0ð ˆøô ô 	6ä�HŠH¸¿¼ÃsÐKÔLÜ�I‰I�l¨TˆIÔ2Ü! $§-¡-°Ó5Ð5ûð		6ús,   Á)BE ÄE Ä%E Å E ÅGÅ)AF>Æ>Gc           	     ó¨  €  V P                  4       '       dc   \        P                  P                  4       '       d,   \	        RRR7       \        P                  P                  4        V P                  VVR7       \        V P                  ,          pR;p;p;p;p;p	;p
;r¼V P                  '       d   RpV P                  '       d   RpV P                  '       d   RpV P                  '       d   R	pV P                  '       d   R
p	V P                  '       d   Rp
V P                  '       d   RpV P                   '       d   RpWE: V: V: V: V	: V
: V: V: 2,          pV:R RV P"                  : 2p\	        V4       R#   \$         dF   p\&        P)                  RT P"                  : RT: R2RR7       \+        T P"                  T4      hRp?ii ; i)zJ
Process a file in triage mode, showing only summary results on one line.
r7  r3   r8  rX  r¼   ÚMÚAÚSÚIÚHrÏ   ÚDÚVÚ12rJ  rY  r  rµ   Tr  N)r–  r  r9  r:  r¹  r;  rñ  ÚTYPE2TAGr’   ró  rø  rù  rú  rû  rü  rý  rþ  r_   r‚  rU   r  rv   )ra   rè  rÜ  r   rÓ  ro  rë  rì  rÌ  rí  Ú	base64obfrï  Úvba_obfr7  rC   s   &&&&           r,   Úprocess_file_triageÚ"VBA_Parser_CLI.process_file_triageá  s†  € ð
	6à×!Ñ!×#Ò#ä—:‘:×$Ñ$×&Ò&Ü˜/¨rÕ2Ü—J‘J×$Ñ$Ô&Ø×#Ñ#Ð9MØ0;ð $ô =ä˜TŸY™YÕ'ˆEØ`cÐcˆFÐc�XÐc 
Ðc¨TÐc°JÐcÀÐcÈVØ×'×'Ð'°#¨Ø××Ð¨C Ø×!×!Ð!° :Ø�|�|ˆ| C˜TØ×!×!Ð!° :Ø×$×$Ð$°# iØ×$×$Ð$¨s fØ×!×!Ð!¨S 7Ø©6²8ºZÊÊzÚ)2²FºGðEõ EˆEô "'¨¯«Ð6ˆDÜ�$ŽKøÜô 	6ä�IŠI¸¿¼ËÐLØ#ð ô %ä! $§-¡-°Ó5Ð5ûð		6úsN   ‚F ˜#F ¼B	F ÃF ÃF Ã.F ÄF ÄF Ä*F Ä>AF ÆGÆA GÇG)r   rä  )FTTFFFFF)FFF)rf   rg   rh   ri   rj   r]   r<  rN  rQ  rU  r¶  rq  r  rk   rl   rm   rn   s   @@r,   r3  r3  µ  s<   ù‡ € ñõ
>ô?ô 9ô>mò"ô&yôxL÷^!6ô !6r.   r3  c           
     ód  € RpRp\         P                  ! VR7      pVP                  RRRR7       VP                  RR	R
RR7       VP                  RRR\        RRR7       VP                  RR\        R. RR7       VP                  RRR\        RRR7       VP	                  RR7      pVP                  RRR R!R"R#R$R%7       VP                  R&R'R R!R(R#R)R%7       VP                  R*R+R R!R,R#R-R%7       VP                  R.R/R0R1R2R3R47       VP                  R5R6R	R7R8R9R47       VP                  R:R	R;R<R7       VP                  R=R0R>R2R?R47       VP                  R@R	RARBR7       VP                  RCRDRERFVRGRH7       VP                  RIRJR	R8RKRH7       VP                  RLRMR	R2RNRH7       VP                  RORPR	R8RQRH7       VP                  RRR	RSRT7       VP                  RURVR	R8RWRH7       VP                  V 4      p\        VP                  4      ^ 8X  dp   RX\        P                  RY,          ,          p\        RZ\        : R[V: R\24       \        \        4       VP                  4        \        P                  ! \        4       VP                   '       d$   VP"                  '       d   VP%                  R]4       V# )^zBparse command line arguments (given ones or per default sys.argv) r;  z2usage: olevba [options] <filename> [filename2 ...])ÚusageÚ	filenamesr	  zFiles to analyze)ÚnargsÚhelpz-rÚ
store_trueÚ	recursivez)find files recursively in subdirectories.)ÚactionÚdestr…  z-zz--zipÚzip_passwordNzRif the file is a zip archive, open all files from it, using the provided password.)r‰  r’   Údefaultr…  z-pz
--passwordr>  z^if encrypted office files are encountered, try decryption with this password. May be repeated.)r’   rˆ  r‹  r…  z-fz
--zipfnameÚ	zip_fnamezzif the file is a zip archive, file(s) to be opened within the zip. Wildcards * and ? are supported. (default: %(default)s)z Output mode (mutually exclusive))Útitlez-tz--triageÚstore_constÚoutput_modeÚtriageÚunspecifiedzLtriage mode, display results as a summary table (default for multiple files))rˆ  r‰  Úconstr‹  r…  z-dz
--detailedÚdetailedz=detailed mode, display full results (default for single file)z-jz--jsonr·  z2json mode, detailed in json format (never default)z-az
--analysisÚstore_falser_  Tz8display only analysis results, not the macro source code)rˆ  r‰  r‹  r…  z-cz--codera  Fz/display only VBA source code, do not analyze itz--decoderè  zedisplay all the obfuscated strings with their decoded content (Hex, Base64, StrReverse, Dridex, VBA).z--attrr`  z?display the attribute lines at the beginning of VBA source codez--revealrb  zbdisplay the macro source code after replacing all the obfuscated strings by their decoded content.z-lz
--loglevelÚloglevelÚstorezElogging level debug/info/warning/error/critical (default=%(default)s))r‰  rˆ  r‹  r…  z--deobfrÜ  z-Attempt to deobfuscate VBA expressions (slow)z	--relaxedr~  zeDo not raise errors if opening of substream fails (this option is now deprecated, enabled by default)z--show-pcoderc  z)Show disassembled P-code (using pcodedmp)z
--no-pcodez(Disable extraction and analysis of pcode)rˆ  r…  z--no-xlmr   zKDo not extract XLM Excel macros. This may speed up analysis of large files.ú%d.%d.%dºrÀ   é   Núolevba ú on Python ú' - http://decalage.info/python/oletoolsz6You cannot combine options --no-pcode and --show-pcode)ÚargparseÚArgumentParserÚadd_argumentr„   Úadd_argument_groupÚ
parse_argsr9  rƒ  r  Úversion_infor¹  Ú__version__rj   Ú
print_helpÚexitÚRETURN_WRONG_ARGSrc  Úno_pcoder  )Úcmd_line_argsÚDEFAULT_LOG_LEVELr‚  ÚparserÚmodesrº  Úpython_versions   &      r,   r¡  r¡    sc  € ð "Ðà@€EÜ×$Ò$¨5Ô1€FØ
×Ñ˜¨3Ð5GÐÔHð
 ×Ñ˜ \¸ØHð ô Jà
×Ñ˜˜g¨NÄØ $ðEð ô Fð ×Ñ˜˜l´¸XØ "ðOð ô Pð ×Ñ˜˜l°Ä3Ø #ðAð ô Bð
 ×%Ñ%Ð,NÐ%ÓO€EØ	×Ñ�t˜Z°Ø)°Ø,ð;ð ô <ð
 
×Ñ�t˜\°-Ø)°Ø,ð+ð ô ,ð
 
×Ñ�t˜X¨mØ)°Àð.ð ô /ð ×Ñ˜˜l°=Ø+°Tð+ð ô ,ð ×Ñ˜˜h¨|Ø,°eØNð ô Pð ×Ñ˜
¨<Ø3ð-ð ô .ð
 ×Ñ˜¨Ð=NØ $ð/ð ô 0ð ×Ñ˜
¨<Ø5ð(ð ô )ð
 ×Ñ˜˜l°ÀGØ 1ð5ð ô 6ð ×Ñ˜	¨¸lØ %ØLð ô Nð ×Ñ˜¨)¸LØ $ðYð ô Zð ×Ñ˜¨\À,Ø %ØHð ô Jð ×Ñ˜¨\ØGð ô Ià
×Ñ˜
¨¸,ÐPUØ!nð ô pð ×Ñ Ó.€Gô ˆ7×ÑÓ Ô"à#¤c×&6Ñ&6°sÕ&;Õ;ˆÝß›Nð,ô 	-äŒgŒØ×ÑÔÜ�ŠÔ"Ô#à××Ð˜g×.×.Ð.Ø�‰ÐMÔNà€Nr.   c                ó
  €  Rp\        WVVP                  VP                  R7      pVP                  R8X  dk   VP	                  VP
                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  R7       MìVP                  R8X  d4   VP                  VP
                  VP                  VP                  R7       M¨VP                  R8X  dt   \        VP                  VP
                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  R7      4       M$\!        RP#                  VP                  4      4      hVP%                  4        \&        P)                  R	4       \*        P,                  ! V 4      '       g   \&        P)                  R
4       \.        #  T\*        PL                  8¼  d   \*        PN                  ! Y@4      hRp \&        P)                  RP#                  TPP                  4      4       TPP                  \*        PR                  ,           p\*        PT                  ! Y4      pT'       g,   \&        PW                  R4       \*        PX                  ! T 4      h\&        P[                  R4       \	        YqT;'       g    T Y4^,           4       \&        P)                  R P#                  T4      4       \\        P^                  ! T4       #   \0         Edv   p\&        P)                  RRR7       X'       d   TP%                  4        \&        P)                  R4       \*        P,                  ! T 4      '       d    Rp?EL¦\3        T\4        \6        34      '       d‹   TP                  R!9   d   \9        R:R RT : R24       MYTP                  R8X  d-   \        T R\;        T4      P<                  \?        T4      R7       M\&        PA                  RT ,          4       \B        u Rp?# \3        T\D        4      '       d‹   TP                  R!9   d   \9        R:R RT : R24       MYTP                  R8X  d-   \        T R\;        T4      P<                  \?        T4      R7       M\&        PA                  RT ,          4       \B        u Rp?# \3        T\F        4      '       d®   TP                  R!9   d#   \9        R:R RT : RTPH                  : 24       MoTP                  R8X  d7   \        T R\;        T4      P<                  \?        TPH                  4      R7       M(\&        PA                  RT : RTPH                  : R24       \J        u Rp?# h Rp?ii ; i  \0         d     # i ; i   \&        P)                  R P#                  T4      4       \\        P^                  ! T4       i   \0         d     i i ; i; i)"zî
Part of main function that processes a single file.
This is meant to be used only for the command-line interface of olevba

This handles exceptions and encryption.

Returns a single code summarizing the status of processing of this file
N)r  rð  r~  r  r“  )rè  r_  r`  ra  rb  rÜ  rc  r   r�  )rè  rÜ  r   r·  zunexpected output mode: "{0}"!z Checking for encryption (normal)zno encryption detectedzCaught exception:Tr  z)Checking for encryption (after exception)Ú?r{  rJ  z0 - Error opening substream or uenxpected contentr  ©r®  r’   r  Úmessagez3Error opening substream or unexpected content in %sz - File format not supportedz,Failed to open %s -- probably not supported!z!ERRORr¦  rY  r  z)!z Checking encryption passwords {}z4Decrypt failed, run with debug output to get detailszWorking on decrypted filezRemoving crypt temp file {})r�  r‘  )0r3  r~  r§  r�  r¶  rè  r_  r`  ra  rb  rÜ  rc  r   r  r¿  rq  r‘   r6   r(  rU   r  r"   r  Ú	RETURN_OKr‚  r<   r€   rˆ   r¹  r’   rf   r„   rÖ   ÚRETURN_OPEN_ERRORrq   rv   r`   ÚRETURN_PARSE_ERRORÚMAX_NESTING_DEPTHÚMaxCryptoNestingReachedÚpasswordrÆ  rÇ  r  ÚWrongEncryptionPasswordr  ÚosÚunlink)	r_   r  rð  rº  Úcrypto_nestingÚ
vba_parserrC   rÉ  rÊ  s	   &&&&&    r,   r¶  r¶  l  s§  € ðNØˆ
ô $ HÀ9Ø,3¯O©OØ29×2BÑ2BôDˆ
ð ×Ñ *Ô,à×#Ñ#¸×9UÑ9UØ&-×&:Ñ&:Ø)0×)@Ñ)@ÐPW×PeÑPeØ07×0NÑ0NØ%,×%8Ñ%8ÀW×EWÑEWØ+2¯>©>ð $õ ;ð × Ñ  HÔ,à×*Ñ*À×@\Ñ@\Ø7>×7JÑ7JÐSZ×SaÑSað +õ cà× Ñ  FÔ*ÜØ×,Ñ,À'×B^ÑB^Ø&-×&:Ñ&:Ø)0×)@Ñ)@ÐPW×PeÑPeØ07×0NÑ0NØ%,×%8Ñ%8ÀW×EWÑEWØ4;·N±Nð -ó DõEô Ð=×DÑDÀW×EXÑEXÓYÓZÐZØ×ÑÔô 	�	‰	Ð4Ô5Ü×"Ò" 8×,Ò,Ü�I‰IÐ.Ô/ÜÐð -ð` œ×1Ñ1Ô1Ü×,Ò,¨^ÓFÐFà€NðÜ�	‰	Ð4×;Ñ;¸G×<LÑ<LÓMÔNØ×$Ñ$¤v×'?Ñ'?Õ?ˆ	ÜŸš¨Ó<ˆßÜ�I‰IÐLÔMÜ×0Ò0°Ó:Ð:Ü�‰Ð,Ô-Ü˜N°)×2GÐ2G¸xØ#°AÕ%5ó7ð	Ü�I‰IÐ3×:Ñ:¸>ÓJÔKÜ�IŠI�nÕ%øô} õ )Ü�	‰	Ð%°ˆ	Ô5ßØ×ÑÔä�	‰	Ð=Ô>Ü×Ò˜x×(Ò(Ýä˜#Ô 2Ô4GÐH×IÒIØ×&Ñ&Ð*CÔCÜÜ'*«Hð6õ 7à×(Ñ(¨FÔ2Ü H°7Ü%)¨#£Y×%7Ñ%7ÄÀSÃöKô —M‘Mð #2Ø4<õ#=ô >ä(Õ(Ü˜C¤×/Ò/Ø×&Ñ&Ð*CÔCÜÄCËÐRÕSØ×(Ñ(¨FÔ2Ü H°7Ü%)¨#£Y×%7Ñ%7ÄÀSÃöKô —M‘MÐ"PÐS[Õ"[Ô\Ü(Õ(Ü˜C¤×1Ò1Ø×&Ñ&Ð*CÔCÜ¬X³xÀÇÃÐNÕOØ×(Ñ(¨FÔ2Ü H°7Ü%)¨#£Y×%7Ñ%7Ü'*¨3¯<©<Ó'8ö:ô —M’MÛ%-¨s¯|¬|ð#=ô >ä)Õ)àûðS)ûô~ ô 	Ùð	ûð	Ü�I‰IÐ3×:Ñ:¸>ÓJÔKÜ�IŠI�nÕ%øÜô 	Ùð	ýs•   ‚GL ÇL ÈB;V4 ËV4 Ë$:V#ÌV Ì+AVÎB VÐ1V Ð7BVÓV ÓB=VÖV ÖVÖV Ö#V1Ö0V1Ö4XÖ6:W1×0X×1W?×<X×>W?×?Xc           
     óX
  € \        V 4      p\        P                  ! VP                  R8H  VP                  RR7       VP                  R8X  d,   \        R\        \        P                  R,          RRRR7       M6R	\        P                  R,          ,          p\        R
\        : RV: R24       VP                  '       d/   VP                  '       g   \        P                  R4       RVn        \        ;QJ dT    . R \        P                   ! VP"                  VP$                  VP&                  VP(                  R7       4       F  NK  	  5MM! R \        P                   ! VP"                  VP$                  VP&                  VP(                  R7       4       4      pVP                  R8X  d    \+        V4      ^8X  d	   RVn        MRVn        VP                  R8X  dO   VP                  '       d   \        P                  R4       VP,                  '       d   \        P                  R4       VP                  R8X  d)   \        R:R RR:R 24       \        R*:R RR+:R 24       Rp^ pR;p;rx\.        p	 V EF°  w  rgp\1        V\2        4      '       Ed+   \1        V\4        4      '       dh   VP                  R8X  d   \        R:R RV: R24       M-VP                  R8w  d   \        P7                  RV,          4       V	^ 8X  d   \8        M\:        p	MnVP                  R8X  d   \        R:R RV: RV: 24       M2VP                  R8w  d"   \        P7                  RV: R V: R!V: 24       V	^ 8X  d   \<        M\:        p	VP                  R8X  d,   \        VR"\?        V4      P@                  \C        V4      R#7       EKH  VP                  R8X  d   Wd8w  d   Ve   \        R$V,          4       Tp\E        WxWa4      p
V^,          pV
\.        8X  d   EKš  V	\.        8X  d   T
p	EKª  \:        p	EK³  	  VP                  R8X  d   \        R%4       \        P                  R)T	,          4       \        PR                  ! 4        \        PT                  ! T	4       R#   \F        PH                   dP   p\        PK                  R&PM                  T4      RR'7       T	\.        8X  d   \N        p	 Rp?LšT	\:        8H    Rp?L¨Rp?i\2         d/   p\        PK                  R(T,          RR'7       \P        p	 Rp?LßRp?ii ; i),z÷
Main function, called when olevba is run from the command line

Optional argument: command line arguments to be forwarded to ArgumentParser
in process_args. Per default (cmd_line_args=None), sys.argv is used. Option
mainly added for unit-testing
r·  T)Úother_logger_has_first_linerS   r˜  z$http://decalage.info/python/oletoolsÚMetaInformation)Úscript_nameÚversionr¬  Úurlr’   r¼  r—  rš  r›  rœ  z$set --deobf because --reveal was setc              3   ór   "  € T F-  w  rpV'       d   VP                  R 4      '       d   K'  WV3x € K/  	  R# 5ir‚   )rù  )r7   rð  r_   r  s   &   r,   r9   Úmain.<locals>.<genexpr>  s:   é € ð Jñ9<Ñ4˜9°÷ $-°×1BÑ1BÀ3×1Gô 7˜I°Õ6ó9<ùs   ‚$7«7)r‡  rŠ  rŒ  r‘  r“  r�  z.ignoring option --reveal in triage output modez2ignoring option --show-pcode in triage output modeÚFlagsr{  rJ  ÚFilenameÚ65Nr®  z - File not foundzGiven path %r does not exist!z  - Failed to read from zip file zException opening/reading z from zip file z: r  r¯  z
Files in %s:zÖ
(Flags: OpX=OpenXML, XML=Word2003XML, FlX=FlatOPC XML, MHT=MHTML, TXT=Text, M=Macros, A=Auto-executable, S=Suspicious keywords, I=IOCs, H=Hex strings, B=Base64 strings, D=Dridex strings, V=VBA strings, ?=Unknown)
z$Problems with encryption in main: {}r  zUnhandled exception in main: %szwill exit now with code %sz-----------zA-----------------------------------------------------------------)+r¡  r&   rX   r�  r•  r¿  r£  r  r¢  r¹  rb  rÜ  rU   r  r�   r   Ú
iter_filesrƒ  r‡  rŠ  rŒ  r9  rc  r±  r<   r‚  r   r  ÚRETURN_FILE_NOT_FOUNDÚRETURN_SEVERAL_ERRSÚRETURN_XGLOB_ERRr’   rf   r„   r¶  r"   ÚCryptoErrorBaserÖ   r6   ÚRETURN_ENCRYPTEDÚRETURN_UNEXPECTEDÚend_loggingr¥  )r¨  rº  r¬  Úall_input_infoÚprevious_containerÚcountrð  r_   r  Úreturn_codeÚcurr_return_coderC   s   &           r,   ÚmainrÔ  ß  s4  € ô ˜Ó'€Gô ×Ò˜g×1Ñ1°6Ñ9¸7×;KÑ;KØ:>õ@ð ×Ñ˜fÔ$ä˜x´Ü"%×"2Ñ"2°3Õ"7Ø=Ø)¸$ö	@ð $¤c×&6Ñ&6°sÕ&;Õ;ˆÝß›Nð,ô 	-ð ×%×%Ð%¨g×.A×.AÐ.AÜ�	‰	Ð8Ô9Ø"ˆÔ÷ ”Uñ JÜ8=×8HÒ8HØ&×0Ñ0¸G×<MÑ<MØ,3×,@Ñ,@Ø)0×):Ñ):õ9<óJ—U‘Uñ JÜ8=×8HÒ8HØ&×0Ñ0¸G×<MÑ<MØ,3×,@Ñ,@Ø)0×):Ñ):õ9<óJó J€Nð ×Ñ˜mÔ+Üˆ~Ó !Ô#Ø",ˆGÕà"*ˆGÔà×Ñ˜hÔ&Ø×)×)Ð)Ü�I‰IÐFÔGØ××ÐÜ�I‰IÐJÔKð ×Ñ˜hÔ&Üœw«
Ð3Ô4Üœx«Ð2Ô3àÐØ€EØ"&Ð&€IÐ&�Ü€Kð<(Ü)7Ñ%ˆI ä˜$¤	×*Ó*Ü˜dÔ$9×:Ò:Ø×*Ñ*¨hÔ6Ü¼SÃ(ÐKÕLØ ×,Ñ,°Ô6ÜŸ	™	Ð"AÀHÕ"LÔMØ;FÈ!Ô;KÕ"7Ü9Lñ  ð ×*Ñ*¨hÔ6ÜÌcÓS[Ò]fÐgÕhØ ×,Ñ,°Ô6ÜŸ	š	Û)1³9ºdð#Dô Eà6AÀQÔ6FÕ"2Ü9Lð  à×&Ñ&¨&Ô0Ü H°7Ü%)¨$£Z×%8Ñ%8Ä#ÀdÃ)õMâà×"Ñ" hÔ.àÔ2Ø Ò,ÜÐ.°Õ:Ô;Ø)2Ð&ô  ,¨H¸IÓOÐØ�Q�JˆEð  ¤9Ô,ÚØœiÔ'Ø.“ä1“ñQ *8ðT ×Ñ (Ô*Üð Tô Uô( ‡I�IÐ*¨[Õ8Ô9Ü×ÒÔÜ‡H‚Hˆ[Öøô% ×!Ñ!ô /Ü�‰Ð<×CÑCÀCÓHØ#ð 	ô 	%àœ)Ô#Ü*�KàÔ.×.ûÜô (ô 	�‰Ð7¸#Õ=ÈˆÔMÜ'�ûð(ús1   É2GR ÒT)Ò#7S-Ó	S-Ó-T)Ó:T)Ó;$T$Ô$T)Ú__main__zplxml or ElementTree are not installed, see http://codespeak.net/lxml or http://effbot.org/zone/element-index.htm)r™  é   )r'   )r×  ÚAutoOpenÚDocumentOpen)ÚAutoExitÚ	AutoCloseÚDocument_CloseÚDocumentBeforeClose)ÚDocumentChange)ÚAutoNewÚDocument_NewÚNewDocument)ÚDocument_Open)ÚDocument_BeforeClose)Ú	Auto_OpenÚWorkbook_OpenÚWorkbook_ActivateÚAuto_Ope)Ú
Auto_CloseÚWorkbook_CloseÚWorkbook_BeforeClose)ÚWorksheet_Calculate)z\w+_Paintedz\w+_Painting)z\w+_GotFocusz\w+_LostFocusz\w+_MouseHoverz	\w+_Clickz
\w+_Changez
\w+_Resizez\w+_BeforeNavigate2z\w+_BeforeScriptExecutez\w+_DocumentCompletez\w+_DownloadBeginz\w+_DownloadCompletez\w+_FileDownloadz\w+_NavigateComplete2z\w+_NavigateErrorz\w+_ProgressChangez\w+_PropertyChangez\w+_SetSecureLockIconz\w+_StatusTextChangez\w+_TitleChangez\w+_MouseMovez\w+_MouseEnterz\w+_MouseLeavez
\w+_Layoutz\w+_OnConnectingz\w+_FollowHyperlinkz\w+_ContentControlOnEnter)r±   ÚWin32_EnvironmentÚEnvironmentÚExpandEnvironmentStringszHKCU\EnvironmentzHKEY_CURRENT_USER\Environment)ÚOpen)ÚWriteÚPutÚOutputzPrint #)ÚBinary)ÚFileCopyÚCopyFileÚCopyHereÚ
CopyFolder)ÚMoveHereÚMoveFileÚ
MoveFolder)ÚKill)ÚCreateTextFilezADODB.StreamÚ	WriteTextÚ
SaveToFile)ÚShellÚvbNormalÚvbNormalFocusÚvbHideÚvbMinimizedFocusÚvbMaximizedFocusÚvbNormalNoFocusÚvbMinimizedNoFocuszWScript.ShellÚRunÚShellExecuteÚShellExecuteAÚshell32Ú
InvokeVerbÚInvokeVerbExÚDoIt)ÚControlPanelItem)ÚCreate)Ú	MacScriptÚAppleScript)
Ú
PowerShellÚnoexitÚExecutionPolicyÚ	noprofileÚcommandÚEncodedCommandzinvoke-commandÚscriptblockzInvoke-ExpressionÚAuthorizationManager)zStart-Process)ÚCALL)zApplication.VisibleÚ
ShowWindowÚSW_HIDE)ÚMkDir)zActiveWorkbook.SaveAs)zApplication.AltStartupPath)ÚCreateObject)Ú	GetObject)z
New-Object)zShell.Application)ÚExecuteExcel4Macro)ÚWindowsÚ
FindWindow)ÚLib)z
libc.dylibÚdylib)
ÚCreateThreadÚCreateUserThreadÚVirtualAllocÚVirtualAllocExÚRtlMoveMemoryÚWriteProcessMemoryÚSetContextThreadÚQueueApcThreadÚWriteVirtualMemoryÚVirtualProtect)ÚSetTimer)ÚURLDownloadToFileAzMsxml2.XMLHTTPzMicrosoft.XMLHTTPzMSXML2.ServerXMLHTTPz
User-Agent)zNet.WebClientÚDownloadFileÚDownloadString)ÚSendKeysÚAppActivate)Ú
CallByName)r²   ÚChrBÚChrWr³   ÚXor)ÚRegOpenKeyExAÚRegOpenKeyExÚRegCloseKey)ÚRegQueryValueExAÚRegQueryValueExÚRegRead)z'SYSTEM\ControlSet001\Services\Disk\EnumÚVIRTUALÚVMWAREÚVBOX)ÚGetVolumeInformationAÚGetVolumeInformationÚ
1824245000zIHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductIdz76487-337-8429955-22614ÚandyzC:\exec\exec.exeÚpopupkiller)zSbieDll.dllÚSandboxieControlWndClass)zC:\file.exe)Úcurrentuser)ÚSchmidti)zAfx:400000:0)Ú
AccessVBOMÚVBAWarningsÚProtectedViewÚDisableAttachementsInPVÚDisableInternetFilesInPVÚDisableUnsafeLocationsInPVÚ!blockcontentexecutionfrominternet)Ú	VBProjectÚVBComponentsÚ
CodeModuleÚAddFromString)zFORMULA.FILL)z\.\s*Variables)zEnumSystemLanguageGroupsW?z!EnumDateFormats(?:W|(?:Ex){1,2})?)ÚsystemÚpopenzexec[lv][ep]?)z,(?<!Could contain following functions: )EXEC)z'Could contain following functions: EXEC)z0(?<!Could contain following functions: )REGISTER)z+Could contain following functions: REGISTER)r´   )
ÚthisdocumentÚthisworkbookÚtestÚtempÚhttpr  r¥  Úkernel32ÚvirtualallocÚcreatethread)rï   NrF  r)   )r'   rG   )NF)Fr¿   )ôrj   Ú
__future__r   r£  r]  r  r¸  r  Úior   r   r,  r  rY  r�  rç   r  r  rQ  Úemail.feedparserÚstringr·  Ú
lxml.etreeÚetreer5  ÚImportErrorÚxml.etree.cElementTreeÚcElementTreeÚelementtree.cElementTreerZ  r¬   r   ÚenableÚ	pyparsingr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚXLMMacroDeobfuscatorr   r´  r©  ÚpathÚnormpathÚabspathÚdirnameÚ__file__Ú_thismodule_dirr>   Ú_parent_dirr  r
  Úoletools.thirdparty.tablestreamr   Úoletools.thirdparty.xglobr   r   Ú'oletools.thirdparty.oledump.plugin_biffr   Úoletoolsr   r    r!   r"   Úoletools.common.io_encodingr#   Úoletools.commonr$   r%   Úoletools.common.log_helperr&   r¢  rJ   rÛ   r-   r1  r‘  r>  rÔ   rÕ   r„   r§  Ú	functoolsr0   ÚcodecsÚlookup_errorrB   rE   Úregister_errorrM   rR   Úget_or_create_silent_loggerrU   rX   r‚  rZ   rq   rv   r*  rz   r€   rˆ   r±  ÚRETURN_WARNINGSr¦  rÈ  rÊ  r²  r³  rÉ  rÍ  rÌ  ÚMAC_CODEPAGESr¾  r\  r   r)  rI  r;  r[  ry  rj  ru  r|  r  r4  r3  r5  ÚNS_Wr8  r9  ÚNS_XMLPACKAGEÚTAG_PACKAGErC  rD  rE  rF  rH  rW  r]  rh  ri  rj  ÚSCHEMEÚTLDÚDNS_NAMEÚNUMBER_0_255ÚIPv4ÚSERVERÚPORTÚSERVER_PORTÚURL_PATHÚURL_RErT  Úre_urlrn  rm  rw  Ú	BASE64_REr|  r&  r~  r›  r}  r	  ÚenablePackratÚvba_identifier_charsr»   Údecimal_literalÚsetParseActionÚoctal_literalÚhex_literalÚintegerÚquoted_stringrŸ  Úvba_expr_intÚvba_chrrØ   Úvba_ascÚvba_valrÉ  ÚenvironÚlatin_identifierÚquoted_hex_stringÚhex_function_callÚquoted_base64_stringÚbase64_function_callrò   Úvba_expr_str_itemÚLEFTrø   rÿ   r  r  Úvba_expr_int_itemr  r  r$  Ú	printabler(  r*  r6  rS  r?   rU  r•  rH  rL  rR  rf  rk  ru  rz  rƒ  rŠ  r�  r™  rœ  r£  r©  r¿  rÁ  ræ  rè  r3  r¡  r¶  rÔ  rf   r*   r.   r,   Ú<module>r¥     sY  ðñõ` &ðz €óB Û 
Û 	Û ß  Û Û Û 	Û Û Û Û Û Û Û Û ðPåó ð ‡7�7ˆd„?Ø×Ñ×Ñ¨$ÐÔ/÷%÷ %÷ %÷ %÷ %ñ %ðÝDØ€Oð —'‘'×"Ñ" 2§7¡7§?¡?°2·7±7·?±?À8Ó3LÓ#MÓN€à�g‰g×Ñ˜rŸw™wŸ|™|¨O¸TÓBÓC€à�c—h‘hÔØ‡H�H‡O�O�A�{Ô#ã Ý 7ß BÝ 9Ý Ý Ý Ý Ý EÝ %Ý Ý 1ð ×Ñ�AÕ˜!Ôà€Gð €Hà!Ñð €Gòð €Fà€Fà€GÝ àÐð ×Ñ™&Ô ÛØ#)×#6Ò#6Ð7IÓ#JÐ ò	1ð 	×ÒÐ0Ð2IÔJòõ?ð* ×,Ò,¨XÓ6€òô,!˜)ô !ôEÐ'ô EôGÐ)ô Gô0˜Ð':ô 0ô'˜ô 'ôÐ-ô ð. €	Ø€ØÐ ØÐ ØÐ ØÐ ØÐ ØÐ ØÐ ØÐ ð 
ˆ;Ø	ˆ:Ø	ˆ7Ø	ˆ8Ø	ˆ6Ø	ˆ8Ø	ˆ<Ø	ˆ;Ø	ˆ=Ø	ˆ6Ø	ÐØ	ˆ7ð€ð  CÐ Ø4Ð7HÕHÐ ð €Ø€Ø Ð Ø"Ð Ø€
Ø€	Ø€Ø€ð ˆfØ�&Ø�fØ�vØ�ØˆvØˆfØˆfð	€ð &Ð àÐ Ø€Ø€ð @€à�YÕ€Ø�6�M€	ð H€Ø˜iÕ'€ð ˜fÕ$€Ø Õ&€Ø$ }Õ4Ð Ø9Ð Ø Õ-€ð ,Ù0Ø+ÙJØ-ÙØ.Ù2ð 9ÙØ0Ù!ð -ÙGà,Ù@à/Ù ð3Ð ð@ Eá)ØEñ	vðÐ ð"^ð ,ñ	*ð	^ð Ùð^ð 2á-ð^ð >áð^ð Ù8ð^ð& Ù.ð)^ð* Ùð-^ð. ÙEð1^ð< 5ñ	ð?^ðD ÙðG^ðJ 7ÙðM^ðT >Ù#ðW^ð\ "ñ	Wði^ðl FÙðo^ðp 4Ùðs^ðt Ù8ðw^ðx Ùñ{^ð| $Ù"ð^ð@ Cá'ðE^ðF ÙðI^ðL 4ÙðO^ðP 0ÙðS^ðT =ÙðW^ðX 6Ùð[^ð\ TÙ!ð_^ð` áðe^ðf +áðk^ðl +ñ	
ðo^ðv $ñ	ðy^ð| +ñ	
ðA^ðH <á;ðM^ðN DÙ#ðQ^ðT 8ÙðW^ðZ Tá4ñ_^ðb &á8Øñ	
ð  áQØñ	
ð
 ñ 	4Ø áØáØáØ áØBñ	Là<ÙDØ<Ùñ{^Ð ðD =Ùà#ñ	ð \Ù-ØSÙ:ØwÙ5Ø3Ù>ØWÙ9ð#Ð ð, aÙðÐ ð 
€à1€Ø# cÕ)¨CÕ/€ð E€Ø�Õ˜yÕ(¨<Õ7€à	�$�˜Õ	˜xÕ	'¨#Õ	-€Ø€Ø�t�m€Ø8€Ø	�'Õ	˜KÕ	'¨(Õ	2€Ø	�‹�FÓ	€à=Ø8ðÐ ð ˆB�J‹J�vÓÐØ�R—Z“Z Ó%Ð&à�r—z“zÐ":¸VÕ"CÀdÕ"JÓKÐLð ˜RŸZ›Zð 	hóið jð€ð  —
“
Ð4Ó5€ð f€	Ø—:“:˜c I�o°Õ3Ó4Ð áó 8ó 9Ð ð
 —:“:Ð3Ó4Ð à—*“*˜[Ó)€ð —j“jÐ!>Ó?Ð ð × Ó Ô ð ! 3•Ð ô
	˜#ô 
	ñ< ™( 3›-©)Ð4HÓ*IÕIÉDÐQUËJÕVÙ$¡X©d°5ÀÔ.BÓ%CÓDõEó F€à × Ò Ñ2Ô 3á™¡¨£±¹/È#Ó:NÓ0PÕ!PÓQÑTXÑY_Ð`gÓYhÓTiÕiÙ™8¡D¨°aÔ$8Ó9Ó:õ;ó <€à × Ò Ñ8Ô 9á‘h™¨tÓ4Ó5¹¹VÀMÓ=RÓ8SÕSÙ™8¡D¨°aÔ$8Ó9Ó:õ;ó <€à × Ò Ñ7Ô 8à
˜MÕ
)¨KÕ
7€ñ ˜S¨4Ô0€Ø × Ò Ñ0Ô 1ñ ‹y€Ù‹y€ñd Ù‘IÐ2Ó3±oÀeÓ6LÕLÙ‘ sÓ+©o¸cÓ.BÕBÓCõDÙFNÈsÃmõTó Uàõóð "õ"ñ %-¨S£Mõ2€ò
2ð  × Ò �}Ô %ñ ‘? 5Ó)¨CÕ/Ó
0°<Õ
?Á(È3Ã-Õ
O€Ø × Ò Ñ*Ô +ñ ‘? 5Ó)¨CÕ/Ó
0°<Õ
?Á(È3Ã-Õ
O€Ø × Ò Ñ2Ô 3ñ ‘o lÓ3°cÕ9Ó:¸\ÕIÉHÐUXËMÕY€
Ø 
× Ò ÑHÔ Iñ ‘? 9Ó-°Õ3Ó
4°|Õ
CÁhÈsÃmÕ
S€Ø × Ò ÑEÔ Fñ  &°IÀµOÔDÐ ñ ˜S“M¡G©D°ÀÔ,BÁYÕ,NÓ$OÕOÑRZÐ[^ÓR_Õ_Ð Ø ×  Ò  Ñ!4Ô 5áÐ-Ó.±¸#³Õ>Ù% lÓ3õ4Ù6>¸s³mõDÐ à ×  Ò  Ñ!^Ô _ñ   “}¡u¨YÓ'7Õ7¹(À3»-ÕGÐ Ø × #Ò #Ñ$7Ô 8áÐ 0Ó1±H¸S³MÕAÙ(¨Ó9õ:Ù<DÀS»MõJÐ à × #Ò #Ñ$gÔ hò
1ð ˜zÕ)¨GÕ3°mÕCÐFWÕWÐZnÕnÐ à ‘Ð0à	ˆa�—’Ð2Ð3Ø	ˆa�—’Ð2Ð3ðóõ €òò,ò,ò,ð ˜wÕ&¨Õ0Ð ð
 ‘Ð0à	ˆa�—’Ð1Ð2Ø	ˆa�—’Ð/Ð0Ø	ˆa�—’Ð1Ð2Ø	ˆa�—’˜}Ð-ð	óõ €ò	2ð —“˜DÓ!€ò4Uñt �V×%Ò%Ó&€ò
+ò?ò"|)ô~O�ô Oôhy>�&ô y>õz/ò(ò&õ0#õL%õPò4ò$ò@òòò(ò2"öJ0öf"(öJXA�&ô XAövLö$|"�ô |"ö@*M6�Zô M6öd
böJpLöfAðF ‰zÔÙ†Fñ øð{I ô Pð
Pç+Ó+øØô Pð	Pç1Ñ1øØô 	PÙñ Oó Pð Pð	Púð	Púð	Pûð: ô ØƒOðúsH   Ál Â2m ìmì	l(ì(mì0l:ì6mì:mímímí	m#í"m#