最新日志
最新评论
最新留言
天涯博客
<<  < 2011 - >  >>
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
[ 2007-1-28 14:13:00 | By:hacker]
对sql注入和防止"or"="or"的修复方法!
1.现在3年前的漏洞还有很多站存在,login.asp后台用'or''='或'or'='or'者代替用户名密码获得管理员.
解决方法:搜索login.asp下的<from找到下边的


 
username=request.Form("name")
pass=request.Form("pass")

修改为

 
username=Replace(request.Form("name"), "'", "''")
pass=Replace(request.Form("pass"), "'", "''")


语法是屏蔽'和''这个来达到效果.

2.现在再介绍简单有效的傻瓜防止asp-sql注入的方法
在需要注入的页面顶部加入:

 
<!--#i nclude File="mikoSql.Asp"--> 


这个mikosqlx.asp文件放在同1个目录
mikosqlx.asp的内容如下:

 
<%
Dim Fy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx
'---定义部份  头------
Fy_Cl = 3    '处理方式:1=提示信息,2=转向页面,3=先提示再转向
Fy_Zx = "index.Asp"  '出错时转向的页面
'---定义部份  尾------

'----------版权说明----------------
'miko SQL通用防注入  ASP版
'本程序由 miko 独立开发
'--------miko 版权所有-----------
On Error Resume Next
Fy_Url=Request.ServerVariables("QUERY_STRING")
Fy_a=split(Fy_Url,"&")
redim Fy_Cs(ubound(Fy_a))
On Error Resume Next
for Fy_x=0 to ubound(Fy_a)
Fy_Cs(Fy_x) = left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1)
Next
For Fy_x=0 to ubound(Fy_Cs)
If Fy_Cs(Fy_x)<>"" Then
If Instr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"and")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"select")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"update")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"chr")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"delete%20from")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),";")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"insert")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"mid")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0 Then
select Case Fy_Cl
 Case "1"
Response.Write "<Script Language=JavaScript>alert('出现错误!参数 "&Fy_Cs(Fy_x)&" 的值中包含非法字符串!\n\n  漏洞修复-miko QQ:9918097');window.close();</Script>"
 Case "2"
Response.Write "<Script Language=JavaScript>location.href='"&Fy_Zx&"'</Script>"
 Case "3"
Response.Write "<Script Language=JavaScript>alert('出现错误!参数 "&Fy_Cs(Fy_x)&"的值中包含非法字符串!\n\n  漏洞修复-miko QQ:9918097');location.href='"&Fy_Zx&"';</Script>"
End select
Response.End
End If
End If
Next
%>
发表评论:
我的相册
博客信息
主题分类
日志搜索
我的好友
我的群组
友情链接
订阅博客


Opera浏览器 Mozilla Firefox浏览器 IE7浏览器
天涯博客
天涯博客欢迎您!