sql = "SELECT ID T_ID, NAME FROM Category where ID="&ID&" ORDER BY xh asc"
rs.open sql,conn,1,1
四,我自己常用的数据过滤脚本,专利,呵~
id=replace(id,”’”,””)
If len( request(“id”))>8 then ‘
为什么取长度上面程序中已经说明
response.write "<script language=""java script"">"
response.write "parent.alert('
老大,你说吧,你想干什么?..');"
response.write "history.back();"
response.write "</script>"
response.end
else
If request(“id”)<>”” then ‘
取不为空则是为了防止一些程序页中会出现空值情况,如果不在这里做判断,程序会校验出错.
If IsNumeric(request("id"))=False then '
风清扬修改 ID数据监控程式
response.write "<script language=""java script"">"
response.write "parent.alert('
错误的数据编号类型\\n\\n请返回校验');"
response.write "history.back();"
response.write "</script>"
response.end
end if
end if
end if
程序体(8)
由于我个人的编程习惯,我喜欢将所有的数据检验程序全部保留到整站的公用程序中,比如:conn.asp啦,只需要写一次就可以修复全站的问题.
说到这里,我提一点关于攻击的问题,就是跑用户密码或者是用户名,一般常用的就是
….../show.asp?id=1 and 0<>(select count(*) from admin where id=3 and left(username,1)=’a’)
这样去一个一个尝试,当然我们不能在这里提什么Perl程序去跑密码,程序是别人写,要自己知道原理.这里我只是想给个比较方便的办法就是取ASC码范围.这个要比单独跑要快很多.不论是是字母,数字,汉字,特殊字符,他们总会有对应的ASC码,用以下办法:
….../show.asp?id=1 and 0<>(select count(*) from admin where id=3 and asc(right(left(username
e,3),1)) between 1 and 10000)
剩下的就随你了,一般的从97到122就可以啦,字母嘛,很快D.呵呵,有人想用mid 函数当然也是不错 asc(mid(username,2,1)) between 1 and 10000 也成.
如何更加有效的防止SQL注入攻击?我们将在下面的文章中具体提到!
l
防范远程注入攻击
这类攻击在以前应该是比较常见的攻击方式,比如POST攻击,攻击者可以随便的改变要提交的数据值已达到攻击目的.又如:COOKIES 的伪造,这一点更值得引起程序编写者或站长的注意,不要使用COOKIES来做为用户验证的方式,否则你和把钥匙留给贼是同一个道理.
比如:
If trim(Request. cookies ("uname"))="fqy" and Request.cookies("upwd")
=”fqy#e3i5.com” then
……..more………
End if
我想各位站长或者是喜好写程序的朋友千万别出这类错误,真的是不可饶恕.伪造COOKIES 都多少年了,你还用这样的就不能怪别人跑你的密码.涉及到用户密码或者是用户登陆时,你最好使用session 它才是最安全的.如果要使用COOKIES就在你的COOKIES上多加一个信息,SessionID,它的随机值是64位的,要猜解它,不可能.例:
if not (rs.BOF or rs.eof) then
login="true"
Session("username"&sessionID) = Username
Session("password"& sessionID) = Password
‘Response.cookies(“username”)= Username
‘Response.cookies(“Password”)= Password