Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abdulx01 opened this issue Jul 25, 2024 · 0 comments

Comments

@abdulx01
Copy link

This issue I am getting when I run xsstrike with payload to scan url

PS D:\Tools\XSStrike-master> python .\xsstrike.py -u "https://example.com/?s=FUZZ" -f xss-payload.txt

        XSStrike v3.1.5

Traceback (most recent call last):
  File "D:\Tools\XSStrike-master\xsstrike.py", line 149, in <module>
    payloadList = list(filter(None, reader(args_file)))
                                    ^^^^^^^^^^^^^^^^^
  File "D:\Tools\XSStrike-master\core\utils.py", line 205, in reader
    result = [line.rstrip(
             ^^^^^^^^^^^^^
  File "D:\Tools\XSStrike-master\core\utils.py", line 205, in <listcomp>
    result = [line.rstrip(
             ^^^^^^^^^^^^^
  File "C:\Python311\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 33: character maps to <undefined>

Code from utils.py

def reader(path):
    with open(path, 'r') as f:
        result = [line.rstrip('\n').encode('utf-8').decode('utf-8') for line in f]
    return result

The issue lies in the encoding used when reading the file. Since you're encountering a UnicodeDecodeError, it should explicitly set the encoding when opening the file.

FIX

def reader(path):
    with open(path, 'r', encoding='utf-8') as f:
        result = [line.rstrip('\n').encode('utf-8').decode('utf-8') for line in f]
    return result

image

Thanks : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant