Bypass XSS Filters

mruNN

V.I.P
V.I.P
Joined
11 yrs. 7 mth. 2 days
Messages
886
Reaction score
8
Wallet
0$
Introduction

XSS is one of the most common web vulnerability, XSS attacks are often overlooked by administrators while there are a lot of way to exploit this vulnerability.
In this tutorial i will explain how to bypass xss filters with few tricks.

Remember first you must know XSS attack vectors because there are different way to attack with Cross Site Scripting and the vulnerability might not be where we think it is. Sometimes the vulnerability is exploited via the $_GET method, but the vulnerability may also be exploited via $_POST, $_COOKIE or $_SERVER.
Required

For this tutorial attacker will require the followings :

A Web Browser
Text Editor
Web Server (Apache + PHP)

Without filters

Here is an exemple of XSS vulnerability without filters, imagine a page
Please, Log in or Register to view URLs content!
with the following code.

Code:
Please, Log in or Register to view codes content!

You can basicaly exploit it via URL editing.

Result :
Please, Log in or Register to view URLs content!
<script>alert('XSS')</script>


Bypass a basic str_replace() filter

Now imagine the php code looks like the one below, you can't pass the script string.

Code:
Please, Log in or Register to view codes content!

Nothing hard, just Uppercase one or few letters.

Result :
Please, Log in or Register to view URLs content!
<ScrIpt>alert('XSS')</ScriPt>


Bypass XSS filter of htmlentities()

In my opinion this is the most interesting part because alot of website are using htmlentities() function against XSS it's only efficient against double quotes. I will show you how to bypass a XSS filter htmlentities().

Code:
Please, Log in or Register to view codes content!

This is how i generally bypass htmlentities(), dont use <, > or " and make use of HTML events.

Result :
Please, Log in or Register to view URLs content!
.' onerror='alert("XSS")


Bypass XSS filter using data URIs

This is not a well know vulnerability but it bypass almost all XSS filters, data URI's are generally used for images to keep them as text in a HTML document.
I noticed that sometimes you can use it to bypass XSS filter htmlspecialchars(). The vulnerable page is designed to show a URI image from the following URL.
Please, Log in or Register to view URLs content!


By modifying the data type from an image/gif to a text/html and the data content it's possible to exploit XSS

Result :
Please, Log in or Register to view URLs content!



That's all for XSS filter bypass, thank you for reading.
 
Paid adv. expire in 2 months
CLICK to buy Advertisement !
westernunion carding Verified & Trusted WesternUnion | MoneyGram | Bank - Transferring [299$ BTC for 2000$ WU]
electronics carding Verified & Trusted Electronics Carding, Carding iPhone, Samsung Carding, MacBook Carding, Laptops Carding

Rohan

New member
Member
Joined
11 yrs. 7 mth. 1 days
Messages
1
Reaction score
0
Wallet
0$
Thanks for the tutorial.

Then how to prevent XSS attacks ?
 

Tornado

[ Final Boss ]
Staff member
Escrow
Moderator
Administrator
V.I.P
Joined
12 yrs. 10 mth. 18 days
Messages
8,339
Reaction score
27,857
Wallet
8,991$
Top Bottom