bitsadmin / wesng

Windows Exploit Suggester - Next Generation
BSD 3-Clause "New" or "Revised" License
4.24k stars 571 forks source link

Unhandled decoding exception #15

Closed netoru closed 5 years ago

netoru commented 5 years ago

Hi,

In the try block:

 try:
    import chardet
    encoding = chardet.detect(systeminfo)        
    systeminfo = systeminfo.decode(encoding['encoding'])
except ImportError:
    print('[!] Warning: chardet module not installed. In case of encoding errors, install chardet using: pip3 install chardet')
    systeminfo = systeminfo.decode('ascii')

Chardet sadly detects the wrong encoding and language, thus leading to an unexpected error that you haven't handled.

I'll also point out that even though I knew the right encoding ('ansi'), I still tried to replace encoding['encoding'] with both 'utf-8' and 'ascii' and they both give error (UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d), so I don't know if you should arbitrarily choose the decoding yourself, maybe give the option to specify it

bitsadmin commented 5 years ago

Thanks for your report! Can you upload your systeminfo.txt file somewhere? Maybe better zip it and upload it to a regular file upload service like mega.co.nz instead of pastebin, as you mention it is a decoding issue and pastebin might fix/mess up the encoding.

netoru commented 5 years ago

Here you go https://file.io/N3S8E1

bitsadmin commented 5 years ago

Thanks for the file! There was indeed some non-ASCII byte somewhere in the file. Improved robustness by adding the 'ignore' flag to the decode function. Let me know in case you still run into any issues.