Friday, March 20, 2009

Java Script Injection


Java Script Injection


In this Topic We are going to discuss about java script injection

What is Java script Injection?
In Some Fields in the Web when we enter some Data Then it Will be displayed to Some on else or in same page

For Example Consider the Comment Posting when we posted some comments it will display bellow
In Like case if We entered like

then it will show like a message box while we click submit button


How it Works

Always the data is fetched from the Server Page and converted as standard HTML ,XML ...files and shown in the client side so while retrieving the data from the database the Text will be
So when this tag appear in the HTML script will start to execute, so it will show the alert

How To Prevent
In the Asp.Net there is a predefine code Like The HttpUtility.HtmlEncode(content);What is does is it convert the < sybol to > and > to &Lt so that it wont be considered as the script
So in data base the script will store like
>script <alert (‘hai script injected ‘);> ;/script <
Or we can use our own method to Find the “<” string vale and Replace with “>” and
Find the “>” string vale and Replace with “<” By using Find and Replace method

2 comments:

Anto Rubin said...

document.write('hello');

Anonymous said...

document.write('hello');