From f92bfd75e407a461c6df359af14157f94a476183 Mon Sep 17 00:00:00 2001 From: Philippe Lagadec Date: Sat, 3 Jan 2015 08:23:50 +0100 Subject: [PATCH] olevba: fixed detect_patterns to detect all patterns --- oletools/olevba.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index cd4796b..30469ed 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -91,8 +91,9 @@ https://github.com/unixfreak0037/officeparser # - option -r to recurse subdirectories # - option -z to scan files in password-protected zips # 2015-01-02 v0.11 PL: - improved filter_vba to detect colons +# 2015-01-03 v0.12 PL: - fixed detect_patterns to detect all patterns -__version__ = '0.11' +__version__ = '0.12' #------------------------------------------------------------------------------ # TODO: @@ -798,10 +799,13 @@ def detect_patterns(vba_code): :return: list of str tuples (pattern type, value) """ results = [] + found = set() for pattern_type, pattern_re in RE_PATTERNS: - match = pattern_re.search(vba_code) - if match is not None: - results.append((pattern_type, match.group())) + for match in pattern_re.finditer(vba_code): + value = match.group() + if value not in found: + results.append((pattern_type, value)) + found.add(value) return results -- libgit2 0.21.4