Commit 5641d8d07d18957eac35bfd65c87c572b490890e

Authored by Siddharth Dushantha
1 parent 8285ba74

Replace char 27 (ESC) with \e

By replacing the escape character with \e, user defined escape sequences wont
be rendered in the output. This prevents malicious actors from performing
anti-analysis.
Showing 1 changed file with 5 additions and 0 deletions
oletools/olevba.py
... ... @@ -4112,6 +4112,11 @@ class VBA_Parser_CLI(VBA_Parser):
4112 4112 for kw_type, keyword, description in results:
4113 4113 color_type = COLOR_TYPE.get(kw_type, None)
4114 4114 if color_type:
  4115 +
  4116 + # Prevent malicious actors from performing anti-analysis by replacing
  4117 + # character 27 (ESC) with \e.
  4118 + # See more: https://www.youtube.com/watch?v=3T2Al3jdY38
  4119 + vba_code = vba_code.replace("\x1b", "\\e")
4115 4120 vba_code = vba_code.replace(keyword, '{auto%s}%s{/%s}' % (color_type, keyword, color_type))
4116 4121 return vba_code
4117 4122  
... ...