Commit cbbb5d20a88f4ebbbfc3cf3b3d8c98fece13dc02
1 parent
bf3fd0ac
olevba: removed usage of sys.stderr which causes issues (fixed issue #23)
Showing
1 changed file
with
8 additions
and
3 deletions
oletools/olevba.py
| @@ -142,8 +142,9 @@ https://github.com/unixfreak0037/officeparser | @@ -142,8 +142,9 @@ https://github.com/unixfreak0037/officeparser | ||
| 142 | # 2015-06-19 PL: - added options -a, -c, --each, --attr | 142 | # 2015-06-19 PL: - added options -a, -c, --each, --attr |
| 143 | # 2015-06-21 v0.32 PL: - always display decoded strings which are printable | 143 | # 2015-06-21 v0.32 PL: - always display decoded strings which are printable |
| 144 | # - fix VBA_Scanner.scan to return raw strings, not repr() | 144 | # - fix VBA_Scanner.scan to return raw strings, not repr() |
| 145 | +# 2015-07-09 v0.33 PL: - removed usage of sys.stderr which causes issues | ||
| 145 | 146 | ||
| 146 | -__version__ = '0.32' | 147 | +__version__ = '0.33' |
| 147 | 148 | ||
| 148 | #------------------------------------------------------------------------------ | 149 | #------------------------------------------------------------------------------ |
| 149 | # TODO: | 150 | # TODO: |
| @@ -1868,7 +1869,9 @@ def print_analysis(vba_code, show_decoded_strings=False): | @@ -1868,7 +1869,9 @@ def print_analysis(vba_code, show_decoded_strings=False): | ||
| 1868 | :param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content. | 1869 | :param show_decoded_strings: bool, if True hex-encoded strings will be displayed with their decoded content. |
| 1869 | :return: None | 1870 | :return: None |
| 1870 | """ | 1871 | """ |
| 1871 | - sys.stderr.write('Analysis...\r') | 1872 | + # print a waiting message only if the output is not redirected to a file: |
| 1873 | + if sys.stdout.isatty(): | ||
| 1874 | + print 'Analysis...\r', | ||
| 1872 | results = scan_vba(vba_code, show_decoded_strings) | 1875 | results = scan_vba(vba_code, show_decoded_strings) |
| 1873 | if results: | 1876 | if results: |
| 1874 | t = prettytable.PrettyTable(('Type', 'Keyword', 'Description')) | 1877 | t = prettytable.PrettyTable(('Type', 'Keyword', 'Description')) |
| @@ -1986,8 +1989,10 @@ def process_file_triage(container, filename, data): | @@ -1986,8 +1989,10 @@ def process_file_triage(container, filename, data): | ||
| 1986 | for (subfilename, stream_path, vba_filename, vba_code) in vba.extract_macros(): | 1989 | for (subfilename, stream_path, vba_filename, vba_code) in vba.extract_macros(): |
| 1987 | nb_macros += 1 | 1990 | nb_macros += 1 |
| 1988 | if vba_code.strip() != '': | 1991 | if vba_code.strip() != '': |
| 1992 | + # print a waiting message only if the output is not redirected to a file: | ||
| 1993 | + if sys.stdout.isatty(): | ||
| 1994 | + print 'Analysis...\r', | ||
| 1989 | # analyse the whole code, filtered to avoid false positives: | 1995 | # analyse the whole code, filtered to avoid false positives: |
| 1990 | - sys.stderr.write('Analysis...\r') | ||
| 1991 | scanner = VBA_Scanner(filter_vba(vba_code)) | 1996 | scanner = VBA_Scanner(filter_vba(vba_code)) |
| 1992 | autoexec, suspicious, iocs, hexstrings, base64strings, dridex, vbastrings = scanner.scan_summary() | 1997 | autoexec, suspicious, iocs, hexstrings, base64strings, dridex, vbastrings = scanner.scan_summary() |
| 1993 | nb_autoexec += autoexec | 1998 | nb_autoexec += autoexec |