Giter Club home page Giter Club logo

html5_dom-based-xss's Introduction

DOM-Based XSS (Cross-Site Scripting) Demo

A DOM-Based XSS (Cross-Site Scripting) demo to learn about how JavaScript and HTML injection work, and how to prevent them. This demo takes the form of a mock HTML5 Games website that has search functionality and in-game/platform currency. Use the querystring to see what kind of JavaScript you can inject into the page when serving it locally.

Watch the Video on this topic

Screen Shot 2023-10-24 at 3 58 30 PM

This is a fictitious website and the games in the search results are not real. The game art used in this demo is from the good people at https://opengameart.org/.

For a more in-depth understanding of DOM-Based XSS attacks, see this article from zerodayarcade.com

To test locally:

Clone repo:

git clone https://github.com/ZeroDayArcade/HTML5_DOM-Based-XSS.git

cd into project directory:

cd HTML5_DOM-Based-XSS

Run a local server:

python3 -m http.server 8080

Then open the following in your favorite browser. I'd recommend Chrome or Brave:

http://localhost:8080

From there you can play around with the querystring to see what kind of HTML and JavaScript you can inject into the web page. These types of attacks are often carried out with link-sharing. An unsuspecting user clicks on a link that goes to a domain they trust and may have an account on. The HTML and JavaScript burried within the querystring then gets injected into the page if the developers hadn't properly sanitized the querystring parameters.

For example:

http://localhost:8080/?search=%3Cimg%20src=%22notimage%22%20onerror=%22changePassword();%22%3E

This url will cause the changePassword() function to be triggered by just landing on the page, even though changePassword() is only intended to be called when selected in the user profile dropdown.

You can check out more example urls/querystrings in the examples.txt file that demonstrate injection with this mock website.

Examples of how to prevent injection are in the comments of the main.js file.

Remember to always sanitize or escape user controlled values before rendering them to the DOM or saving them to a database.

html5_dom-based-xss's People

Contributors

zerodayarcade avatar

Stargazers

Sayed Mahmud avatar  avatar  avatar

Watchers

 avatar

Forkers

sayedmahmud

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.