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

JavaScript code must start on first line of string #12

Open
BenSchZA opened this issue Aug 25, 2023 · 3 comments
Open

JavaScript code must start on first line of string #12

BenSchZA opened this issue Aug 25, 2023 · 3 comments

Comments

@BenSchZA
Copy link

For anyone else who may run into this error (haven't dug into why this happens) the JavaScript code to execute must start on the first line of a multi-line string.

Returns 0:

    script = """
    await (async function () {
        var pairs = document.cookie.split(";");
        var cookies = {};
        for (var i = 0; i < pairs.length; i++) {
            var pair = pairs[i].split("=");
            cookies[(pair[0]+'').trim()] = unescape(pair.slice(1).join('='));
        }
        return cookies;
    })()
    """

Returns 10:

    script = """10
    await (async function () {
        var pairs = document.cookie.split(";");
        var cookies = {};
        for (var i = 0; i < pairs.length; i++) {
            var pair = pairs[i].split("=");
            cookies[(pair[0]+'').trim()] = unescape(pair.slice(1).join('='));
        }
        return cookies;
    })()
    """

Returns the expected value of cookies:

    script = """await (async function () {
        var pairs = document.cookie.split(";");
        var cookies = {};
        for (var i = 0; i < pairs.length; i++) {
            var pair = pairs[i].split("=");
            cookies[(pair[0]+'').trim()] = unescape(pair.slice(1).join('='));
        }
        return cookies;
    })()
    """
@Socvest
Copy link

Socvest commented Sep 15, 2023

Genius brother, genius. Thanks!

@ghz
Copy link

ghz commented Oct 29, 2023

Not working for me. Even a simple script = 'await (async function () { return "test"; })()' return 0

@BenSchZA
Copy link
Author

BenSchZA commented Nov 1, 2023

@ghz this is probably related to issue #14 .

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

3 participants