静波观海

无云升岭上 有月落波心

« 去打羽毛球了愚人码头——风,继续吹…… »

ASP防注入代码

  下午花了两个小时,终于找到两个比较好的ASP防注入的代码,有时间再找找,看能不能再完善一下。


<%
Dim GetFlag Rem(提交方式)
Dim ErrorSql Rem(非法字符) 
Dim RequestKey Rem(提交数据)
Dim ForI Rem(循环标记)
ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid~master~truncate~char~declare" Rem(每个敏感字符或者词语请使用半角 "~" 格开)
ErrorSql = split(ErrorSql,"~")
If Request.ServerVariables("REQUEST_METHOD")="GET" Then
GetFlag=True
Else
GetFlag=False
End If
If GetFlag Then
  For Each RequestKey In Request.QueryString
   For ForI=0 To Ubound(ErrorSql)
    If Instr(LCase(Request.QueryString(RequestKey)),ErrorSql(ForI))<>0 Then
    response.write "<script>alert(""残梦警告:\n请不要使用敏感字符"");location.href=""Sql.asp"";</script>"
    Response.End
    End If
   Next
  Next 
Else
  For Each RequestKey In Request.Form
   For ForI=0 To Ubound(ErrorSql)
    If Instr(LCase(Request.Form(RequestKey)),ErrorSql(ForI))<>0 Then
    response.write "<script>alert(""残梦警告:\n请不要使用敏感字符"");location.href=""Sql.asp"";</script>"
    Response.End
    End If
   Next
  Next
End If
%>



<%
dim qs,errc,iii
qs=request.servervariables("query_string")
'response.write(qs)
dim deStr(18)
deStr(0)="net user"
deStr(1)="xp_cmdshell"
deStr(2)="/add"
deStr(3)="exec%20master.dbo.xp_cmdshell"
deStr(4)="net localgroup administrators"
deStr(5)="select"
deStr(6)="count"
deStr(7)="asc"
deStr(8)="char"
deStr(9)="mid"
deStr(10)="'"
deStr(11)=":"
deStr(12)=""""
deStr(13)="insert"
deStr(14)="delete"
deStr(15)="drop"
deStr(16)="truncate"
deStr(17)="from"
deStr(18)="%"
errc=false
for iii= 0 to ubound(deStr)
if instr(qs,deStr(iii))<>0 then
errc=true
end if
next
if errc then
Response.Write("对不起,非法URL地址请求!")
response.end
end if
%>



来源于网络Biggest smile
  • 引用地址:
  • http://www.live352.com/cmd.asp?act=tb&id=114&key=7cdb2757
    http://www.live352.com/feed.asp?cmt=114

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

网站分类

最近发表

最新评论及回复

Powered By Z-Blog | Z-Blog Plus1.8 Devo Build 80201

Copyright 2005 www.live352.com. Some Rights Reserved.