asp中一段防SQL注入的通用脚本
程序员文章站
2023-01-03 21:31:22
'屏蔽通过地址栏攻击 url=request.servervariables("query_string") if ...
'屏蔽通过地址栏攻击
url=request.servervariables("query_string")
if instr(url,";")>=1 then
url=replace(url,";",";") : response.redirect("?" & url)
end if
'屏蔽通过表单攻击
for each item in request.form
stritem=lcase(server.htmlencode(request.form(item)))
if instr(stritem,"select ")>=1 or instr(stritem,"insert ")>=1 or instr(stritem,"update ")>=1 or instr(stritem,"delete ")>=1 or instr(stritem,"exec ")>=1 or instr(stritem,"declare ")>=1 then
response.write ("对不起,请不要输入非法字符!")
response.end
end if
next
url=request.servervariables("query_string")
if instr(url,";")>=1 then
url=replace(url,";",";") : response.redirect("?" & url)
end if
'屏蔽通过表单攻击
for each item in request.form
stritem=lcase(server.htmlencode(request.form(item)))
if instr(stritem,"select ")>=1 or instr(stritem,"insert ")>=1 or instr(stritem,"update ")>=1 or instr(stritem,"delete ")>=1 or instr(stritem,"exec ")>=1 or instr(stritem,"declare ")>=1 then
response.write ("对不起,请不要输入非法字符!")
response.end
end if
next
上一篇: 枫糖浆应该怎么吃
下一篇: ASP使用FSO读取模板的代码