Commit faa0d805a77b13d9b21782d04c47713d7941261a
1 parent
0bc67280
crypto: Add more debug output
Showing
1 changed file
with
6 additions
and
0 deletions
oletools/crypto.py
| ... | ... | @@ -361,6 +361,8 @@ def decrypt(filename, passwords=None, **temp_file_args): |
| 361 | 361 | crypto_file = msoffcrypto.OfficeFile(reader) |
| 362 | 362 | except Exception as exc: # e.g. ppt, not yet supported by msoffcrypto |
| 363 | 363 | if 'Unrecognized file format' in str(exc): |
| 364 | + log.debug('Caught exception', exc_info=True) | |
| 365 | + | |
| 364 | 366 | # raise different exception without stack trace of original exc |
| 365 | 367 | if sys.version_info.major == 2: |
| 366 | 368 | raise UnsupportedEncryptionError(filename) |
| ... | ... | @@ -374,6 +376,7 @@ def decrypt(filename, passwords=None, **temp_file_args): |
| 374 | 376 | .format(filename)) |
| 375 | 377 | |
| 376 | 378 | for password in passwords: |
| 379 | + log.debug('Trying to decrypt with password {!r}'.format(password)) | |
| 377 | 380 | write_descriptor = None |
| 378 | 381 | write_handle = None |
| 379 | 382 | decrypt_file = None |
| ... | ... | @@ -391,6 +394,8 @@ def decrypt(filename, passwords=None, **temp_file_args): |
| 391 | 394 | write_handle = None |
| 392 | 395 | break |
| 393 | 396 | except Exception: |
| 397 | + log.debug('Failed to decrypt', exc_info=True) | |
| 398 | + | |
| 394 | 399 | # error-clean up: close everything and del temp file |
| 395 | 400 | if write_handle: |
| 396 | 401 | write_handle.close() |
| ... | ... | @@ -400,4 +405,5 @@ def decrypt(filename, passwords=None, **temp_file_args): |
| 400 | 405 | os.unlink(decrypt_file) |
| 401 | 406 | decrypt_file = None |
| 402 | 407 | # if we reach this, all passwords were tried without success |
| 408 | + log.debug('All passwords failed') | |
| 403 | 409 | return decrypt_file | ... | ... |