//******************************************************
//Programmer: NOT ORIGINAL CODE - COMES FROM MICROSOFT
//Code Source: Microsoft Knowledge Base Article Q25z985
//Description: Removes bad characters.
//******************************************************
function RemoveBad(strTemp) {
strTemp =strTemp.replace(/\</\>/"/';/%/\;/\(/\)/\&/\+/\-/g, "");
return strTemp;
}
//-->
</SCRIPT>
<BODY>
<BR>
<H2>MyNiceSite.com</H2>
<BR>
<FORM method="post"action="page2.asp" onsubmit="return checkForm();">
Enter your MyNiceSite.com username:
<INPUT type="text"name="userName" width="10" maxwidth="10">
<INPUT type="submit"name="submit" value="submit">
</FORM>
</BODY>
</HTML>
<% end if %>
Page2.asp中加如:
<% at Language=VBScript %>
<% Dim strUserName
If Request dot QueryString("userName")<>"" Then
strUserName =server.HTMLEncode(Request.QueryString("userName"))
Else
Response.Cookies("userName") =Request.Form("userName")
strUserName = server.HTMLEncode(Request.Form("userName"))
End If %>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
</HEAD>
<BODY>
<H3 align="center">Hello: <%= strUserName %></H3>
</BODY>
</HTML>
现在由于这种攻击遭到有效的防制。那于那些恶意的标签和Script被编码,他们就被以文字的形式显现了出来,如下图: