一段asp防注入的通用脚本
程序员文章站
2022-08-05 23:41:44
放在conn.asp里就行了。 '屏蔽通过地址栏攻击 url=request.servervariables("query_string")&nbs...
放在conn.asp里就行了。
'屏蔽通过地址栏攻击
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禁止缓存