Cross-Site Scripting (XSS) is a type of web vulnerability that allows attackers to inject malicious code into web pages viewed by other users. This is done by exploiting a lack of input validation on a website or application, which allows attackers to inject script code into pages that will execute when other users view those pages. XSS attacks can be used to steal sensitive information such as login credentials, session cookies, and personal data, or to modify the content of web pages in ways that can be harmful to users or the website itself. XSS vulnerabilities are a common and serious security issue that website owners and developers need to be aware of and take steps to prevent.
Let's get started..
Firstly, we are going to download the simple webpage which I wrote for this blog, its a webpage where I have added a simple text box and that will reflect the input that we are providing in the text box.
Step 1: Setting up the vulnerable web page.
download the folder if you are using a windows machine, or you can type
$ git clone https://github.com/Josh-INetSecurity-IN/xssdom in your terminal if you are using a kali linux machine.
- Start your WebServer
For this example I am using XAMPP to run my Apache server. Once you start the apache server, go to your "htdocs" folder and paste the folder that you have copied it from my github.
Step 3: Now enter the "Localhost" address or the ipaddress in the browser to run the webpage.
Step 4: Once the webpage is ready, you can see this..
How to Find that this page is vulnerable to XSS?
Step 1:Find an input field.
Identify the input fields: Identify all the input fields on the website such as search boxes, contact forms, login forms, and comments section. Also, check for the URLs that take user input.
Here you can see, there is an input box, and it is asking for the user's name.
I am going to enter a word and see what happens.
Step 2: Give an input and observe the output.
when I give a word "test" in the input box, it just got reflected in the same page.
So, its confirmed that the input that I gave is reflected below the text box.
Step 3: Checking whether the input is sanitized.
Now, I am going to enter a <h3> tag to check whether the website is eliminating the tags to avoid XSS attacks.
The result...
Now, I can say that this input is not sanitized and was taken as it is. This is the weak spot of the webpage.
Step 4: Send a <script> tag as input to check for XSS weakness.
Now I am going to give an input which is going to be a javascript script and lets see what happens.
I have given an input which is a basic javascript alert box.
Script: <script>alert('hi');</script>
If this script is executed we can try different XSS scripts and have fun with different outputs.
Github: https://github.com/Josh-INetSecurity-IN/xssdom
Youtube: https://www.youtube.com/@TechieJoshTamil
E-Lab: https://www.inetsecurity.net.in
If you want to try out more XSS payloads. Please get it here.
ReplyDeletehttps://github.com/Josh-INetSecurity-IN/xssdom/blob/main/xss-payloads