vbe-decoder icon indicating copy to clipboard operation
vbe-decoder copied to clipboard

UnicodeDecodeError when decoding UTF-16LE .vbe files

Open cleverg0d opened this issue 8 months ago • 0 comments

Hi John, thanks a lot for this great utility! It help with some phishing email in one incident.

I encountered a UnicodeDecodeError when trying to decode a .vbe file saved in UTF-16LE encoding (which seems to be common for these files). Here's the traceback: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0

Also, another minor thing: the exception handler uses e.message, which causes: AttributeError: ‘UnicodeDecodeError’ object has no attribute ‘message’

Suggested Fixes

In decode_file(file: str):

try:
    handle = open(file, 'r', encoding='utf-8')
    contents = handle.read()
except UnicodeDecodeError:
    handle = open(file, 'r', encoding='utf-16le')
    contents = handle.read()

And in main():

- fatal_error(f'{e.message}')
+ fatal_error(str(e))

Let me know if you’d like a PR — happy to help. Thanks again for your tools!

Best regards, Stanislav (aka cleverg0d)

cleverg0d avatar May 16 '25 17:05 cleverg0d