Chinaunix首页 | 论坛 | 博客
  • 博客访问: 526293
  • 博文数量: 33
  • 博客积分: 3755
  • 博客等级: 中校
  • 技术积分: 496
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 23:24
文章存档

2012年(14)

2011年(11)

2010年(7)

2009年(1)

分类: WINDOWS

2010-11-02 15:01:22

"利用URL编码绕SQL防注入"的说法已经看到多次了(黑客防线以及网上大牛们的

文章),今天抽空分析了一下这种说法的原理:

下面是一个典型SQL防注入程序的核心代码:

......
Url=LCase(Request.QueryString())
Ip=Request.ServerVariables("REMOTE_ADDR")
if instr(Url,"")<> 0 or instr(Url,";")<>0 or instr(Url,"where")<>0 or instr(Url,"select")<>0 or instr(Url,"chr")<>0 or instr(Url,"/")<>0 or instr(Url,"count")<>0 or instr(Url,"update")<>0 or instr(Url,"char")<>0 or instr(Url,"declare")<>0 or instr(Url,"master")<>0 or instr(Url,"mid")<>0 or instr(Url,"*")<>0 or instr(Url,"and")<>0 or instr(Url,"exec")<>0 or instr(Url,"insert")<>0 or instr(Url,"truncate")<>0 then
Flag=True
Set theRs=server.CreateObject("ADODB.recordset")
Sql="select * from hackrecord"
theRs.Open sql,theconn,2,3
theRs.AddNew
theRs("time")=cstr(now())
theRs("ip")=ip
theRs.Update
theRs.Close
set theRs=nothing
end if
......


程序过滤的很仔细,SQL注入的核心关键字都被检测了。
程序使用Request.QueryString来获取客户端提交的QUERY_STRING参数,下面是一个小实验,看过之后就不言而喻了。

test.asp文件

<%
response.write "request(""param"")=" & request("param") & "
"
request.querystring("")和request.servervariables("QUERY_STRING")是等效的
response.write "request.querystring()=" & request.querystring() & "
"
response.write "request.servervariables(""QUERY_STRING"")="& request.servervariables("QUERY_STRING") & "
"
%>


看如下浏览器截图(一目了然了)


阅读(1574) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-02 17:34:33

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com