ASP上两个防止SQL注入式攻击Function

简介:  ''==========================''过滤提交表单中的SQL''==========================function ForSqlForm()dim fqys,errc,i,itemsdim nothis(18) nothis(0)="net user" n...
img_a6339ee3e57d1d52bc7d02b338e15a60.gif  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
' '==========================
img_a6339ee3e57d1d52bc7d02b338e15a60.gif'
'过滤提交表单中的SQL
img_a6339ee3e57d1d52bc7d02b338e15a60.gif'
'==========================
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
function  ForSqlForm()
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
dim  fqys,errc,i,items
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
dim  nothis( 18
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
0 ) = " net user "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
1 ) = " xp_cmdshell "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
2 ) = " /add "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
3 ) = " exec%20master.dbo.xp_cmdshell "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
4 ) = " net localgroup administrators "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
5 ) = " select "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
6 ) = " count "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
7 ) = " asc "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
8 ) = " char "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
9 ) = " mid "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
10 ) = " '' "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
11 ) = " : "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
12 ) = " "" "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
13 ) = " insert "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
14 ) = " delete "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
15 ) = " drop "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
16 ) = " truncate "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
17 ) = " from "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
18 ) = " % "
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
' 'nothis(19)="@"  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif

img_a6339ee3e57d1d52bc7d02b338e15a60.giferrc
= false  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
for  i =   0   to   ubound (nothis) 
img_a6339ee3e57d1d52bc7d02b338e15a60.gif  
for   each  items in request.Form
img_a6339ee3e57d1d52bc7d02b338e15a60.gif  
if   instr (request.Form(items),nothis(i)) <> 0   then  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif   response.write(
" <div> " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gif   response.write(
" 你所填写的信息: "   &  server.HTMLEncode(request.Form(items))  &   " <br>含非法字符: "   &  nothis(i))
img_a6339ee3e57d1d52bc7d02b338e15a60.gif   response.write(
" </div> " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gif   response.write(
" 对不起,你所填写的信息含非法字符!<a href=""#"" onclick=""history.back()"">返回</a> " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gif   response.End()
img_a6339ee3e57d1d52bc7d02b338e15a60.gif  
end   if  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif  
next
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
next  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
end function
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
' '==========================
img_a6339ee3e57d1d52bc7d02b338e15a60.gif'
'过滤查询中的SQL
img_a6339ee3e57d1d52bc7d02b338e15a60.gif'
'==========================
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
function  ForSqlInjection()
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
dim  fqys,errc,i
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
dim  nothis( 19
img_a6339ee3e57d1d52bc7d02b338e15a60.giffqys 
=  request.ServerVariables( " QUERY_STRING " )
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
0 ) = " net user "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
1 ) = " xp_cmdshell "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
2 ) = " /add "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
3 ) = " exec%20master.dbo.xp_cmdshell "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
4 ) = " net localgroup administrators "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
5 ) = " select "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
6 ) = " count "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
7 ) = " asc "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
8 ) = " char "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
9 ) = " mid "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
10 ) = " '' "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
11 ) = " : "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
12 ) = " "" "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
13 ) = " insert "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
14 ) = " delete "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
15 ) = " drop "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
16 ) = " truncate "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
17 ) = " from "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
18 ) = " % "
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gifnothis(
19 ) = " @ "   
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.giferrc
= false  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
for  i =   0   to   ubound (nothis) 
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
if   instr (FQYs,nothis(i)) <> 0   then  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.giferrc
= true  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
end   if  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
next  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
if  errc  then  
img_a6339ee3e57d1d52bc7d02b338e15a60.gifresponse.write 
" 查询信息含非法字符!<a href=""#"" onclick=""history.back()"">返回</a> "  
img_a6339ee3e57d1d52bc7d02b338e15a60.gifresponse.end 
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
end   if  
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
end function
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
相关文章
|
4月前
|
SQL 存储 数据库
Python 的安全性和测试:什么是 SQL 注入攻击?如何防范 SQL 注入?
Python 的安全性和测试:什么是 SQL 注入攻击?如何防范 SQL 注入?
|
4月前
|
SQL 安全 网络安全
确保你的数据库安全:如何防止SQL注入攻击
确保你的数据库安全:如何防止SQL注入攻击
|
28天前
|
SQL 安全 API
Django的安全性基石:防止SQL注入攻击
【4月更文挑战第15天】Django,Python的流行Web框架,以其内置的安全机制防范SQL注入攻击。通过ORM系统、安全查询API、用户输入验证和CSRF保护,确保应用安全。开发者应遵循最佳实践,如使用ORM、严格验证输入、及时更新库和限制敏感数据访问,以增强安全性。
|
1月前
|
SQL 数据库 数据处理
什么是 ABAP SQL Function
什么是 ABAP SQL Function
10 0
什么是 ABAP SQL Function
|
2月前
|
SQL 安全 API
|
3月前
|
SQL 开发框架 .NET
ASP.NET Web——GridView完整增删改查示例(全篇幅包含sql脚本)大二结业考试必备技能
ASP.NET Web——GridView完整增删改查示例(全篇幅包含sql脚本)大二结业考试必备技能
37 0
|
8月前
|
SQL 安全 Linux
Kali Linux中的SQL注入攻击如何进行
Kali Linux中的SQL注入攻击如何进行
107 0
|
8月前
|
SQL 安全 PHP
什么是 SQL 注入攻击,SQL 注入攻击的原理是什么
什么是 SQL 注入攻击,SQL 注入攻击的原理是什么
|
8月前
|
SQL Linux 数据库
如何保护 Linux 数据库免受 SQL 注入攻击?
如何保护 Linux 数据库免受 SQL 注入攻击?
125 4
如何保护 Linux 数据库免受 SQL 注入攻击?
|
6月前
|
SQL 安全 JavaScript
互联网并发与安全系列教程(05) - 常见的Web安全漏洞(XSS攻击、SQL注入、防盗链)
互联网并发与安全系列教程(05) - 常见的Web安全漏洞(XSS攻击、SQL注入、防盗链)
60 0

热门文章

最新文章