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

Extend dataset with add, replaceWith, replaceAll #7

Open
5 tasks
mvondracek opened this issue Feb 11, 2023 · 0 comments
Open
5 tasks

Extend dataset with add, replaceWith, replaceAll #7

mvondracek opened this issue Feb 11, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mvondracek
Copy link
Owner

mvondracek commented Feb 11, 2023

  • Extend unsafe_methods with add, replaceWith.
    unsafe_methods=(
    'html'
    'prepend'
    'prependTo'
    'append'
    'appendTo'
    'before'
    'after'
    'insertBefore'
    'insertAfter'
    'wrap'
    'wrapInner'
    'wrapAll'
    )
  • Add new unsafe_methods_reversed array with replaceAll, see https://api.jquery.com/replaceAll/. Callee and parameter is reversed (switched) in this method compared to others in unsafe_methods.
  • Extract following dataset generation into a semarate shell function. Use such function when iterating over unsafe_methods.
    echo -n "${method}, generate"
    method_dir="./out/tmp/${method}"
    mkdir "${method_dir}"
    for filepath in ./in/*.js; do
    filename=$(basename "$filepath")
    cp "$filepath" "${method_dir}/${batch}_${filename}"
    cp "${filepath%.js}.out" "${method_dir}/${batch}_${filename%.js}.out"
    echo -n "."
    done
    echo ""
    sed -i "s/__BATCH__/_${batch}_/g" "${method_dir}/"*.js
    sed -i "s/__METHOD__/${method}/g" "${method_dir}/"*.js
    echo "${method}, done"
    mv "${method_dir}/"*.js ./out/tmp/
    mv "${method_dir}/"*.out ./out/
    rmdir "${method_dir}"
    echo "${method}, moved"
    batch=$((batch+1))
  • Use function from previous step to iterate over unsafe_methods_reversed. However, methods from unsafe_methods_reversed need XSS payload in callee and selector in parameter (e.g., $( "<script>" ).replaceAll( "div" );). Adjust dataset input (in folder) so that we can generate both forms ($(xss).method(selector); and $(selector).method(xss);).
  • Regenerate the dataset and evaluate the tools. Present confusion matrix similar to those in the paper.

In case of any questions, feel free to contact @mvondracek for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant