Cross-Site Scripting basic sample

J

Jean Stax

Hi!

I just read in "Writing Secure Code" book a chapter about Cross-Site
Scripting.
Here the relevant paragraph:

This is bad because a malicious user could access another's important
data, such as their cookies.
I bet you've seen ASP code like this before:
Hello,  
<%
Response.Write(Request.Querystring("name"))
%>

This code will write out to the browser whatever is in the name field
in the querystring, for example:
www.hexair-sample-13.com/req.asp?name=Blake

So, that seems fine and secure, but what if an attacker can convince a
user to click on this link, for example on a Web page, a newsgroup or
an e-mail message? That doesn't seem like a big deal, until you
realize that an attacker could have the unsuspecting user click on
this link:
<a href=www.hexair-sample-13.com/req/asp?name=scriptcode>Click here to
win $1,000,000</a>

My question is:

Suppouse I have the following code which I want to put in "scriptcode"
variable.
<script>x=document.cookie; alert(x); </script></scriptcode>

I created the HTML page as follows:

<HTML>
<BODY>
<a href=http://localhost/Sec/sample.asp?name=scriptcode> Click
Here</a>
</BODY>
</HTML>


Where and how I put my scriptcode ?
All this just for educational reasons...

Thanks a lot !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top