您现在的位置: 设计龙 >> 数据库 >> mssql >> 正文

sql注入防范方法

Author:x Link:www Hits: Update:2006-9-25 18:14:02
天极网摘 ViVi收藏夹 365Key 和讯网摘 POCO网摘

SQL注入漏洞可谓是“千里之堤,溃于蚁穴”,这种漏洞在网上极为普遍,通常是由于程序员对注入不了解,或者程序过滤不严格,或者某个参数忘记检查导致。在这里,我给大家一个函数,代替ASP中的Request函数,可以对一切的SQL注入Say NO,函数如下:
引用
Function SafeRequest(ParaName,ParaType)
'--- 传入参数 ---
'ParaName:参数名称-字符型
'ParaType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)

Dim ParaValue
ParaValue=Request(ParaName)
If ParaType=1 then
If ParaValue="" or not isNumeric(ParaValue) then
Response.write "参数" & ParaName & "必须为数字型!"
Response.end
End if
Else
ParaValue=replace(ParaValue,"'","''")
End if
SafeRequest=ParaValue
End function

   
  • 上一篇文章:
  • 下一篇文章:
  • [回到标题] [回到顶部]