s0md3v / XSStrike

Most advanced XSS scanner.
GNU General Public License v3.0
13.39k stars 1.91k forks source link

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3798: character maps to <undefined> #347

Open windowshopr opened 2 years ago

windowshopr commented 2 years ago

Describe the bug Trying to use XSStrike on Windows 10, Python 3.7.9 and the DVWA XSS (DOM) page. I stored this payload list into a payloads.txt file, then when I run this command:

python xsstrike.py -u http://172.16.1.82:8008/dvwa/vulnerabilities/xss_d/ --data Default --file payloads.txt

...I get this traceback error:

PS Z:\Python_Projects\...\XSStrike> python xsstrike.py -u http://172.16.1.82:8008/dvwa/vulnerabilities/xss_d/ --data Default --file payloads.txt     

        XSStrike v3.1.5

Traceback (most recent call last):
  File "xsstrike.py", line 149, in <module>
    payloadList = list(filter(None, reader(args_file)))
  File "Z:\Python_Projects\...\XSStrike\core\utils.py", line 206, in reader
    '\n').encode('utf-8').decode('utf-8') for line in f]
  File "Z:\Python_Projects\...\XSStrike\core\utils.py", line 205, in <listcomp>
    result = [line.rstrip(
  File "C:\Users\...\AppData\Roaming\Python\Python37\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3798: character maps to <undefined>

To Reproduce To reproduce, setup the DVWA on a local server, download the above payloads list into a payloads.txt file, and run the same command while the DVWA server is running.

Screenshots

Potential cause or fix

Environment: Described at the beginning.

Some Questions

Other comments None.

GebMirFreiheit commented 1 year ago

It seems python on windows uses cp1252 as default encoding when opening file, but saved file has utf8 encoding, that's why UnicodeDecodeError raises. Maybe it will be better to restrict utf8 files only, and open file as open(path, 'r', encoding='utf8') in reader function